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

Method get

samples/common/sampleEngines.cpp:94–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92} // namespace
93
94nvinfer1::ICudaEngine* LazilyDeserializedEngine::get()
95{
96 SMP_RETVAL_IF_FALSE(
97 !mIsSafe, "Safe mode is enabled, but trying to get standard engine!", nullptr, sample::gLogError);
98
99 if (mEngine == nullptr)
100 {
101 SMP_RETVAL_IF_FALSE(
102 !mEngineBlob.empty(), "Engine blob is empty. Nothing to deserialize!", nullptr, sample::gLogError);
103
104 using time_point = std::chrono::time_point<std::chrono::high_resolution_clock>;
105 using duration = std::chrono::duration<float>;
106 time_point const deserializeStartTime{std::chrono::high_resolution_clock::now()};
107
108 if (mLeanDLLPath.empty())
109 {
110 mRuntime.reset(createRuntime());
111 }
112 else
113 {
114 mParentRuntime.reset(createRuntime());
115 ASSERT(mParentRuntime.get() != nullptr);
116
117 mRuntime.reset(mParentRuntime->loadRuntime(mLeanDLLPath.c_str()));
118 }
119 ASSERT(mRuntime.get() != nullptr);
120
121 if (mVersionCompatible)
122 {
123 // Application needs to opt into allowing deserialization of engines with embedded lean runtime.
124 mRuntime->setEngineHostCodeAllowed(true);
125 }
126
127 if (!mTempdir.empty())
128 {
129 mRuntime->setTemporaryDirectory(mTempdir.c_str());
130 }
131
132 mRuntime->setTempfileControlFlags(mTempfileControls);
133
134 SMP_RETVAL_IF_FALSE(mRuntime != nullptr, "runtime creation failed", nullptr, sample::gLogError);
135 if (mDLACore != -1)
136 {
137 mRuntime->setDLACore(mDLACore);
138 }
139 mRuntime->setErrorRecorder(&gRecorder);
140 for (auto const& pluginPath : mDynamicPlugins)
141 {
142 mRuntime->getPluginRegistry().loadLibrary(pluginPath.c_str());
143 }
144 mEngine.reset(mRuntime->deserializeCudaEngine(mEngineBlob.data(), mEngineBlob.size()));
145 SMP_RETVAL_IF_FALSE(mEngine != nullptr, "Engine deserialization failed", nullptr, sample::gLogError);
146
147 time_point const deserializeEndTime{std::chrono::high_resolution_clock::now()};
148 sample::gLogInfo << "Engine deserialized in "
149 << duration(deserializeEndTime - deserializeStartTime).count() << " sec." << std::endl;
150 }
151

Callers 15

constructNetworkMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
_downloadFileFunction · 0.45
_parseArgsFunction · 0.45
getFilePathFunction · 0.45
build_evaluatorFunction · 0.45
get_map_funcFunction · 0.45
load_plugin_lib.pyFile · 0.45
sample.pyFile · 0.45
model.pyFile · 0.45
constructNetworkMethod · 0.45

Calls 13

loadRuntimeMethod · 0.80
c_strMethod · 0.80
setTemporaryDirectoryMethod · 0.80
deserializeCudaEngineMethod · 0.80
createRuntimeFunction · 0.70
emptyMethod · 0.45
resetMethod · 0.45
setDLACoreMethod · 0.45
setErrorRecorderMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected