MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / get

Method get

src/Detector/tensorrt_yolo/common/sampleEngines.cpp:76–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74} // namespace
75
76nvinfer1::ICudaEngine* LazilyDeserializedEngine::get()
77{
78 SMP_RETVAL_IF_FALSE(
79 !mIsSafe, "Safe mode is enabled, but trying to get standard engine!", nullptr, sample::gLogError);
80
81 if (mEngine == nullptr)
82 {
83#if (NV_TENSORRT_MAJOR > 8)
84 SMP_RETVAL_IF_FALSE(getFileReader().isOpen() || !getBlob().empty(), "Engine is empty. Nothing to deserialize!",
85 nullptr, sample::gLogError);
86#endif
87 using time_point = std::chrono::time_point<std::chrono::high_resolution_clock>;
88 using duration = std::chrono::duration<float>;
89 time_point const deserializeStartTime{std::chrono::high_resolution_clock::now()};
90
91 if (mLeanDLLPath.empty())
92 {
93 mRuntime.reset(createRuntime());
94 }
95 else
96 {
97 mParentRuntime.reset(createRuntime());
98 ASSERT(mParentRuntime.get() != nullptr);
99
100 mRuntime.reset(mParentRuntime->loadRuntime(mLeanDLLPath.c_str()));
101 }
102 ASSERT(mRuntime.get() != nullptr);
103
104 if (mVersionCompatible)
105 {
106 // Application needs to opt into allowing deserialization of engines with embedded lean runtime.
107 mRuntime->setEngineHostCodeAllowed(true);
108 }
109
110 if (!mTempdir.empty())
111 {
112 mRuntime->setTemporaryDirectory(mTempdir.c_str());
113 }
114
115 mRuntime->setTempfileControlFlags(mTempfileControls);
116
117 SMP_RETVAL_IF_FALSE(mRuntime != nullptr, "runtime creation failed", nullptr, sample::gLogError);
118 if (mDLACore != -1)
119 {
120 mRuntime->setDLACore(mDLACore);
121 }
122 mRuntime->setErrorRecorder(&gRecorder);
123#if !TRT_WINML
124 for (auto const& pluginPath : mDynamicPlugins)
125 {
126 mRuntime->getPluginRegistry().loadLibrary(pluginPath.c_str());
127 }
128#endif
129
130#if (NV_TENSORRT_MAJOR > 8)
131 if (getFileReader().isOpen())
132 {
133 mEngine.reset(mRuntime->deserializeCudaEngine(getFileReader()));

Callers 15

mainFunction · 0.45
OpenCaptureMethod · 0.45
InitDetectorMethod · 0.45
InitDetectorMethod · 0.45
InitDetectorMethod · 0.45
InitDetectorMethod · 0.45
InitDetectorMethod · 0.45
InitDetectorMethod · 0.45
mainFunction · 0.45
CaptureThreadMethod · 0.45
mainFunction · 0.45
InitMethod · 0.45

Calls 4

createRuntimeFunction · 0.85
isOpenMethod · 0.80
emptyMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected