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

Method prepare

samples/sampleDynamicReshape/sampleDynamicReshape.cpp:346–369  ·  view source on GitHub ↗

\brief Prepares the model for inference by creating an execution context and allocating buffers. \details This function sets up the sample for inference. This involves allocating buffers for the inputs and outputs, as well as creating TensorRT execution contexts for both engines. This only needs to be called a single time. \return false if error in build preprocessor or predict context.

Source from the content-addressed store, hash-verified

344//! \return false if error in build preprocessor or predict context.
345//!
346bool SampleDynamicReshape::prepare()
347{
348 mPreprocessorContext = makeUnique(mPreprocessorEngine->createExecutionContext());
349 if (!mPreprocessorContext)
350 {
351 sample::gLogError << "Preprocessor context build failed." << std::endl;
352 return false;
353 }
354
355
356 mPredictionContext = makeUnique(mPredictionEngine->createExecutionContext());
357 if (!mPredictionContext)
358 {
359 sample::gLogError << "Prediction context build failed." << std::endl;
360 return false;
361 }
362
363 // Since input dimensions are not known ahead of time, we only allocate the output buffer and preprocessor output
364 // buffer.
365 mPredictionInput.resize(mPredictionInputDims);
366 mOutput.hostBuffer.resize(mPredictionOutputDims);
367 mOutput.deviceBuffer.resize(mPredictionOutputDims);
368 return true;
369}
370
371//!
372//! \brief Runs inference for this sample

Callers 1

mainFunction · 0.45

Calls 2

resizeMethod · 0.45

Tested by

no test coverage detected