TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
nvinfer1::plugin::ResizeNearest Class Referenceabstract
Inheritance diagram for nvinfer1::plugin::ResizeNearest:
Collaboration diagram for nvinfer1::plugin::ResizeNearest:

Public Member Functions

 ResizeNearest (float scale)
 
 ResizeNearest (const void *data, size_t length)
 
 ~ResizeNearest () override=default
 
int getNbOutputs () const override
 Get the number of outputs from the layer. More...
 
Dims getOutputDimensions (int index, const Dims *inputs, int nbInputDims) override
 
int initialize () override
 Initialize the layer for execution. More...
 
void terminate () override
 Release resources acquired during plugin layer initialization. More...
 
void destroy () override
 Destroy the plugin object. More...
 
size_t getWorkspaceSize (int) const override
 
int enqueue (int batch_size, const void *const *inputs, void **outputs, void *workspace, cudaStream_t stream) override
 
size_t getSerializationSize () const override
 Find the size of the serialization buffer required. More...
 
void serialize (void *buffer) const override
 Serialize the layer. More...
 
bool supportsFormat (DataType type, PluginFormat format) const override
 Check format support. More...
 
const char * getPluginType () const override
 Return the plugin type. More...
 
const char * getPluginVersion () const override
 Return the plugin version. More...
 
IPluginV2Extclone () const override
 Clone the plugin object. More...
 
void setPluginNamespace (const char *libNamespace) override
 Set the namespace that this plugin object belongs to. More...
 
const char * getPluginNamespace () const override
 Return the namespace of the plugin object. More...
 
DataType getOutputDataType (int index, const nvinfer1::DataType *inputTypes, int nbInputs) const override
 
bool isOutputBroadcastAcrossBatch (int outputIndex, const bool *inputIsBroadcasted, int nbInputs) const override
 
bool canBroadcastInputAcrossBatch (int inputIndex) const override
 
void attachToContext (cudnnContext *cudnnContext, cublasContext *cublasContext, IGpuAllocator *gpuAllocator) override
 Attach the plugin object to an execution context and grant the plugin the access to some context resource. More...
 
void configurePlugin (const Dims *inputDims, int nbInputs, const Dims *outputDims, int nbOutputs, const DataType *inputTypes, const DataType *outputTypes, const bool *inputIsBroadcast, const bool *outputIsBroadcast, PluginFormat floatFormat, int maxBatchSize) override
 
void detachFromContext () override
 Detach the plugin object from its execution context. More...
 
virtual nvinfer1::DataType getOutputDataType (int32_t index, const nvinfer1::DataType *inputTypes, int32_t nbInputs) const =0
 Return the DataType of the plugin output at the requested index. More...
 
virtual bool isOutputBroadcastAcrossBatch (int32_t outputIndex, const bool *inputIsBroadcasted, int32_t nbInputs) const =0
 Return true if output tensor is broadcast across a batch. More...
 
virtual bool canBroadcastInputAcrossBatch (int32_t inputIndex) const =0
 Return true if plugin can use input that is broadcast across batch without replication. More...
 
virtual void configurePlugin (const Dims *inputDims, int32_t nbInputs, const Dims *outputDims, int32_t nbOutputs, const DataType *inputTypes, const DataType *outputTypes, const bool *inputIsBroadcast, const bool *outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize)=0
 Configure the layer with input and output data types. More...
 
virtual Dims getOutputDimensions (int32_t index, const Dims *inputs, int32_t nbInputDims)=0
 Get the dimension of an output tensor. More...
 
virtual size_t getWorkspaceSize (int32_t maxBatchSize) const =0
 Find the workspace size required by the layer. More...
 
virtual int32_t enqueue (int32_t batchSize, const void *const *inputs, void **outputs, void *workspace, cudaStream_t stream)=0
 Execute the layer. More...
 

Protected Member Functions

int32_t getTensorRTVersion () const
 Return the API version with which this plugin was built. More...
 
void configureWithFormat (const Dims *, int32_t, const Dims *, int32_t, DataType, PluginFormat, int32_t)
 Derived classes should not implement this. More...
 

Private Attributes

float mScale
 
Dims mInputDims
 
Dims mOutputDims
 
std::string mNameSpace
 

Constructor & Destructor Documentation

◆ ResizeNearest() [1/2]

ResizeNearest::ResizeNearest ( float  scale)
Here is the caller graph for this function:

◆ ResizeNearest() [2/2]

ResizeNearest::ResizeNearest ( const void *  data,
size_t  length 
)

◆ ~ResizeNearest()

nvinfer1::plugin::ResizeNearest::~ResizeNearest ( )
overridedefault

Member Function Documentation

◆ getNbOutputs()

int ResizeNearest::getNbOutputs ( ) const
overridevirtual

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().

Implements nvinfer1::IPluginV2.

