TensorRT 10.5.0
nvinfer1::IPluginV2IOExt Class Referenceabstract

Plugin class for user-implemented layers. More...

#include <NvInferRuntimePlugin.h>

Inheritance diagram for nvinfer1::IPluginV2IOExt:
nvinfer1::IPluginV2Ext nvinfer1::IPluginV2

Public Member Functions

virtual void configurePlugin (PluginTensorDesc const *in, int32_t nbInput, PluginTensorDesc const *out, int32_t nbOutput) noexcept=0
 Configure the layer. More...
 
virtual bool supportsFormatCombination (int32_t pos, PluginTensorDesc const *inOut, int32_t nbInputs, int32_t nbOutputs) const noexcept=0
 Return true if plugin supports the format and datatype for the input/output indexed by pos. More...
 
- Public Member Functions inherited from nvinfer1::IPluginV2Ext
virtual nvinfer1::DataType getOutputDataType (int32_t index, nvinfer1::DataType const *inputTypes, int32_t nbInputs) const noexcept=0
 Return the DataType of the plugin output at the requested index. More...
 
virtual TRT_DEPRECATED bool isOutputBroadcastAcrossBatch (int32_t outputIndex, bool const *inputIsBroadcasted, int32_t nbInputs) const noexcept=0
 Return true if the output tensor is broadcast across a batch. More...
 
virtual TRT_DEPRECATED bool canBroadcastInputAcrossBatch (int32_t inputIndex) const noexcept=0
 Return true if the plugin can use an input tensor that is broadcast across batch without replication. More...
 
 IPluginV2Ext ()=default
 
 ~IPluginV2Ext () override=default
 
virtual void attachToContext (cudnnContext *, cublasContext *, IGpuAllocator *) noexcept
 Attach the plugin object to an execution context and grant the plugin the access to some context resources. More...
 
virtual void detachFromContext () noexcept
 Detach the plugin object from its execution context. More...
 
IPluginV2Extclone () const noexcept override=0
 Clone the plugin object. This copies over internal plugin parameters as well and returns a new plugin object with these parameters. If the source plugin is pre-configured with configurePlugin(), the returned object must also be pre-configured. The returned object must allow attachToContext() with a new execution context. Cloned plugin objects can share the same per-engine immutable resource (e.g. weights) with the source object (e.g. via ref-counting) to avoid duplication. More...
 
- Public Member Functions inherited from nvinfer1::IPluginV2
virtual AsciiChar const * getPluginType () const noexcept=0
 Return the plugin type. Should match the plugin name returned by the corresponding plugin creator. More...
 
virtual AsciiChar const * getPluginVersion () const noexcept=0
 Return the plugin version. Should match the plugin version returned by the corresponding plugin creator. More...
 
virtual int32_t getNbOutputs () const noexcept=0
 Get the number of outputs from the layer. More...
 
virtual Dims getOutputDimensions (int32_t index, Dims const *inputs, int32_t nbInputDims) noexcept=0
 Get the dimension of an output tensor. More...
 
virtual int32_t initialize () noexcept=0
 Initialize the layer for execution. This is called when the engine is created. More...
 
virtual void terminate () noexcept=0
 Release resources acquired during plugin layer initialization. This is called when the engine is destroyed. More...
 
virtual size_t getWorkspaceSize (int32_t maxBatchSize) const noexcept=0
 Find the workspace size required by the layer. More...
 
virtual int32_t enqueue (int32_t batchSize, void const *const *inputs, void *const *outputs, void *workspace, cudaStream_t stream) noexcept=0
 Execute the layer. More...
 
virtual size_t getSerializationSize () const noexcept=0
 Find the size of the serialization buffer required to store the plugin configuration in a binary file. More...
 
virtual void serialize (void *buffer) const noexcept=0
 Serialize the layer. More...
 
virtual void destroy () noexcept=0
 Destroy the plugin object. This will be called when the network, builder or engine is destroyed. More...
 
virtual void setPluginNamespace (AsciiChar const *pluginNamespace) noexcept=0
 Set the namespace that this plugin object belongs to. Ideally, all plugin objects from the same plugin library must have the same namespace. More...
 
virtual AsciiChar const * getPluginNamespace () const noexcept=0
 Return the namespace of the plugin object. More...
 

Protected Member Functions

int32_t getTensorRTVersion () const noexcept override
 Return the API version with which this plugin was built. The upper byte is reserved by TensorRT and is used to differentiate this from IPluginV2 and IPluginV2Ext. More...
 
- Protected Member Functions inherited from nvinfer1::IPluginV2Ext
void configureWithFormat (Dims const *, int32_t, Dims const *, int32_t, DataType, PluginFormat, int32_t) noexcept override
 Derived classes must not implement this. In a C++11 API it would be override final. More...
 

Detailed Description

Plugin class for user-implemented layers.

Plugins are a mechanism for applications to implement custom layers. This interface provides additional capabilities to the IPluginV2Ext interface by extending different I/O data types and tensor formats.

See also
IPluginV2Ext
Deprecated:
Deprecated in TensorRT 10.0.

Member Function Documentation

◆ configurePlugin()

virtual void nvinfer1::IPluginV2IOExt::configurePlugin ( PluginTensorDesc const *  in,
int32_t  nbInput,
PluginTensorDesc const *  out,
int32_t  nbOutput 
)
pure virtualnoexcept

Configure the layer.

This function is called by the builder prior to initialize(). It provides an opportunity for the layer to make algorithm choices on the basis of the provided I/O PluginTensorDesc.

Parameters
inThe input tensors attributes that are used for configuration.
nbInputNumber of input tensors.
outThe output tensors attributes that are used for configuration.
nbOutputNumber of output tensors.


Usage considerations

  • Allowed context for the API call
    • Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads when building networks on multiple devices sharing the same plugin. However, TensorRT will not call this method from two threads simultaneously on a given clone of a plugin.

◆ getTensorRTVersion()

int32_t nvinfer1::IPluginV2IOExt::getTensorRTVersion ( ) const
inlineoverrideprotectedvirtualnoexcept

Return the API version with which this plugin was built. The upper byte is reserved by TensorRT and is used to differentiate this from IPluginV2 and IPluginV2Ext.

Do not override this method as it is used by the TensorRT library to maintain backwards-compatibility with plugins.


Usage considerations

  • Allowed context for the API call
    • Thread-safe: Yes, the implementation provided here is safe to call from any thread.

Reimplemented from nvinfer1::IPluginV2Ext.

◆ supportsFormatCombination()

virtual bool nvinfer1::IPluginV2IOExt::supportsFormatCombination ( int32_t  pos,
PluginTensorDesc const *  inOut,
int32_t  nbInputs,
int32_t  nbOutputs 
) const
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.

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 must 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 must not inspect inOut[pos+1..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 asking for formats once it finds kFORMAT_COMBINATION_LIMIT on combinations.


Usage considerations

  • Allowed context for the API call
    • Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads when building networks on multiple devices sharing the same plugin.

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