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

Method infer

samples/sampleNamedDimensions/sampleNamedDimensions.cpp:249–286  ·  view source on GitHub ↗

\brief Runs the TensorRT inference engine for this sample \details This function is the main execution function of the sample. It allocates the buffer, sets inputs and executes the engine.

Source from the content-addressed store, hash-verified

247//! sets inputs and executes the engine.
248//!
249bool SampleNamedDimensions::infer()
250{
251 // Create RAII buffer manager object
252 samplesCommon::BufferManager buffers(mEngine);
253
254 auto context = SampleUniquePtr<nvinfer1::IExecutionContext>(mEngine->createExecutionContext());
255 if (!context)
256 {
257 return false;
258 }
259
260 // Read the input data into the managed buffers
261 ASSERT(mParams.inputTensorNames.size() == 2);
262 if (!processInput(buffers))
263 {
264 return false;
265 }
266
267 // Memcpy from host input buffers to device input buffers
268 buffers.copyInputToDevice();
269
270 bool status = context->executeV2(buffers.getDeviceBindings().data());
271 if (!status)
272 {
273 return false;
274 }
275
276 // Memcpy from device output buffers to host output buffers
277 buffers.copyOutputToHost();
278
279 // Verify results
280 if (!verifyOutput(buffers))
281 {
282 return false;
283 }
284
285 return true;
286}
287
288//!
289//! \brief Reads the input and stores the result in a managed buffer

Callers 1

mainFunction · 0.45

Calls 6

copyInputToDeviceMethod · 0.80
executeV2Method · 0.80
copyOutputToHostMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected