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

Method getSafe

samples/common/sampleEngines.cpp:160–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160nvinfer1::safe::ICudaEngine* LazilyDeserializedEngine::getSafe()
161{
162 SMP_RETVAL_IF_FALSE(
163 mIsSafe, "Safe mode is not enabled, but trying to get safe engine!", nullptr, sample::gLogError);
164
165 ASSERT(sample::hasSafeRuntime());
166 if (mSafeEngine == nullptr)
167 {
168 SMP_RETVAL_IF_FALSE(
169 !mEngineBlob.empty(), "Engine blob is empty. Nothing to deserialize!", nullptr, sample::gLogError);
170
171 SMP_RETVAL_IF_FALSE(
172 mDLACore == -1, "Safe DLA engine built with kDLA_STANDALONE should not be deserialized in TRT!", nullptr,
173 sample::gLogError);
174
175 using time_point = std::chrono::time_point<std::chrono::high_resolution_clock>;
176 using duration = std::chrono::duration<float>;
177 time_point const deserializeStartTime{std::chrono::high_resolution_clock::now()};
178
179 std::unique_ptr<safe::IRuntime> safeRuntime{sample::createSafeInferRuntime(sample::gLogger.getTRTLogger())};
180 SMP_RETVAL_IF_FALSE(safeRuntime != nullptr, "SafeRuntime creation failed", nullptr, sample::gLogError);
181 safeRuntime->setErrorRecorder(&gRecorder);
182 mSafeEngine.reset(
183 safeRuntime->deserializeCudaEngine(mEngineBlob.data(), mEngineBlob.size()));
184 SMP_RETVAL_IF_FALSE(mSafeEngine != nullptr, "SafeEngine deserialization failed", nullptr, sample::gLogError);
185
186 time_point const deserializeEndTime{std::chrono::high_resolution_clock::now()};
187 sample::gLogInfo << "SafeEngine deserialized in "
188 << duration(deserializeEndTime - deserializeStartTime).count() << " sec." << std::endl;
189 }
190
191 return mSafeEngine.get();
192}
193
194void setTensorScalesFromCalibration(nvinfer1::INetworkDefinition& network, std::vector<IOFormat> const& inputFormats,
195 std::vector<IOFormat> const& outputFormats, std::string const& calibrationFile)

Callers 1

setUpInferenceFunction · 0.80

Calls 9

hasSafeRuntimeFunction · 0.85
createSafeInferRuntimeFunction · 0.85
deserializeCudaEngineMethod · 0.80
emptyMethod · 0.45
setErrorRecorderMethod · 0.45
resetMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected