MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / getNumpyTypeDesc

Method getNumpyTypeDesc

src/fastertransformer/utils/Tensor.cc:256–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256std::string Tensor::getNumpyTypeDesc(DataType type) const
257{
258 static const std::unordered_map<DataType, std::string> type_map{{TYPE_INVALID, "x"},
259 {TYPE_BOOL, "?"},
260 {TYPE_BYTES, "b"},
261 {TYPE_UINT8, "u1"},
262 {TYPE_UINT16, "u2"},
263 {TYPE_UINT32, "u4"},
264 {TYPE_UINT64, "u8"},
265 {TYPE_INT8, "i1"},
266 {TYPE_INT16, "i2"},
267 {TYPE_INT32, "i4"},
268 {TYPE_INT64, "i8"},
269 {TYPE_FP16, "f2"},
270 {TYPE_FP32, "f4"},
271 {TYPE_FP64, "f8"}};
272
273 if (type == TYPE_BF16) {
274 FT_LOG_WARNING("getNumpyTypeDesc(TYPE_BF16) returns an invalid type 'x' since Numpy doesn't "
275 "support bfloat16 as of now, it will be properly extended if numpy supports. "
276 "Please refer for the discussions https://github.com/numpy/numpy/issues/19808.");
277 }
278
279 return type_map.count(type) > 0 ? type_map.at(type) : "x";
280}
281
282void Tensor::saveNpy(const std::string& filename) const
283{

Callers

nothing calls this directly

Calls 1

atMethod · 0.80

Tested by

no test coverage detected