◆ getOutputDimensions() [1/2]

Dims ResizeNearest::getOutputDimensions ( int  index,
const Dims inputs,
int  nbInputDims 
)
override

◆ initialize()

int ResizeNearest::initialize ( )
overridevirtual

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).

Implements nvinfer1::IPluginV2.

◆ terminate()

void ResizeNearest::terminate ( )
overridevirtual

Release resources acquired during plugin layer initialization.

This is called when the engine is destroyed.

See also
initialize()

Implements nvinfer1::IPluginV2.

◆ destroy()

void ResizeNearest::destroy ( )
overridevirtual

Destroy the plugin object.

This will be called when the network, builder or engine is destroyed.

Implements nvinfer1::IPluginV2.

◆ getWorkspaceSize() [1/2]

size_t ResizeNearest::getWorkspaceSize ( int  ) const
override

◆ enqueue() [1/2]

int ResizeNearest::enqueue ( int  batch_size,
const void *const *  inputs,
void **  outputs,
void *  workspace,
cudaStream_t  stream 
)
override

◆ getSerializationSize()

size_t ResizeNearest::getSerializationSize ( ) const
overridevirtual

Find the size of the serialization buffer required.

Returns
The size of the serialization buffer.

Implements nvinfer1::IPluginV2.

Here is the caller graph for this function:

◆ serialize()

void ResizeNearest::serialize ( void *  buffer) const
overridevirtual

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()

Implements nvinfer1::IPluginV2.

Here is the call graph for this function:

◆ supportsFormat()

bool ResizeNearest::supportsFormat ( DataType  type,
PluginFormat  format 
) const
overridevirtual

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.
DataType:kBOOL not supported.

Implements nvinfer1::IPluginV2.

◆ getPluginType()

const char * ResizeNearest::getPluginType ( ) const
overridevirtual

Return the plugin type.

Should match the plugin name returned by the corresponding plugin creator

See also
IPluginCreator::getPluginName()

Implements nvinfer1::IPluginV2.

◆ getPluginVersion()

const char * ResizeNearest::getPluginVersion ( ) const
overridevirtual

Return the plugin version.

Should match the plugin version returned by the corresponding plugin creator

See also
IPluginCreator::getPluginVersion()

Implements nvinfer1::IPluginV2.

◆ clone()

IPluginV2Ext * ResizeNearest::clone ( ) const
overridevirtual

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 should also be pre-configured. The returned object should 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.

Implements nvinfer1::IPluginV2Ext.

Here is the call graph for this function:

◆ setPluginNamespace()

void ResizeNearest::setPluginNamespace ( const char *  pluginNamespace)
overridevirtual

Set the namespace that this plugin object belongs to.

Ideally, all plugin objects from the same plugin library should have the same namespace.

Implements nvinfer1::IPluginV2.

◆ getPluginNamespace()

const char * ResizeNearest::getPluginNamespace ( ) const
overridevirtual

Return the namespace of the plugin object.

Implements nvinfer1::IPluginV2.

◆ getOutputDataType() [1/2]

DataType ResizeNearest::getOutputDataType ( int  index,
const nvinfer1::DataType inputTypes,
int  nbInputs 
) const
override

◆ isOutputBroadcastAcrossBatch() [1/2]

bool ResizeNearest::isOutputBroadcastAcrossBatch ( int  outputIndex,
const bool *  inputIsBroadcasted,
int  nbInputs 
) const
override

◆ canBroadcastInputAcrossBatch() [1/2]

bool ResizeNearest::canBroadcastInputAcrossBatch ( int  inputIndex) const
override

◆ attachToContext()

void ResizeNearest::attachToContext ( cudnnContext *  ,
cublasContext *  ,
IGpuAllocator  
)
overridevirtual

Attach the plugin object to an execution context and grant the plugin the access to some context resource.

Parameters
cudnnThe cudnn context handle of the execution context
cublasThe cublas context handle of the execution context
allocatorThe allocator used by the execution context

This function is called automatically for each plugin when a new execution context is created. If the plugin needs per-context resource, it can be allocated here. The plugin can also get context-owned CUDNN and CUBLAS context here.

Reimplemented from nvinfer1::IPluginV2Ext.

◆ configurePlugin() [1/2]

void ResizeNearest::configurePlugin ( const Dims inputDims,
int  nbInputs,
const Dims outputDims,
int  nbOutputs,
const DataType inputTypes,
const DataType outputTypes,
const bool *  inputIsBroadcast,
const bool *  outputIsBroadcast,
PluginFormat  floatFormat,
int  maxBatchSize 
)
override

◆ detachFromContext()

void ResizeNearest::detachFromContext ( )
overridevirtual

Detach the plugin object from its execution context.

This function is called automatically for each plugin when a execution context is destroyed. If the plugin owns per-context resource, it can be released here.

Reimplemented from nvinfer1::IPluginV2Ext.

