TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
SampleMNIST Class Reference

The SampleMNIST class implements the MNIST sample. More...

Collaboration diagram for SampleMNIST:

Public Member Functions

 SampleMNIST (const samplesCommon::CaffeSampleParams &params)
 
bool build ()
 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 SampleMNIST class implements the MNIST sample.

It creates the network using a trained Caffe MNIST classification model

Member Typedef Documentation

◆ SampleUniquePtr

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

Constructor & Destructor Documentation

◆ SampleMNIST()

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

Member Function Documentation

◆ build()

bool SampleMNIST::build ( )

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 SampleMNIST::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 SampleMNIST::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 SampleMNIST::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 SampleMNIST::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 SampleMNIST::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> SampleMNIST::mEngine {nullptr}
private

The TensorRT engine used to run the network.

◆ mParams

samplesCommon::CaffeSampleParams SampleMNIST::mParams
private

The parameters for the sample.

◆ mInputDims

nvinfer1::Dims SampleMNIST::mInputDims
private

The dimensions of the input to the network.

◆ mMeanBlob

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

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