MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / type

Function type

python/src/utils.cpp:65–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65nvinfer1::DataType type(py::dtype const& type)
66{
67 if (type.is(py::dtype("f4")))
68 {
69 return nvinfer1::DataType::kFLOAT;
70 }
71 else if (type.is(py::dtype("f2")))
72 {
73 return nvinfer1::DataType::kHALF;
74 }
75 else if (type.is(py::dtype("i4")))
76 {
77 return nvinfer1::DataType::kINT32;
78 }
79 else if (type.is(py::dtype("i1")))
80 {
81 return nvinfer1::DataType::kINT8;
82 }
83 else if (type.is(py::dtype("b1")))
84 {
85 return nvinfer1::DataType::kBOOL;
86 }
87 else if (type.is(py::dtype("u1")))
88 {
89 return nvinfer1::DataType::kUINT8;
90 }
91 int32_t constexpr kBITS_PER_BYTE{8};
92 std::stringstream ss{};
93 ss << "[TRT] [E] Could not implicitly convert NumPy data type: " << type.kind()
94 << (type.itemsize() * kBITS_PER_BYTE) << " to TensorRT.";
95 std::cerr << ss.str() << std::endl;
96 PY_ASSERT_VALUE_ERROR(false, ss.str());
97 return nvinfer1::DataType::kFLOAT;
98}
99
100void throwPyError(PyObject* type, std::string const& message)
101{

Calls

no outgoing calls