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

The SampleMovieLens class implements the MovieLens sample. More...

Collaboration diagram for SampleMovieLens:

Public Member Functions

 SampleMovieLens (const SampleMovieLensParams &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

void constructNetwork (SampleUniquePtr< nvinfer1::IBuilder > &builder, SampleUniquePtr< nvinfer1::INetworkDefinition > &network, SampleUniquePtr< nvinfer1::IBuilderConfig > &config, SampleUniquePtr< nvuffparser::IUffParser > &parser)
 Parses a Uff model for a MLP NCF model, creates a TensorRT network, and builds a TensorRT engine. More...
 
bool processInput (const samplesCommon::BufferManager &buffers)
 Copies a batch of input data from SampleMovieLensParams into managed input buffers. More...
 
std::string readNextLine (std::ifstream &file, char delim)
 Helper function to read the next line of the MovieLens dataset .csv file and return the contents of the line after the delimeter. More...
 
void readInputSample (std::ifstream &file, OutputParams &outParams, std::string line)
 Extracts needed dataset values for a single user in the MovieLens, dataset .csv file, and populates the corresponding ground truth data struct. More...
 
void parseMovieLensData ()
 Parses the MovieLens dataset and populates the SampleMovieLensParams data structure. More...
 
void printOutputParams (OutputParams &outParams)
 Prints the expected recommendation results (ground truth) from the MovieLens dataset for a given user. More...
 
bool verifyOutput (uint32_t *userInputPtr, uint32_t *, uint32_t *topKItemNumberPtr, float *topKItemProbPtr)
 Verifies the inference output with ground truth and logs the results. More...
 

Private Attributes

SampleMovieLensParams mParams
 
std::shared_ptr< nvinfer1::ICudaEnginemEngine {nullptr}
 The TensorRT engine used to run the network. More...
 

Detailed Description

The SampleMovieLens class implements the MovieLens sample.

It creates the network using a uff model

Member Typedef Documentation

◆ SampleUniquePtr

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

Constructor & Destructor Documentation

◆ SampleMovieLens()

SampleMovieLens::SampleMovieLens ( const SampleMovieLensParams params)
inline

Member Function Documentation

◆ build()

bool SampleMovieLens::build ( )

Builds the network engine.

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

This function creates the MLP NCF network by parsing the Uff model and builds the engine that will be used to generate recommendations (mEngine)

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

◆ infer()

bool SampleMovieLens::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 SampleMovieLens::teardown ( )

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

Here is the call graph for this function:

◆ constructNetwork()

void SampleMovieLens::constructNetwork ( SampleUniquePtr< nvinfer1::IBuilder > &  builder,
SampleUniquePtr< nvinfer1::INetworkDefinition > &  network,
SampleUniquePtr< nvinfer1::IBuilderConfig > &  config,
SampleUniquePtr< nvuffparser::IUffParser > &  parser 
)
private

Parses a Uff model for a MLP NCF model, creates a TensorRT network, and builds a TensorRT engine.

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

◆ processInput()

bool SampleMovieLens::processInput ( const samplesCommon::BufferManager buffers)
private

Copies a batch of input data from SampleMovieLensParams into managed input buffers.

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

◆ readNextLine()

std::string SampleMovieLens::readNextLine ( std::ifstream &  file,
char  delim 
)
private

Helper function to read the next line of the MovieLens dataset .csv file and return the contents of the line after the delimeter.

This function is called from SampleMovieLens::readInputSample() to extract the needed values per user.

Here is the caller graph for this function:

◆ readInputSample()

void SampleMovieLens::readInputSample ( std::ifstream &  file,
OutputParams outParams,
std::string  line 
)
private

Extracts needed dataset values for a single user in the MovieLens, dataset .csv file, and populates the corresponding ground truth data struct.

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

◆ parseMovieLensData()

void SampleMovieLens::parseMovieLensData ( )
private

Parses the MovieLens dataset and populates the SampleMovieLensParams data structure.

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

◆ printOutputParams()

void SampleMovieLens::printOutputParams ( OutputParams outParams)
private

Prints the expected recommendation results (ground truth) from the MovieLens dataset for a given user.

Here is the caller graph for this function:

◆ verifyOutput()

bool SampleMovieLens::verifyOutput ( uint32_t *  userInputPtr,
uint32_t *  ,
uint32_t *  topKItemNumberPtr,
float *  topKItemProbPtr 
)
private

Verifies the inference output with ground truth and logs the results.

Compares the inference output with ground truth and logs the results.

Here is the caller graph for this function:

Member Data Documentation

◆ mParams

SampleMovieLensParams SampleMovieLens::mParams
private

◆ mEngine

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

The TensorRT engine used to run the network.


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