TensorRT 11.2.1
nvinfer2::safe::IPluginV3OneSafeBuild Class Referenceabstract

Interface for plugins used during the TensorRT build phase. More...

#include <NvInferSafePlugin.h>

Inheritance diagram for nvinfer2::safe::IPluginV3OneSafeBuild:
nvinfer1::v_1_0::IPluginCapability nvinfer1::IVersionedInterface nvinfer2::safe::IPluginV3OneSafeBuildMSS

Public Member Functions

InterfaceInfo getInterfaceInfo () const noexcept override
 Returns version information associated with this interface. More...
 
 IPluginV3OneSafeBuild ()=default
 Default constructor. More...
 
 IPluginV3OneSafeBuild (IPluginV3OneSafeBuild &&)=delete
 Deleted move constructor to maintain non-movability. More...
 
IPluginV3OneSafeBuildoperator= (IPluginV3OneSafeBuild &&) &=delete
 Deleted move assignment operator to maintain non-movability. More...
 
 ~IPluginV3OneSafeBuild () noexcept override=default
 Destructor for IPluginV3OneSafeBuild. More...
 
virtual int32_t configurePlugin (TensorDescriptor const *in, int32_t nbInputs, TensorDescriptor const *out, int32_t nbOutputs) noexcept=0
 Configure the plugin. More...
 
virtual int32_t getOutputDataTypes (DataType *outputTypes, int32_t nbOutputs, DataType const *inputTypes, int32_t nbInputs) const noexcept=0
 Provide the data types of the plugin outputs if the input tensors have the data types provided. More...
 
virtual int32_t getOutputShapes (Dims const *inputs, int32_t nbInputs, Dims *outputs, int32_t nbOutputs) const noexcept=0
 Provide expressions for computing dimensions of the output tensors from dimensions of the input tensors. More...
 
virtual bool supportsFormatCombination (int32_t pos, TensorDescriptor const *inOut, int32_t nbInputs, int32_t nbOutputs) noexcept=0
 Return true if plugin supports the format and datatype for the input/output indexed by pos. More...
 
virtual int32_t getNbOutputs () const noexcept=0
 Get the number of outputs from the plugin. More...
 
virtual size_t getWorkspaceSize (TensorDescriptor const *, int32_t, TensorDescriptor const *, int32_t) const noexcept
 Find the workspace size required by the layer. More...
 
virtual int32_t getValidTactics (int32_t *, int32_t) noexcept
 Query for any custom tactics that the plugin intends to use. More...
 
virtual int32_t getNbTactics () noexcept
 Query for the number of custom tactics the plugin intends to use. More...
 
virtual char const * getTimingCacheID () noexcept
 Called to query the suffix to use for the timing cache ID. May be called anytime after plugin creation. More...
 
virtual int32_t getFormatCombinationLimit () noexcept
 Return the maximum number of format combinations that will be timed by TensorRT during the build phase. More...
 
virtual char const * getMetadataString () noexcept
 Query for a string representing the configuration of the plugin. May be called anytime after plugin creation. More...
 
- Public Member Functions inherited from nvinfer1::IVersionedInterface
virtual APILanguage getAPILanguage () const noexcept
 The language used to build the implementation of this Interface. More...
 
virtual ~IVersionedInterface () noexcept=default
 

Static Public Attributes

static constexpr int32_t kDEFAULT_FORMAT_COMBINATION_LIMIT = 100
 Default maximum number of format combinations timed by TensorRT during the build phase. More...
 

Protected Member Functions

 IPluginV3OneSafeBuild (IPluginV3OneSafeBuild const &)=default
 
IPluginV3OneSafeBuildoperator= (IPluginV3OneSafeBuild const &) &=default
 
- Protected Member Functions inherited from nvinfer1::IVersionedInterface
 IVersionedInterface ()=default
 
 IVersionedInterface (IVersionedInterface const &)=default
 
 IVersionedInterface (IVersionedInterface &&)=default
 
IVersionedInterfaceoperator= (IVersionedInterface const &) &=default
 
IVersionedInterfaceoperator= (IVersionedInterface &&) &=default
 

Detailed Description

Interface for plugins used during the TensorRT build phase.

Extends IPluginCapability to provide build-phase plugin behavior; used when creating an engine by IBuilder. Supports configuration and format combination limits.

Constructor & Destructor Documentation

◆ IPluginV3OneSafeBuild() [1/3]

nvinfer2::safe::IPluginV3OneSafeBuild::IPluginV3OneSafeBuild ( )
default

Default constructor.

Precondition
none
Postcondition
Object is in default-constructed state.

◆ IPluginV3OneSafeBuild() [2/3]

nvinfer2::safe::IPluginV3OneSafeBuild::IPluginV3OneSafeBuild ( IPluginV3OneSafeBuild &&  )
delete

Deleted move constructor to maintain non-movability.

Precondition
none
Postcondition
none

◆ ~IPluginV3OneSafeBuild()

nvinfer2::safe::IPluginV3OneSafeBuild::~IPluginV3OneSafeBuild ( )
overridedefaultnoexcept

