TensorRT  8.0.0
nvinfer1::IErrorRecorder Class Referenceabstract

Reference counted application-implemented error reporting interface for TensorRT objects. More...

#include <NvInferRuntimeCommon.h>

Public Types

using ErrorDesc = char const *
 
using RefCount = int32_t
 

Public Member Functions

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

Static Public Attributes

static constexpr size_t kMAX_DESC_LENGTH = 127U
 

Protected Member Functions

 IErrorRecorder (IErrorRecorder const &)=default
 
 IErrorRecorder (IErrorRecorder &&)=default
 
IErrorRecorderoperator= (IErrorRecorder const &) &=default
 
IErrorRecorderoperator= (IErrorRecorder &&) &=default
 

Detailed Description

Reference counted application-implemented error reporting interface for TensorRT objects.

The error reporting mechanism is a user defined object that interacts with the internal state of the object that it is assigned to in order to determine information about abnormalities in execution. The error recorder gets both an error enum that is more descriptive than pass/fail and also a string description that gives more detail on the exact failure modes. In the safety context, the error strings are all limited to 128 characters in length. The ErrorRecorder gets passed along to any class that is created from another class that has an ErrorRecorder assigned to it. For example, assigning an ErrorRecorder to an IBuilder allows all INetwork's, ILayer's, and ITensor's to use the same error recorder. For functions that have their own ErrorRecorder accessor functions. This allows registering a different error recorder or de-registering of the error recorder for that specific object.

The ErrorRecorder object implementation must be thread safe if the same ErrorRecorder is passed to different interface objects being executed in parallel in different threads. All locking and synchronization is pushed to the interface implementation and TensorRT does not hold any synchronization primitives when accessing the interface functions.

Member Typedef Documentation

◆ ErrorDesc

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

◆ RefCount

A typedef of a 32bit integer for reference counting.

Member Function Documentation

◆ clear()

virtual void nvinfer1::IErrorRecorder::clear ( )
pure virtualnoexcept

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

◆ decRefCount()

virtual RefCount nvinfer1::IErrorRecorder::decRefCount ( )
pure virtualnoexcept

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.

◆ getErrorCode()

virtual ErrorCode nvinfer1::IErrorRecorder::getErrorCode ( int32_t  errorIdx) const
pure virtualnoexcept

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

◆ getErrorDesc()

virtual ErrorDesc nvinfer1::IErrorRecorder::getErrorDesc ( int32_t  errorIdx) const
pure virtualnoexcept

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

◆ getNbErrors()

virtual int32_t nvinfer1::IErrorRecorder::getNbErrors ( ) const
pure virtualnoexcept

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

◆ hasOverflowed()

virtual bool nvinfer1::IErrorRecorder::hasOverflowed ( ) const
pure virtualnoexcept

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.

◆ incRefCount()

virtual RefCount nvinfer1::IErrorRecorder::incRefCount ( )
pure virtualnoexcept

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.

◆ reportError()

virtual bool nvinfer1::IErrorRecorder::reportError ( ErrorCode  val,
ErrorDesc  desc 
)
pure virtualnoexcept

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.

Member Data Documentation

◆ kMAX_DESC_LENGTH

constexpr size_t nvinfer1::IErrorRecorder::kMAX_DESC_LENGTH = 127U
staticconstexpr

The length limit for an error description, excluding the '\0' string terminator.


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