◆ getOutputDataType() [2/2]

virtual nvinfer1::DataType nvinfer1::IPluginV2Ext::getOutputDataType ( int32_t  index,
const nvinfer1::DataType inputTypes,
int32_t  nbInputs 
) const
pure virtualinherited

Return the DataType of the plugin output at the requested index.

The default behavior should be to return the type of the first input, or DataType::kFLOAT if the layer has no inputs. The returned data type must have a format that is supported by the plugin.

See also
supportsFormat()
Warning
DataType:kBOOL not supported.

◆ isOutputBroadcastAcrossBatch() [2/2]

virtual bool nvinfer1::IPluginV2Ext::isOutputBroadcastAcrossBatch ( int32_t  outputIndex,
const bool *  inputIsBroadcasted,
int32_t  nbInputs 
) const
pure virtualinherited

Return true if output tensor is broadcast across a batch.

Parameters
outputIndexThe index of the output
inputIsBroadcastedThe ith element is true if the tensor for the ith input is broadcast across a batch.
nbInputsThe number of inputs

The values in inputIsBroadcasted refer to broadcasting at the semantic level, i.e. are unaffected by whether method canBroadcastInputAcrossBatch requests physical replication of the values.

◆ canBroadcastInputAcrossBatch() [2/2]

virtual bool nvinfer1::IPluginV2Ext::canBroadcastInputAcrossBatch ( int32_t  inputIndex) const
pure virtualinherited

Return true if plugin can use input that is broadcast across batch without replication.

Parameters
inputIndexIndex of input that could be broadcast.

For each input whose tensor is semantically broadcast across a batch, TensorRT calls this method before calling configurePlugin. If canBroadcastInputAcrossBatch returns true, TensorRT will not replicate the input tensor; i.e., there will be a single copy that the plugin should share across the batch. If it returns false, TensorRT will replicate the input tensor so that it appears like a non-broadcasted tensor.

This method is called only for inputs that can be broadcast.

◆ configurePlugin() [2/2]

virtual void nvinfer1::IPluginV2Ext::configurePlugin ( const Dims inputDims,
int32_t  nbInputs,
const Dims outputDims,
int32_t  nbOutputs,
const DataType inputTypes,
const DataType outputTypes,
const bool *  inputIsBroadcast,
const bool *  outputIsBroadcast,
PluginFormat  floatFormat,
int32_t  maxBatchSize 
)
pure virtualinherited

Configure the layer with input and output data types.

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, data types and maximum batch size.

Parameters
inputDimsThe input tensor dimensions.
nbInputsThe number of inputs.
outputDimsThe output tensor dimensions.
nbOutputsThe number of outputs.
inputTypesThe data types selected for the plugin inputs.
outputTypesThe data types selected for the plugin outputs.
inputIsBroadcastTrue for each input that the plugin must broadcast across the batch.
outputIsBroadcastTrue for each output that TensorRT will broadcast across the batch.
floatFormatThe format selected for the engine for the floating point inputs/outputs.
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). When inputIsBroadcast or outputIsBroadcast is true, the outermost batch size for that input or output should be treated as if it is one. inputIsBroadcast[i] is true only if the input is semantically broadcast across the batch and canBroadcastInputAcrossBatch(i) returned true. outputIsBroadcast[i] is true only if isOutputBroadcastAcrossBatch(i) returned true.

Warning
for the floatFormat 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.

◆ getTensorRTVersion()

int32_t nvinfer1::IPluginV2Ext::getTensorRTVersion ( ) const
inlineprotectedvirtualinherited

Return the API version with which this plugin was built.

The upper byte reserved by TensorRT and is used to differentiate this from IPlguinV2.

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

Reimplemented from nvinfer1::IPluginV2.

◆ configureWithFormat()

void nvinfer1::IPluginV2Ext::configureWithFormat ( const Dims ,
int32_t  ,
const Dims ,
int32_t  ,
DataType  ,
PluginFormat  ,
int32_t   
)
inlineprotectedvirtualinherited

Derived classes should not implement this.

In a C++11 API it would be override final.

Implements nvinfer1::IPluginV2.

◆ getOutputDimensions() [2/2]

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

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().

◆ getWorkspaceSize() [2/2]

virtual size_t nvinfer1::IPluginV2::getWorkspaceSize ( int32_t  maxBatchSize) const
pure virtualinherited

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.

◆ enqueue() [2/2]

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

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).

Member Data Documentation

◆ mScale

float nvinfer1::plugin::ResizeNearest::mScale
private

◆ mInputDims

Dims nvinfer1::plugin::ResizeNearest::mInputDims
private

◆ mOutputDims

Dims nvinfer1::plugin::ResizeNearest::mOutputDims
private

◆ mNameSpace

std::string nvinfer1::plugin::ResizeNearest::mNameSpace
private

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