| 63 | } |
| 64 | |
| 65 | nvinfer1::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 | |
| 100 | void throwPyError(PyObject* type, std::string const& message) |
| 101 | { |
no outgoing calls