| 24 | namespace tensorrt |
| 25 | { |
| 26 | PYBIND11_MODULE(TENSORRT_MODULE, m) |
| 27 | { |
| 28 | // Python strings can be automatically converted to FallbackStrings, |
| 29 | // whose lifetime is tied to TRT objects that reference, but do not own, a string. |
| 30 | // See ForwardDeclarations.h for more information about FallbackString. |
| 31 | // Note that we cannot allow Python to deallocate this string, hence the py::nodelete. |
| 32 | // |
| 33 | // Important: *All* Python enum and class interfaces exported by this module *must* be |
| 34 | // declared with py::module_local() scope, so that multiple TRT runtime modules |
| 35 | // (e.g. tensorrt_lean and tensorrt_dispatch) may be imported by the same Python script |
| 36 | // without conflicts. |
| 37 | // |
| 38 | // See https://pybind11.readthedocs.io/en/stable/advanced/classes.html#module-local-class-bindings |
| 39 | // for more information. |
| 40 | py::class_<FallbackString, std::unique_ptr<FallbackString, py::nodelete>>(m, "FallbackString", py::module_local()) |
| 41 | .def(py::init<std::string>()) |
| 42 | .def(py::init<py::str>()); |
| 43 | py::implicitly_convertible<std::string, FallbackString>(); |
| 44 | py::implicitly_convertible<py::str, FallbackString>(); |
| 45 | |
| 46 | // Make it so that we can use lists of PluginFields without creating unwanted copies. |
| 47 | // This is declared opaque in ForwardDeclarations.h |
| 48 | py::bind_vector<std::vector<nvinfer1::PluginField>>(m, "PluginFieldCollection"); |
| 49 | |
| 50 | // Order matters here - Dependencies must be resolved properly! |
| 51 | // TODO: Maybe use actual forward declarations and define functions later. |
| 52 | bindFoundationalTypes(m); |
| 53 | bindPlugin(m); |
| 54 | #if EXPORT_ALL_BINDINGS |
| 55 | bindInt8(m); |
| 56 | bindGraph(m); |
| 57 | bindAlgorithm(m); |
| 58 | #endif |
| 59 | bindCore(m); |
| 60 | #if EXPORT_ALL_BINDINGS |
| 61 | // Parsers |
| 62 | bindOnnx(m); |
| 63 | bindUff(m); |
| 64 | bindCaffe(m); |
| 65 | #endif |
| 66 | } |
| 67 | } // namespace tensorrt |
nothing calls this directly
no test coverage detected