Destructor for IPluginV3OneSafeBuild.

Precondition
none
Postcondition
none

◆ IPluginV3OneSafeBuild() [3/3]

nvinfer2::safe::IPluginV3OneSafeBuild::IPluginV3OneSafeBuild ( IPluginV3OneSafeBuild const &  )
protecteddefault

Member Function Documentation

◆ configurePlugin()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::configurePlugin ( TensorDescriptor const *  in,
int32_t  nbInputs,
TensorDescriptor const *  out,
int32_t  nbOutputs 
)
pure virtualnoexcept

Configure the plugin.

configurePlugin() can be called multiple times in the build phase during creation of an engine by IBuilder.

configurePlugin() is called when a plugin is being prepared for profiling but not for any specific input size. This provides an opportunity for the plugin to make algorithmic choices on the basis of input and output formats, along with the bound of possible dimensions. The min, opt and max value of the TensorDescriptor correspond to the kMIN, kOPT and kMAX value of the current profile that the plugin is being profiled for, with the desc.dims field corresponding to the dimensions of plugin specified at network creation. Wildcard dimensions may exist during this phase in the desc.dims field.

Parameters
inThe input tensors attributes that are used for configuration.
nbInputsNumber of input tensors.
outThe output tensors attributes that are used for configuration.
nbOutputsNumber of output tensors.

◆ getFormatCombinationLimit()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::getFormatCombinationLimit ( )
inlinevirtualnoexcept

Return the maximum number of format combinations that will be timed by TensorRT during the build phase.

◆ getInterfaceInfo()

InterfaceInfo nvinfer2::safe::IPluginV3OneSafeBuild::getInterfaceInfo ( ) const
inlineoverridevirtualnoexcept

Returns version information associated with this interface.

Applications must not override this method.

Precondition
none
Postcondition
none
Returns
InterfaceInfo with kind "PLUGIN_V3ONE_SAFE_BUILD", major 1, minor 0.

Implements nvinfer1::IVersionedInterface.

Reimplemented in nvinfer2::safe::IPluginV3OneSafeBuildMSS.

◆ getMetadataString()

virtual char const * nvinfer2::safe::IPluginV3OneSafeBuild::getMetadataString ( )
inlinevirtualnoexcept

Query for a string representing the configuration of the plugin. May be called anytime after plugin creation.

Returns
A string representing the plugin's creation state, especially with regard to its attribute values.

◆ getNbOutputs()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::getNbOutputs ( ) const
pure virtualnoexcept

Get the number of outputs from the plugin.

Returns
The number of outputs, which must be a positive integer.

◆ getNbTactics()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::getNbTactics ( )
inlinevirtualnoexcept

Query for the number of custom tactics the plugin intends to use.

◆ getOutputDataTypes()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::getOutputDataTypes ( DataType outputTypes,
int32_t  nbOutputs,
DataType const *  inputTypes,
int32_t  nbInputs 
) const
pure virtualnoexcept

Provide the data types of the plugin outputs if the input tensors have the data types provided.

Parameters
outputTypesPre-allocated array to which the output data types should be written.
nbOutputsThe number of output tensors. This matches the value returned from getNbOutputs().
inputTypesThe input data types.
nbInputsThe number of input tensors.
Returns
0 for success, else non-zero (which will cause engine termination). The returned code will be reported through the error recorder.
Note
Provide DataType::kFLOATs if the layer has no inputs. The data type for any size tensor outputs must be DataType::kINT32. The returned data types must each have a format that is supported by the plugin.
Warning
DataType:kBOOL and DataType::kUINT8 are not supported.

◆ getOutputShapes()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::getOutputShapes ( Dims const *  inputs,
int32_t  nbInputs,
Dims outputs,
int32_t  nbOutputs 
) const
pure virtualnoexcept

Provide expressions for computing dimensions of the output tensors from dimensions of the input tensors.

Parameters
inputsExpressions for dimensions of the input tensors
nbInputsThe number of input tensors
shapeInputsExpressions for values of the shape tensor inputs
nbShapeInputsThe number of shape tensor inputs
outputsPre-allocated array to which the output dimensions must be written
exprBuilderObject for generating new dimension expressions
Note
Any size tensor outputs must be declared to be 0-D.
The declaration of shapeInputs as DimsExprs is slightly abusive, because the "dimensions" are actually the values of the shape tensor. For example, if the input shape tensor is a 2x3 matrix, the DimsExprs will have six "dimensions": the three values from the first row of the matrix followed by the three values from the second row of the matrix.
Returns
0 for success, else non-zero (which will cause engine termination). Returned code will be reported through the error recorder.

Implemented in nvinfer2::safe::IPluginV3OneSafeBuildMSS.

◆ getTimingCacheID()

virtual char const * nvinfer2::safe::IPluginV3OneSafeBuild::getTimingCacheID ( )
inlinevirtualnoexcept

Called to query the suffix to use for the timing cache ID. May be called anytime after plugin creation.

