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
SampleMNISTAPI Class Reference

The SampleMNISTAPI class implements the MNIST API sample. More...

Collaboration diagram for SampleMNISTAPI:

Public Member Functions

 SampleMNISTAPI (const SampleMNISTAPIParams &params)
 
bool build ()
 Function builds the network engine. More...
 
bool infer ()
 Runs the TensorRT inference engine for this sample. More...
 
bool teardown ()
 Cleans 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< nvinfer1::IBuilder > &builder, SampleUniquePtr< nvinfer1::INetworkDefinition > &network, SampleUniquePtr< nvinfer1::IBuilderConfig > &config)
 Uses the API to create the MNIST Network. More...
 
bool processInput (const samplesCommon::BufferManager &buffers)
 Reads the input and stores the result in a managed buffer. More...
 
bool verifyOutput (const samplesCommon::BufferManager &buffers)
 Classifies digits and verify result. More...
 
std::map< std::string, nvinfer1::WeightsloadWeights (const std::string &file)
 Loads weights from weights file. More...
 

Private Attributes

SampleMNISTAPIParams mParams
 The parameters for the sample. More...
 
int mNumber {0}
 The number to classify. More...
 
std::map< std::string, nvinfer1::WeightsmWeightMap
 The weight name to weight value map. More...
 
std::vector< SampleUniquePtr< nvinfer1::IHostMemory > > weightsMemory
 Host weights memory holder. More...
 
std::shared_ptr< nvinfer1::ICudaEnginemEngine
 The TensorRT engine used to run the network. More...
 

Detailed Description

The SampleMNISTAPI class implements the MNIST API sample.

It creates the network for MNIST classification using the API

Member Typedef Documentation

◆ SampleUniquePtr

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

Constructor & Destructor Documentation

◆ SampleMNISTAPI()

SampleMNISTAPI::SampleMNISTAPI ( const SampleMNISTAPIParams params)
inline

Member Function Documentation

◆ build()

bool SampleMNISTAPI::build ( )

Function builds the network engine.

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

This function creates the MNIST network by using the API to create a 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 SampleMNISTAPI::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 and executes the engine.

Here is the call graph for this function:

◆ teardown()

bool SampleMNISTAPI::teardown ( )

Cleans up any state created in the sample class.

◆ constructNetwork()

bool SampleMNISTAPI::constructNetwork ( SampleUniquePtr< nvinfer1::IBuilder > &  builder,
SampleUniquePtr< nvinfer1::INetworkDefinition > &  network,
SampleUniquePtr< nvinfer1::IBuilderConfig > &  config 
)
private

Uses the API to create the MNIST Network.

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 SampleMNISTAPI::processInput ( const samplesCommon::BufferManager buffers)
private

Reads the input 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 SampleMNISTAPI::verifyOutput ( const samplesCommon::BufferManager buffers)
private

Classifies digits and verify result.

Returns
whether the classification output matches expectations
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadWeights()

std::map< std::string, nvinfer1::Weights > SampleMNISTAPI::loadWeights ( const std::string &  file)
private

Loads weights from weights file.

TensorRT weight files have a simple space delimited format [type] [size] <data x size in hex>

Here is the caller graph for this function:

Member Data Documentation

◆ mParams

SampleMNISTAPIParams SampleMNISTAPI::mParams
private

The parameters for the sample.

◆ mNumber

int SampleMNISTAPI::mNumber {0}
private

The number to classify.

◆ mWeightMap

std::map<std::string, nvinfer1::Weights> SampleMNISTAPI::mWeightMap
private

The weight name to weight value map.

◆ weightsMemory

std::vector<SampleUniquePtr<nvinfer1::IHostMemory> > SampleMNISTAPI::weightsMemory
private

Host weights memory holder.

◆ mEngine

std::shared_ptr<nvinfer1::ICudaEngine> SampleMNISTAPI::mEngine
private

The TensorRT engine used to run the network.


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