@Namespace(value="nvinfer1") @NoOffset @Properties(inherit=nvinfer.class) public class IResizeLayer extends ILayer
m
dimensions of N-D, where 0 < m <= min(8, N) and N > 0
- ResizeMode::kLINEAR - resizes innermost m
dimensions of N-D, where 0 < m <= min(3, N) and N > 0
Default resize mode is ResizeMode::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 ResizeMode settings (nearest, linear, bilinear, etc.) is
ResizeCoordinateTransformation::kASYMMETRIC.
The 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.
If executing this layer on DLA, the following combinations of parameters are supported:
- In kNEAREST mode:
* (ResizeCoordinateTransformation::kASYMMETRIC, ResizeSelector::kFORMULA, ResizeRoundMode::kFLOOR)
* (ResizeCoordinateTransformation::kHALF_PIXEL, ResizeSelector::kFORMULA, ResizeRoundMode::kHALF_DOWN)
* (ResizeCoordinateTransformation::kHALF_PIXEL, ResizeSelector::kFORMULA, ResizeRoundMode::kHALF_UP)
- In kLINEAR mode:
* (ResizeCoordinateTransformation::kHALF_PIXEL, ResizeSelector::kFORMULA)
* (ResizeCoordinateTransformation::kHALF_PIXEL, ResizeSelector::kUPPER)
\warning Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
IResizeLayer(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getAlignCorners()
Deprecated.
Deprecated in TensorRT 8.0. Superseded by IResizeLayer::getCoordinateTransformation().
|
nvinfer.ResizeCoordinateTransformation |
getCoordinateTransformation()
\brief Get coordinate transformation function.
|
float |
getCubicCoeff()
\brief Get the coefficient 'A' used in cubic interpolation.
|
boolean |
getExcludeOutside()
\brief Get the state for excluding outside pixels.
|
nvinfer.ResizeRoundMode |
getNearestRounding()
\brief Get rounding mode for nearest neighbor resize.
|
Dims32 |
getOutputDimensions()
\brief Get the output dimensions.
|
nvinfer.InterpolationMode |
getResizeMode()
\brief Get resize mode for an input tensor.
|
int |
getScales(int size,
float[] scales) |
int |
getScales(int size,
FloatBuffer scales) |
int |
getScales(int size,
FloatPointer scales)
\brief Copies resize scales to scales[0, ..., nbScales-1], where nbScales is the number of scales that were set.
|
nvinfer.ResizeSelector |
getSelectorForSinglePixel()
\brief Get the coordinate selector function when resized to single pixel.
|
void |
setAlignCorners(boolean alignCorners)
Deprecated.
Deprecated in TensorRT 8.0. Superseded by IResizeLayer::setCoordinateTransformation().
|
void |
setCoordinateTransformation(int coordTransform) |
void |
setCoordinateTransformation(nvinfer.ResizeCoordinateTransformation coordTransform)
\brief Set coordinate transformation function.
|
void |
setCubicCoeff(float A)
\brief Set the coefficient 'A' used in cubic interpolation.
|
void |
setExcludeOutside(boolean excludeFlag)
\brief Set the state for excluding outside pixels.
|
void |
setNearestRounding(int value) |
void |
setNearestRounding(nvinfer.ResizeRoundMode value)
\brief Set rounding mode for nearest neighbor resize.
|
void |
setOutputDimensions(Dims32 dimensions)
\brief Set the output dimensions.
|
void |
setResizeMode(int resizeMode) |
void |
setResizeMode(nvinfer.InterpolationMode resizeMode)
\brief Set resize mode for an input tensor.
|
void |
setScales(float[] scales,
int nbScales) |
void |
setScales(FloatBuffer scales,
int nbScales) |
void |
setScales(FloatPointer scales,
int nbScales)
\brief Set the resize scales.
|
void |
setSelectorForSinglePixel(int selector) |
void |
setSelectorForSinglePixel(nvinfer.ResizeSelector selector)
\brief Set coordinate selector function when resized to single pixel.
|
getInput, getMetadata, getName, getNbInputs, getNbOutputs, getOutput, getOutputType, getPrecision, getType, outputTypeIsSet, precisionIsSet, resetOutputType, resetPrecision, setInput, setMetadata, setMetadata, setName, setName, setOutputType, setOutputType, setPrecision, setPrecision
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public IResizeLayer(Pointer p)
Pointer(Pointer)
.@NoException(value=true) public void setOutputDimensions(@ByVal @Cast(value="nvinfer1::Dims*") Dims32 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().setScales
,
getOutputDimensions
@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims32 getOutputDimensions()
@NoException(value=true) public void setScales(@Const FloatPointer scales, int nbScales)
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().setOutputDimensions
,
getScales
@NoException(value=true) public void setScales(@Const FloatBuffer scales, int nbScales)
@NoException(value=true) public void setScales(@Const float[] scales, int nbScales)
@NoException(value=true) public int getScales(int size, FloatPointer scales)
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.@NoException(value=true) public int getScales(int size, FloatBuffer scales)
@NoException(value=true) public int getScales(int size, float[] scales)
@NoException(value=true) public void setResizeMode(nvinfer.InterpolationMode resizeMode)
ResizeMode
@NoException(value=true) public void setResizeMode(@Cast(value="nvinfer1::InterpolationMode") int resizeMode)
@NoException(value=true) public nvinfer.InterpolationMode getResizeMode()
@Deprecated @NoException(value=true) public void setAlignCorners(@Cast(value="bool") boolean alignCorners)
@Cast(value="bool") @Deprecated @NoException(value=true) public boolean getAlignCorners()
@NoException(value=true) public void setCoordinateTransformation(nvinfer.ResizeCoordinateTransformation coordTransform)
nvinfer.ResizeCoordinateTransformation
@NoException(value=true) public void setCoordinateTransformation(@Cast(value="nvinfer1::ResizeCoordinateTransformation") int coordTransform)
@NoException(value=true) public nvinfer.ResizeCoordinateTransformation getCoordinateTransformation()
@NoException(value=true) public void setSelectorForSinglePixel(nvinfer.ResizeSelector selector)
nvinfer.ResizeSelector
@NoException(value=true) public void setSelectorForSinglePixel(@Cast(value="nvinfer1::ResizeSelector") int selector)
@NoException(value=true) public nvinfer.ResizeSelector getSelectorForSinglePixel()
@NoException(value=true) public void setNearestRounding(nvinfer.ResizeRoundMode value)
nvinfer.ResizeRoundMode
@NoException(value=true) public void setNearestRounding(@Cast(value="nvinfer1::ResizeRoundMode") int value)
@NoException(value=true) public nvinfer.ResizeRoundMode getNearestRounding()
@NoException(value=true) public void setCubicCoeff(float A)
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.
@NoException(value=true) public float getCubicCoeff()
setCubicCoeff()
@NoException(value=true) public void setExcludeOutside(@Cast(value="bool") boolean excludeFlag)
@Cast(value="bool") @NoException(value=true) public boolean getExcludeOutside()
setExcludeOutside()
Copyright © 2024. All rights reserved.