Returns
Suffix to use for timing cache ID, considering only the creation state of the plugin. Returning nullptr will disable timing caching for the plugin altogether.
Note
If timing caching is enabled for the plugin (by returning non-null), the I/O shape and format information will be automatically considered to form the prefix of the timing cache ID. Therefore, only other factors determining the creation state of the plugin, such as its attribute values, should be considered to compose the return value.

◆ getValidTactics()

virtual int32_t nvinfer2::safe::IPluginV3OneSafeBuild::getValidTactics ( int32_t *  ,
int32_t   
)
inlinevirtualnoexcept

Query for any custom tactics that the plugin intends to use.

This method queries for the set of tactics T(f) supported by the plugin for the format combination f indicated by the immediately preceding call to configurePlugin(). It is guaranteed to be called after configurePlugin().

For each format combination provided through configurePlugin(), up to a maximum of getFormatCombinationLimit(), the plugin will be timed for each tactic advertised through this method for that format combination. i.e. The plugin will be timed $N = sum_{i=0}^{i<getFormatCombinationLimit()} (T(f[i]))$ times. If $N = 1$, the plugin may not be timed. In peudocode, the timing protocol appears as the following:

counter = 0 for each supported format combination ++counter if counter > getFormatCombinationLimit() goto done configurePlugin(...) for each tactic in getValidTactics(...) time tactic done:

Parameters
tacticsPre-allocated buffer to which the tactic values should be written
nbTacticsThe number of tactics advertised through getNbTactics()
Note
The provided tactic values must be unique and non-zero. The tactic value 0 is reserved for the default tactic attached to each format combination.
Returns
0 for success, else non-zero (which will cause engine termination). The returned code will be reported through the error recorder.

◆ getWorkspaceSize()

virtual size_t nvinfer2::safe::IPluginV3OneSafeBuild::getWorkspaceSize ( TensorDescriptor const *  ,
int32_t  ,
TensorDescriptor const *  ,
int32_t   
) const
inlinevirtualnoexcept

Find the workspace size required by the layer.

This function is called after the plugin is configured, and possibly during execution. The result should be a sufficient workspace size to deal with inputs and outputs of the given size or any smaller problem.

Returns
The workspace size.

◆ operator=() [1/2]

IPluginV3OneSafeBuild & nvinfer2::safe::IPluginV3OneSafeBuild::operator= ( IPluginV3OneSafeBuild &&  ) &
delete

Deleted move assignment operator to maintain non-movability.

Precondition
none
Postcondition
none

◆ operator=() [2/2]

IPluginV3OneSafeBuild & nvinfer2::safe::IPluginV3OneSafeBuild::operator= ( IPluginV3OneSafeBuild const &  ) &
protecteddefault

◆ supportsFormatCombination()

virtual bool nvinfer2::safe::IPluginV3OneSafeBuild::supportsFormatCombination ( int32_t  pos,
TensorDescriptor const *  inOut,
int32_t  nbInputs,
int32_t  nbOutputs 
)
pure virtualnoexcept

Return true if plugin supports the format and datatype for the input/output indexed by pos.

For this method inputs are numbered 0.. (nbInputs - 1) and outputs are numbered nbInputs.. (nbInputs + nbOutputs

  • 1). Using this numbering, pos is an index into InOut, where 0 <= pos < nbInputs + nbOutputs - 1.

TensorRT invokes this method to ask if the input/output indexed by pos supports the format/datatype specified by inOut[pos].format and inOut[pos].type. The override should return true if that format/datatype at inOut[pos] are supported by the plugin. If support is conditional on other input/output formats/datatypes, the plugin can make its result conditional on the formats/datatypes in inOut[0.. pos - 1], which will be set to values that the plugin supports. The override should not inspect inOut[pos1.. nbInputs + nbOutputs - 1], which will have invalid values. In other words, the decision for pos must be based on inOut[0..pos] only.

Some examples:

  • A definition for a plugin that supports only FP16 NCHW:
      return inOut.format[pos] == TensorFormat::kLINEAR && inOut.type[pos] == DataType::kHALF;
    
  • A definition for a plugin that supports only FP16 NCHW for its two inputs, and FP32 NCHW for its single output:
      return inOut.format[pos] == TensorFormat::kLINEAR && (inOut.type[pos] == pos < 2 ?  DataType::kHALF :
      DataType::kFLOAT);
    
  • A definition for a "polymorphic" plugin with two inputs and one output that supports any format or type, but the inputs and output must have the same format and type:
      return pos == 0 || (inOut.format[pos] == inOut.format[0] && inOut.type[pos] == inOut.type[0]);
    
    Warning
    TensorRT will stop querying once it finds getFormatCombinationLimit() of combinations.
    See also
    getFormatCombinationLimit

Member Data Documentation

◆ kDEFAULT_FORMAT_COMBINATION_LIMIT

constexpr int32_t nvinfer2::safe::IPluginV3OneSafeBuild::kDEFAULT_FORMAT_COMBINATION_LIMIT = 100
staticconstexpr

Default maximum number of format combinations timed by TensorRT during the build phase.

See also
getFormatCombinationLimit

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

  Copyright © 2024 NVIDIA Corporation
  Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact