TensorRT 10.5.0
|
A resize layer in a network definition. More...
#include <NvInfer.h>
Public Member Functions | |
void | setOutputDimensions (Dims const &dimensions) noexcept |
Set the output dimensions. More... | |
Dims | getOutputDimensions () const noexcept |
Get the output dimensions. More... | |
void | setScales (float const *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 (InterpolationMode interpolationMode) noexcept |
Set resize mode for an input tensor. More... | |
InterpolationMode | getResizeMode () const noexcept |
Get resize mode for an input tensor. 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 | setCubicCoeff (float A) noexcept |
Set the coefficient 'A' used in cubic interpolation. More... | |
float | getCubicCoeff () const noexcept |
Get the coefficient 'A' used in cubic interpolation. More... | |
void | setExcludeOutside (bool excludeFlag) noexcept |
Set the state for excluding outside pixels. More... | |
bool | getExcludeOutside () const noexcept |
Get the state for excluding outside pixels. 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 (char const *name) noexcept |
Set the name of a layer. More... | |
char const * | getName () const noexcept |
Return the name of a layer. More... | |
int32_t | getNbInputs () const noexcept |
Get the number of inputs of a layer. More... | |
ITensor * | getInput (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. More... | |
ITensor * | getOutput (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 preferred or required computational precision of this layer in a weakly-typed network. 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 in a weakly-typed network. 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... | |
void | setMetadata (char const *metadata) noexcept |
Set the metadata for this layer. More... | |
char const * | getMetadata () const noexcept |
Get the metadata of the layer. More... | |
Protected Member Functions | |
virtual | ~IResizeLayer () noexcept=default |
Protected Member Functions inherited from nvinfer1::ILayer | |
virtual | ~ILayer () noexcept=default |
Protected Member Functions inherited from nvinfer1::INoCopy | |
INoCopy ()=default | |
virtual | ~INoCopy ()=default |
INoCopy (INoCopy const &other)=delete | |
INoCopy & | operator= (INoCopy const &other)=delete |
INoCopy (INoCopy &&other)=delete | |
INoCopy & | operator= (INoCopy &&other)=delete |
Protected Attributes | |
apiv::VResizeLayer * | mImpl |
Protected Attributes inherited from nvinfer1::ILayer | |
apiv::VLayer * | mLayer |
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:
m
dimensions of N-D, where 0 < m <= min(8, N) and N > 0m
dimensions of N-D, where 0 < m <= min(3, N) and N > 0Default resize mode is InterpolationMode::kNEAREST.
The coordinates in the output tensor are mapped to coordinates in the input tensor using a function set by calling setCoordinateTransformation(). The default for all InterpolationMode settings (nearest, linear, bilinear, etc.) is ResizeCoordinateTransformation::kASYMMETRIC.
The resize layer provides two ways to resize tensor dimensions.
If executing this layer on DLA, the following combinations of parameters are supported:
|
protectedvirtualdefaultnoexcept |
|
inlinenoexcept |
Get coordinate transformation function.
|
inlinenoexcept |
Get the coefficient 'A' used in cubic interpolation.
|
inlinenoexcept |
Get the state for excluding outside pixels.
|
inlinenoexcept |
Get rounding mode for nearest neighbor resize.
|
inlinenoexcept |
Get the output dimensions.
|
inlinenoexcept |
Get resize mode for an input tensor.
|
inlinenoexcept |
Copies resize scales to scales[0, ..., nbScales-1], where nbScales is the number of scales that were set.
size | The number of scales to get. If size != nbScales, no scales will be copied. |
scales | Pointer 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.
|
inlinenoexcept |
Get the coordinate selector function when resized to single pixel.
|
inlinenoexcept |
Set coordinate transformation function.
The function maps a coordinate in the output tensor to a coordinate in the input tensor.
Default function is ResizeCoordinateTransformation::kASYMMETRIC.
|
inlinenoexcept |
Set the coefficient 'A' used in cubic interpolation.
Cubic uses the coefficient 'A' to calculate the weight of input pixels:
x := The relative distance between the sampled pixels and the input coordinates. weight(x) := for |x| <= 1, ((A + 2) * x - (A + 3)) * x * x + 1, for 1 < |x| < 2, ((A * x - 5 * A) * x + 8 * A) * x - 4 * A, others 0;
This attribute is valid only if "resize mode" is "cubic".
The default value is -0.75.
|
inlinenoexcept |
Set the state for excluding outside pixels.
If set to true, the weight of sampling locations outside the input tensor will be set to false, and the weight will be renormalized so that their sum is 1.0.
The default value is false.
|
inlinenoexcept |
Append or replace an input of this layer with a specific tensor.
index | the index of the input to modify. |
tensor | the 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:
If this function is called with the value 1, then the function getNbInputs() changes from returning 1 to 2.
|
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.
|
inlinenoexcept |
Set the output dimensions.
dimensions | The output dimensions. Number of output dimensions must be the same as the number of input dimensions. |
If executing this layer on DLA, setOutputDimensions() is not supported.
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().
|
inlinenoexcept |
Set resize mode for an input tensor.
Supported resize modes are Nearest Neighbor and Linear.
|
inlinenoexcept |
Set the resize scales.
scales | An array of resize scales. |
nbScales | Number of scales. Number of scales must be equal to the number of input dimensions. |
If executing this layer on DLA, there are three restrictions: 1) nbScales has to be exactly 4. 2) the first two elements in scales need to be exactly 1 (for unchanged batch and channel dimensions). 3) The last two elements in scales, representing the scale values along height and width dimensions, respectively, need to be integer values in the range of [1, 32] for kNEAREST mode and [1, 4] for kLINEAR. Example of DLA-supported scales: {1, 1, 2, 2}.
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().
|
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.
|
protected |
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