TensorRT  6.0.1.5
nvinfer1::IPluginV2 Class Referenceabstract

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

#include <NvInferRuntimeCommon.h>

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

Public Member Functions

virtual int getTensorRTVersion () const
 Return the API version with which this plugin was built. More...
 
virtual const char * getPluginType () const =0
 Return the plugin type. Should match the plugin name returned by the corresponding plugin creator.
 
virtual const char * getPluginVersion () const =0
 Return the plugin version. Should match the plugin version returned by the corresponding plugin creator.
 
virtual int getNbOutputs () const =0
 Get the number of outputs from the layer. More...
 
virtual Dims getOutputDimensions (int index, const Dims *inputs, int nbInputDims)=0
 Get the dimension of an output tensor. More...
 
virtual bool supportsFormat (DataType type, PluginFormat format) const =0
 Check format support. More...
 
virtual void configureWithFormat (const Dims *inputDims, int nbInputs, const Dims *outputDims, int nbOutputs, DataType type, PluginFormat format, int maxBatchSize)=0
 Configure the layer. More...
 
virtual int initialize ()=0
 Initialize the layer for execution. This is called when the engine is created. More...
 
virtual void terminate ()=0
 Release resources acquired during plugin layer initialization. This is called when the engine is destroyed. More...
 
virtual size_t getWorkspaceSize (int maxBatchSize) const =0
 Find the workspace size required by the layer. More...
 
virtual int enqueue (int batchSize, const void *const *inputs, void **outputs, void *workspace, cudaStream_t stream)=0
 Execute the layer. More...
 
virtual size_t getSerializationSize () const =0
 Find the size of the serialization buffer required. More...
 
virtual void serialize (void *buffer) const =0
 Serialize the layer. More...
 
virtual void destroy ()=0
 Destroy the plugin object. This will be called when the network, builder or engine is destroyed.
 
virtual IPluginV2clone () const =0
 Clone the plugin object. This copies over internal plugin parameters and returns a new plugin object with these parameters.
 
virtual void setPluginNamespace (const char *pluginNamespace)=0
 Set the namespace that this plugin object belongs to. Ideally, all plugin objects from the same plugin library should have the same namespace.
 
virtual const char * getPluginNamespace () const =0
 Return the namespace of the plugin object.
 

Detailed Description

Plugin class for user-implemented layers.

Plugins are a mechanism for applications to implement custom layers. When combined with IPluginCreator it provides a mechanism to register plugins and look up the Plugin Registry during de-serialization.

See also
IPluginCreator
IPluginRegistry

Member Function Documentation

◆ configureWithFormat()

virtual void nvinfer1::IPluginV2::configureWithFormat ( const Dims inputDims,
int  nbInputs,
const Dims outputDims,
int  nbOutputs,
DataType  type,
PluginFormat  format,
int  maxBatchSize 
)
pure virtual

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 its weights, dimensions, and maximum batch size.

Parameters
inputDimsThe input tensor dimensions.
nbInputsThe number of inputs.
outputDimsThe output tensor dimensions.
nbOutputsThe number of outputs.
typeThe data type selected for the engine.
formatThe format selected for the engine.
maxBatchSizeThe maximum batch size.

The dimensions passed here do not include the outermost batch size (i.e. for 2-D image networks, they will be 3-dimensional CHW dimensions).

Warning
for the format field, the values PluginFormat::kCHW4, PluginFormat::kCHW16, and PluginFormat::kCHW32 will not be passed in, this is to keep backward compatibility with TensorRT 5.x series. Use PluginV2IOExt or PluginV2DynamicExt for other PluginFormats.

Implemented in nvinfer1::IPluginV2IOExt, and nvinfer1::IPluginV2Ext.

◆ enqueue()

virtual int nvinfer1::IPluginV2::enqueue ( int  batchSize,
const void *const *  inputs,
void **  outputs,
void *  workspace,
cudaStream_t  stream 
)
pure virtual

Execute the layer.

Parameters
batchSizeThe number of inputs in the batch.
inputsThe memory for the input tensors.
outputsThe memory for the output tensors.
workspaceWorkspace for execution.
streamThe stream in which to execute the kernels.
Returns
0 for success, else non-zero (which will cause engine termination).

Implemented in nvinfer1::IPluginV2DynamicExt.

◆ getNbOutputs()

virtual int nvinfer1::IPluginV2::getNbOutputs ( ) const
pure virtual

Get the number of outputs from the layer.

Returns
The number of outputs.

This function is called by the implementations of INetworkDefinition and IBuilder. In particular, it is called prior to any call to initialize().

◆ getOutputDimensions()

virtual Dims nvinfer1::IPluginV2::getOutputDimensions ( int  index,
const Dims inputs,
int  nbInputDims 
)
pure virtual

Get the dimension of an output tensor.

Parameters
indexThe index of the output tensor.
inputsThe input tensors.
nbInputDimsThe number of input tensors.

This function is called by the implementations of INetworkDefinition and IBuilder. In particular, it is called prior to any call to initialize().

Implemented in nvinfer1::IPluginV2DynamicExt.

◆ getSerializationSize()

virtual size_t nvinfer1::IPluginV2::getSerializationSize ( ) const
pure virtual

Find the size of the serialization buffer required.

Returns
The size of the serialization buffer.

◆ getTensorRTVersion()

virtual int nvinfer1::IPluginV2::getTensorRTVersion ( ) const
inlinevirtual

Return the API version with which this plugin was built.

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

Reimplemented in nvinfer1::IPluginV2IOExt, nvinfer1::IPluginV2Ext, and nvinfer1::IPluginV2DynamicExt.

◆ getWorkspaceSize()

virtual size_t nvinfer1::IPluginV2::getWorkspaceSize ( int  maxBatchSize) const
pure virtual

Find the workspace size required by the layer.

This function is called during engine startup, after initialize(). The workspace size returned should be sufficient for any batch size up to the maximum.

Returns
The workspace size.

Implemented in nvinfer1::IPluginV2DynamicExt.

◆ initialize()

virtual int nvinfer1::IPluginV2::initialize ( )
pure virtual

Initialize the layer for execution. This is called when the engine is created.

Returns
0 for success, else non-zero (which will cause engine termination).

◆ serialize()

virtual void nvinfer1::IPluginV2::serialize ( void *  buffer) const
pure virtual

Serialize the layer.

Parameters
bufferA pointer to a buffer to serialize data. Size of buffer must be equal to value returned by getSerializationSize.
See also
getSerializationSize()

◆ supportsFormat()

virtual bool nvinfer1::IPluginV2::supportsFormat ( DataType  type,
PluginFormat  format 
) const
pure virtual

Check format support.

Parameters
typeDataType requested.
formatPluginFormat requested.
Returns
true if the plugin supports the type-format combination.

This function is called by the implementations of INetworkDefinition, IBuilder, and safe::ICudaEngine/ICudaEngine. In particular, it is called when creating an engine and when deserializing an engine.

Warning
for the format field, the values PluginFormat::kCHW4, PluginFormat::kCHW16, and PluginFormat::kCHW32 will not be passed in, this is to keep backward compatibility with TensorRT 5.x series. Use PluginV2IOExt or PluginV2DynamicExt for other PluginFormats.

Implemented in nvinfer1::IPluginV2IOExt, and nvinfer1::IPluginV2DynamicExt.

◆ terminate()

virtual void nvinfer1::IPluginV2::terminate ( )
pure virtual

Release resources acquired during plugin layer initialization. This is called when the engine is destroyed.

See also
initialize()

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