TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
SampleAlgorithmSelector Class Reference

The SampleAlgorithmSelector class implements the SampleAlgorithmSelector sample. More...

Collaboration diagram for SampleAlgorithmSelector:

Public Member Functions

 SampleAlgorithmSelector (const samplesCommon::CaffeSampleParams &params)
 
bool build (IAlgorithmSelector *selector)
 Builds the network engine. More...
 
bool infer ()
 Runs the TensorRT inference engine for this sample. More...
 
bool teardown ()
 Used to clean up any state created in the sample class. More...
 

Private Types

template<typename T >
using SampleUniquePtr = std::unique_ptr< T, samplesCommon::InferDeleter >
 

Private Member Functions

bool constructNetwork (SampleUniquePtr< nvcaffeparser1::ICaffeParser > &parser, SampleUniquePtr< nvinfer1::INetworkDefinition > &network)
 uses a Caffe parser to create the MNIST Network and marks the output layers. More...
 
bool processInput (const samplesCommon::BufferManager &buffers, const std::string &inputTensorName, int inputFileIdx) const
 Reads the input and mean data, preprocesses, and stores the result in a managed buffer. More...
 
bool verifyOutput (const samplesCommon::BufferManager &buffers, const std::string &outputTensorName, int groundTruthDigit) const
 Verifies that the output is correct and prints it. More...
 

Private Attributes

std::shared_ptr< nvinfer1::ICudaEnginemEngine {nullptr}
 The TensorRT engine used to run the network. More...
 
samplesCommon::CaffeSampleParams mParams
 The parameters for the sample. More...
 
nvinfer1::Dims mInputDims
 The dimensions of the input to the network. More...
 
SampleUniquePtr< nvcaffeparser1::IBinaryProtoBlobmMeanBlob
 

Detailed Description

The SampleAlgorithmSelector class implements the SampleAlgorithmSelector sample.

It creates the network using a trained Caffe MNIST classification model.

Member Typedef Documentation

◆ SampleUniquePtr

template<typename T >
using SampleAlgorithmSelector::SampleUniquePtr = std::unique_ptr<T, samplesCommon::InferDeleter>
private

Constructor & Destructor Documentation

◆ SampleAlgorithmSelector()

SampleAlgorithmSelector::SampleAlgorithmSelector ( const samplesCommon::CaffeSampleParams params)
inline

Member Function Documentation

◆ build()

bool SampleAlgorithmSelector::build ( IAlgorithmSelector selector)

Builds the network engine.

Creates the network, configures the builder and creates the network engine.

This function creates the MNIST network by parsing the caffe model and builds the engine that will be used to run MNIST (mEngine).

Returns
Returns true if the engine was created successfully and false otherwise.
Here is the call graph for this function:

◆ infer()

bool SampleAlgorithmSelector::infer ( )

Runs the TensorRT inference engine for this sample.

This function is the main execution function of the sample. It allocates the buffer, sets inputs, executes the engine, and verifies the output.

Here is the call graph for this function:

◆ teardown()

bool SampleAlgorithmSelector::teardown ( )

Used to clean up any state created in the sample class.

Clean up the libprotobuf files as the parsing is complete.

Note
It is not safe to use any other part of the protocol buffers library after ShutdownProtobufLibrary() has been called.
Here is the call graph for this function:

◆ constructNetwork()

bool SampleAlgorithmSelector::constructNetwork ( SampleUniquePtr< nvcaffeparser1::ICaffeParser > &  parser,
SampleUniquePtr< nvinfer1::INetworkDefinition > &  network 
)
private

uses a Caffe parser to create the MNIST Network and marks the output layers.

Uses a caffe parser to create the MNIST Network and marks the output layers.

Parameters
networkPointer to the network that will be populated with the MNIST network.
builderPointer to the engine builder.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processInput()

bool SampleAlgorithmSelector::processInput ( const samplesCommon::BufferManager buffers,
const std::string &  inputTensorName,
int  inputFileIdx 
) const
private

Reads the input and mean data, preprocesses, and stores the result in a managed buffer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyOutput()

bool SampleAlgorithmSelector::verifyOutput ( const samplesCommon::BufferManager buffers,
const std::string &  outputTensorName,
int  groundTruthDigit 
) const
private

Verifies that the output is correct and prints it.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mEngine

std::shared_ptr<nvinfer1::ICudaEngine> SampleAlgorithmSelector::mEngine {nullptr}
private

The TensorRT engine used to run the network.

◆ mParams

samplesCommon::CaffeSampleParams SampleAlgorithmSelector::mParams
private

The parameters for the sample.

◆ mInputDims

nvinfer1::Dims SampleAlgorithmSelector::mInputDims
private

The dimensions of the input to the network.

◆ mMeanBlob

SampleUniquePtr<nvcaffeparser1::IBinaryProtoBlob> SampleAlgorithmSelector::mMeanBlob
private

The documentation for this class was generated from the following file: