TensorRT  8.0.1
nvinfer1::IResizeLayer Class Reference

A resize layer in a network definition. More...

#include <NvInfer.h>

Inheritance diagram for nvinfer1::IResizeLayer:
nvinfer1::ILayer nvinfer1::INoCopy

Public Member Functions

void setOutputDimensions (Dims dimensions) noexcept
 Set the output dimensions. More...
 
Dims getOutputDimensions () const noexcept
 Get the output dimensions. More...
 
void setScales (const float *scales, int32_t nbScales) noexcept
 Set the resize scales. More...
 
int32_t getScales (int32_t size, float *scales) const noexcept
 Copies resize scales to scales[0, ..., nbScales-1], where nbScales is the number of scales that were set. More...
 
void setResizeMode (ResizeMode resizeMode) noexcept
 Set resize mode for an input tensor. More...
 
ResizeMode getResizeMode () const noexcept
 Get resize mode for an input tensor. More...
 
TRT_DEPRECATED void setAlignCorners (bool alignCorners) noexcept
 Set whether to align corners while resizing. More...
 
TRT_DEPRECATED bool getAlignCorners () const noexcept
 True if align corners has been set. More...
 
void setCoordinateTransformation (ResizeCoordinateTransformation coordTransform) noexcept
 Set coordinate transformation function. More...
 
ResizeCoordinateTransformation getCoordinateTransformation () const noexcept
 Get coordinate transformation function. More...
 
void setSelectorForSinglePixel (ResizeSelector selector) noexcept
 Set coordinate selector function when resized to single pixel. More...
 
ResizeSelector getSelectorForSinglePixel () const noexcept
 Get the coordinate selector function when resized to single pixel. More...
 
void setNearestRounding (ResizeRoundMode value) noexcept
 Set rounding mode for nearest neighbor resize. More...
 
ResizeRoundMode getNearestRounding () const noexcept
 Get rounding mode for nearest neighbor resize. More...
 
void setInput (int32_t index, ITensor &tensor) noexcept
 Append or replace an input of this layer with a specific tensor. More...
 
- Public Member Functions inherited from nvinfer1::ILayer
LayerType getType () const noexcept
 Return the type of a layer. More...
 
void setName (const char *name) noexcept
 Set the name of a layer. More...
 
const char * getName () const noexcept
 Return the name of a layer. More...
 
int32_t getNbInputs () const noexcept
 Get the number of inputs of a layer.
 
ITensorgetInput (int32_t index) const noexcept
 Get the layer input corresponding to the given index. More...
 
int32_t getNbOutputs () const noexcept
 Get the number of outputs of a layer.
 
ITensorgetOutput (int32_t index) const noexcept
 Get the layer output corresponding to the given index. More...
 
void setInput (int32_t index, ITensor &tensor) noexcept
 Replace an input of this layer with a specific tensor. More...
 
void setPrecision (DataType dataType) noexcept
 Set the computational precision of this layer. More...
 
DataType getPrecision () const noexcept
 get the computational precision of this layer More...
 
bool precisionIsSet () const noexcept
 whether the computational precision has been set for this layer More...
 
void resetPrecision () noexcept
 reset the computational precision for this layer More...
 
void setOutputType (int32_t index, DataType dataType) noexcept
 Set the output type of this layer. More...
 
DataType getOutputType (int32_t index) const noexcept
 get the output type of this layer More...
 
bool outputTypeIsSet (int32_t index) const noexcept
 whether the output type has been set for this layer More...
 
void resetOutputType (int32_t index) noexcept
 reset the output type for this layer More...
 

Protected Attributes

apiv::VResizeLayermImpl
 
- Protected Attributes inherited from nvinfer1::ILayer
apiv::VLayermLayer
 

Additional Inherited Members

- Protected Member Functions inherited from nvinfer1::INoCopy
 INoCopy (const INoCopy &other)=delete
 
INoCopyoperator= (const INoCopy &other)=delete
 
 INoCopy (INoCopy &&other)=delete
 
INoCopyoperator= (INoCopy &&other)=delete
 

Detailed Description

A resize layer in a network definition.

Resize layer can be used for resizing a N-D tensor.

Resize layer currently supports the following configurations:

Default resize mode is ResizeMode::kNEAREST.

Resize layer provides two ways to resize tensor dimensions.

  • Set output dimensions directly. It can be done for static as well as dynamic resize layer. Static resize layer requires output dimensions to be known at build-time. Dynamic resize layer requires output dimensions to be set as one of the input tensors.
  • Set scales for resize. Each output dimension is calculated as floor(input dimension * scale). Only static resize layer allows setting scales where the scales are known at build-time.
Warning
Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.

Member Function Documentation

◆ getAlignCorners()

TRT_DEPRECATED bool nvinfer1::IResizeLayer::getAlignCorners ( ) const
inlinenoexcept

True if align corners has been set.

Returns
True if align corners has been set, false otherwise.
Deprecated:
Superseded by IResizeLayer::getCoordinateTransformation() and will be removed in TensorRT 10.0.

◆ getCoordinateTransformation()

ResizeCoordinateTransformation nvinfer1::IResizeLayer::getCoordinateTransformation ( ) const
inlinenoexcept

Get coordinate transformation function.

Returns
The coordinate transformation function.

◆ getNearestRounding()

ResizeRoundMode nvinfer1::IResizeLayer::getNearestRounding ( ) const
inlinenoexcept

Get rounding mode for nearest neighbor resize.

Returns
The rounding mode.

◆ getOutputDimensions()

Dims nvinfer1::IResizeLayer::getOutputDimensions ( ) const
inlinenoexcept

Get the output dimensions.

Returns
The output dimensions.

◆ getResizeMode()

ResizeMode nvinfer1::IResizeLayer::getResizeMode ( ) const
inlinenoexcept

Get resize mode for an input tensor.

Returns
The resize mode.

◆ getScales()

int32_t nvinfer1::IResizeLayer::getScales ( int32_t  size,
float *  scales 
) const
inlinenoexcept

Copies resize scales to scales[0, ..., nbScales-1], where nbScales is the number of scales that were set.

Parameters
sizeThe number of scales to get. If size != nbScales, no scales will be copied.
scalesPointer to where to copy the scales. Scales will be copied only if size == nbScales and scales != nullptr.

In case the size is not known consider using size = 0 and scales = nullptr. This method will return the number of resize scales.

Returns
The number of resize scales i.e. nbScales if scales were set. Return -1 in case no scales were set or resize layer is used in dynamic mode.

◆ getSelectorForSinglePixel()

ResizeSelector nvinfer1::IResizeLayer::getSelectorForSinglePixel ( ) const
inlinenoexcept

Get the coordinate selector function when resized to single pixel.

Returns
The selector function.

◆ setAlignCorners()

TRT_DEPRECATED void nvinfer1::IResizeLayer::setAlignCorners ( bool  alignCorners)
inlinenoexcept

Set whether to align corners while resizing.

If true, the centers of the 4 corner pixels of both input and output tensors are aligned i.e. preserves the values of corner pixels.

Default: false.

Deprecated:
Superseded by IResizeLayer::setCoordinateTransformation() and will be removed in TensorRT 10.0.

◆ setCoordinateTransformation()

void nvinfer1::IResizeLayer::setCoordinateTransformation ( ResizeCoordinateTransformation  coordTransform)
inlinenoexcept

Set coordinate transformation function.

We have different functions mapping the coordinate in output tensor to the coordinate in input tensor.

Default is ResizeCoordinateTransformation::kASYMMETRIC.

See also
ResizeCoordinateTransformation

◆ setInput()

void nvinfer1::ILayer::setInput
inlinenoexcept

Append or replace an input of this layer with a specific tensor.

Parameters
indexthe index of the input to modify.
tensorthe new input tensor.

Sets the input tensor for the given index. The index must be 0 for a static resize layer. A static resize layer is converted to a dynamic resize layer by calling setInput with an index 1. A dynamic resize layer cannot be converted back to a static resize layer.

For a dynamic resize layer, the values 0 and 1 are valid. The indices in the dynamic case are as follows:

  • 0: Data or Shape tensor to be resized.
  • 1: The output dimensions, as a 1D Int32 shape tensor.

If this function is called with a value 1, then the function getNbInputs() changes from returning 1 to 2.

◆ setNearestRounding()

void nvinfer1::IResizeLayer::setNearestRounding ( ResizeRoundMode  value)
inlinenoexcept

Set rounding mode for nearest neighbor resize.

This value is used for nearest neighbor interpolation rounding. It is applied after coordinate transformation.

Default is kFLOOR.

See also
ResizeRoundMode

◆ setOutputDimensions()

void nvinfer1::IResizeLayer::setOutputDimensions ( Dims  dimensions)
inlinenoexcept

Set the output dimensions.

Parameters
dimensionsThe output dimensions. Number of output dimensions must be the same as the number of input dimensions.

If there is a second input, i.e. resize layer is dynamic, calling setOutputDimensions() is an error and does not update the dimensions.

Output dimensions can be specified directly, or via scale factors relative to input dimensions. Scales for resize can be provided using setScales().

See also
setScales
getOutputDimensions

◆ setResizeMode()

void nvinfer1::IResizeLayer::setResizeMode ( ResizeMode  resizeMode)
inlinenoexcept

Set resize mode for an input tensor.

Supported resize modes are Nearest Neighbor and Linear.

See also
ResizeMode

◆ setScales()

void nvinfer1::IResizeLayer::setScales ( const float *  scales,
int32_t  nbScales 
)
inlinenoexcept

Set the resize scales.

Parameters
scalesAn array of resize scales.
nbScalesNumber of scales. Number of scales must be equal to the number of input dimensions.

If there is a second input, i.e. resize layer is dynamic, calling setScales() is an error and does not update the scales.

Output dimensions are calculated as follows: outputDims[i] = floor(inputDims[i] * scales[i])

Output dimensions can be specified directly, or via scale factors relative to input dimensions. Output dimensions can be provided directly using setOutputDimensions().

See also
setOutputDimensions
getScales

◆ setSelectorForSinglePixel()

void nvinfer1::IResizeLayer::setSelectorForSinglePixel ( ResizeSelector  selector)
inlinenoexcept

Set coordinate selector function when resized to single pixel.

When resize to single pixel image, use this function to decide how to map the coordinate in the original image.

Default is ResizeSelector::kFORMULA.

See also
ResizeSelector

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