The SampleMNISTAPI class implements the MNIST API sample. More...
Public Member Functions | |
SampleMNISTAPI (const SampleMNISTAPIParams ¶ms) | |
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::Weights > | loadWeights (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::Weights > | mWeightMap |
The weight name to weight value map. More... | |
std::vector< SampleUniquePtr< nvinfer1::IHostMemory > > | weightsMemory |
Host weights memory holder. More... | |
std::shared_ptr< nvinfer1::ICudaEngine > | mEngine |
The TensorRT engine used to run the network. More... | |
The SampleMNISTAPI class implements the MNIST API sample.
It creates the network for MNIST classification using the API
|
private |
|
inline |
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)
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.
bool SampleMNISTAPI::teardown | ( | ) |
Cleans up any state created in the sample class.
|
private |
Uses the API to create the MNIST Network.
network | Pointer to the network that will be populated with the MNIST network |
builder | Pointer to the engine builder |
|
private |
Reads the input and stores the result in a managed buffer.
|
private |
Classifies digits and verify result.
|
private |
Loads weights from weights file.
TensorRT weight files have a simple space delimited format [type] [size] <data x size in hex>
|
private |
The parameters for the sample.
|
private |
The number to classify.
|
private |
The weight name to weight value map.
|
private |
Host weights memory holder.
|
private |
The TensorRT engine used to run the network.