\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.
| 247 | //! sets inputs and executes the engine. |
| 248 | //! |
| 249 | bool 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 |
no test coverage detected