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

A simple imeplementation of the IErrorRecorder interface for use by samples. More...

Inheritance diagram for SampleErrorRecorder:
Collaboration diagram for SampleErrorRecorder:

Public Types

using ErrorDesc = const char *
 A typedef of a c-style string for reporting error descriptions. More...
 
using RefCount = int32_t
 A typedef of a 32bit integer for reference counting. More...
 

Public Member Functions

 SampleErrorRecorder ()=default
 
virtual ~SampleErrorRecorder () noexcept
 
int32_t getNbErrors () const noexcept final
 Return the number of errors. More...
 
ErrorCode getErrorCode (int32_t errorIdx) const noexcept final
 Returns the ErrorCode enumeration. More...
 
IErrorRecorder::ErrorDesc getErrorDesc (int32_t errorIdx) const noexcept final
 Returns the c-style string description of the error. More...
 
bool hasOverflowed () const noexcept final
 Determine if the error stack has overflowed. More...
 
void clear () noexcept final
 Clear the error stack on the error recorder. More...
 
bool empty () const noexcept
 Simple helper function that. More...
 
bool reportError (ErrorCode val, IErrorRecorder::ErrorDesc desc) noexcept final
 report an error to the error recorder with the corresponding enum and description. More...
 
IErrorRecorder::RefCount incRefCount () noexcept final
 Increments the refcount for the current ErrorRecorder. More...
 
IErrorRecorder::RefCount decRefCount () noexcept final
 Decrements the refcount for the current ErrorRecorder. More...
 

Private Types

using errorPair = std::pair< ErrorCode, std::string >
 
using errorStack = std::vector< errorPair >
 

Private Member Functions

const errorPairoperator[] (size_t index) const noexcept
 
bool indexCheck (int32_t index) const noexcept
 

Private Attributes

std::mutex mStackLock
 
std::atomic< int32_t > mRefCount {0}
 
errorStack mErrorStack
 

Detailed Description

A simple imeplementation of the IErrorRecorder interface for use by samples.

This interface also can be used as a reference implementation. The sample Error recorder is based on a vector that pairs the error code and the error string into a single element. It also uses standard mutex's and atomics in order to make sure that the code works in a multi-threaded environment. SampleErrorRecorder is not intended for use in automotive safety environments.

Member Typedef Documentation

◆ errorPair

using SampleErrorRecorder::errorPair = std::pair<ErrorCode, std::string>
private

◆ errorStack

using SampleErrorRecorder::errorStack = std::vector<errorPair>
private

◆ ErrorDesc

using nvinfer1::IErrorRecorder::ErrorDesc = const char*
inherited

A typedef of a c-style string for reporting error descriptions.

◆ RefCount

using nvinfer1::IErrorRecorder::RefCount = int32_t
inherited

A typedef of a 32bit integer for reference counting.

Constructor & Destructor Documentation

◆ SampleErrorRecorder()

SampleErrorRecorder::SampleErrorRecorder ( )
default

◆ ~SampleErrorRecorder()

virtual SampleErrorRecorder::~SampleErrorRecorder ( )
inlinevirtualnoexcept

Member Function Documentation

◆ getNbErrors()

int32_t SampleErrorRecorder::getNbErrors ( ) const
inlinefinalvirtualnoexcept

Return the number of errors.

Determines the number of errors that occurred between the current point in execution and the last time that the clear() was executed. Due to the possibility of asynchronous errors occuring, a TensorRT API can return correct results, but still register errors with the Error Recorder. The value of getNbErrors must monotonically increases until clear() is called.

Returns
Returns the number of errors detected, or 0 if there are no errors.
See also
clear

Implements nvinfer1::IErrorRecorder.

◆ getErrorCode()

ErrorCode SampleErrorRecorder::getErrorCode ( int32_t  errorIdx) const
inlinefinalvirtualnoexcept

Returns the ErrorCode enumeration.

Parameters
errorIdxA 32bit integer that indexes into the error array.

The errorIdx specifies what error code from 0 to getNbErrors()-1 that the application wants to analyze and return the error code enum.

Returns
Returns the enum corresponding to errorIdx.
See also
getErrorDesc, ErrorCode

Implements nvinfer1::IErrorRecorder.

◆ getErrorDesc()

IErrorRecorder::ErrorDesc SampleErrorRecorder::getErrorDesc ( int32_t  errorIdx) const
inlinefinalvirtualnoexcept

Returns the c-style string description of the error.

Parameters
errorIdxA 32bit integer that indexes into the error array.

For the error specified by the idx value, return the string description of the error. The error string is a c-style string that is zero delimited. In the safety context there is a constant length requirement to remove any dynamic memory allocations and the error message may be truncated. The format of the string is "<EnumAsStr> - <Description>".

Returns
Returns a string representation of the error along with a description of the error.
See also
getErrorCode

Implements nvinfer1::IErrorRecorder.

◆ hasOverflowed()

bool SampleErrorRecorder::hasOverflowed ( ) const
inlinefinalvirtualnoexcept

Determine if the error stack has overflowed.

In the case when the number of errors is large, this function is used to query if one or more errors have been dropped due to lack of storage capacity. This is especially important in the automotive safety case where the internal error handling mechanisms cannot allocate memory.

Returns
true if errors have been dropped due to overflowing the error stack.

Implements nvinfer1::IErrorRecorder.

◆ clear()

void SampleErrorRecorder::clear ( )
inlinefinalvirtualnoexcept

Clear the error stack on the error recorder.

Removes all the tracked errors by the error recorder. This function must guarantee that after this function is called, and as long as no error occurs, the next call to getNbErrors will return zero.

See also
getNbErrors

Implements nvinfer1::IErrorRecorder.

Here is the call graph for this function:

◆ empty()

bool SampleErrorRecorder::empty ( ) const
inlinenoexcept

Simple helper function that.

◆ reportError()

bool SampleErrorRecorder::reportError ( ErrorCode  val,
IErrorRecorder::ErrorDesc  desc 
)
inlinefinalvirtualnoexcept

report an error to the error recorder with the corresponding enum and description.

Parameters
valThe error code enum that is being reported.
descThe string description of the error.

Report an error to the user that has a given value and human readable description. The function returns false if processing can continue, which implies that the reported error is not fatal. This does not guarantee that processing continues, but provides a hint to TensorRT.

Returns
True if the error is determined to be fatal and processing of the current function must end.

Implements nvinfer1::IErrorRecorder.

Here is the call graph for this function:

◆ incRefCount()

IErrorRecorder::RefCount SampleErrorRecorder::incRefCount ( )
inlinefinalvirtualnoexcept

Increments the refcount for the current ErrorRecorder.

Increments the reference count for the object by one and returns the current value. This reference count allows the application to know that an object inside of TensorRT has taken a reference to the ErrorRecorder. If the ErrorRecorder is released before the reference count hits zero, then behavior in TensorRT is undefined. It is strongly recommended that the increment is an atomic operation. TensorRT guarantees that each incRefCount called on an objects construction is paired with a decRefCount call when an object is destructed.

Returns
The current reference counted value.

Implements nvinfer1::IErrorRecorder.

◆ decRefCount()

IErrorRecorder::RefCount SampleErrorRecorder::decRefCount ( )
inlinefinalvirtualnoexcept

Decrements the refcount for the current ErrorRecorder.

Decrements the reference count for the object by one and returns the current value. It is undefined behavior to call decRefCount when RefCount is zero. If the ErrorRecorder is destroyed before the reference count hits zero, then behavior in TensorRT is undefined. It is strongly recommended that the decrement is an atomic operation. TensorRT guarantees that each decRefCount called when an object is destructed is paired with a incRefCount call when that object was constructed.

Returns
The current reference counted value.

Implements nvinfer1::IErrorRecorder.

◆ operator[]()

const errorPair& SampleErrorRecorder::operator[] ( size_t  index) const
inlineprivatenoexcept

◆ indexCheck()

bool SampleErrorRecorder::indexCheck ( int32_t  index) const
inlineprivatenoexcept

Member Data Documentation

◆ mStackLock

std::mutex SampleErrorRecorder::mStackLock
private

◆ mRefCount

std::atomic<int32_t> SampleErrorRecorder::mRefCount {0}
private

◆ mErrorStack

errorStack SampleErrorRecorder::mErrorStack
private

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