pub struct IResizeLayer { /* private fields */ }Expand description
! \class IResizeLayer
!
! \brief 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:
! - InterpolationMode::kNEAREST - resizes last m dimensions of N-D, where 0 < m <= min(8, N) and N > 0
! - InterpolationMode::kLINEAR - resizes last m dimensions of N-D, where 0 < m <= min(3, N) and N > 0
!
! Default 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.
! - 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.
!
Implementations§
Source§impl IResizeLayer
impl IResizeLayer
Sourcepub fn setOutputDimensions(self: Pin<&mut IResizeLayer>, dimensions: &Dims64)
pub fn setOutputDimensions(self: Pin<&mut IResizeLayer>, dimensions: &Dims64)
! ! \brief Set the output dimensions. ! ! \param 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(). ! ! \see setScales ! \see getOutputDimensions !
Sourcepub fn getOutputDimensions(self: &IResizeLayer) -> Dims64
pub fn getOutputDimensions(self: &IResizeLayer) -> Dims64
! ! \brief Get the output dimensions. ! ! \return The output dimensions. !
Sourcepub unsafe fn setScales(
self: Pin<&mut IResizeLayer>,
scales: *const f32,
nbScales: i32,
)
pub unsafe fn setScales( self: Pin<&mut IResizeLayer>, scales: *const f32, nbScales: i32, )
! ! \brief Set the resize scales. ! ! \param scales An array of resize scales. ! \param 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(). ! ! \see setOutputDimensions ! \see getScales !
Sourcepub unsafe fn getScales(self: &IResizeLayer, size: i32, scales: *mut f32) -> i32
pub unsafe fn getScales(self: &IResizeLayer, size: i32, scales: *mut f32) -> i32
! ! \brief Copies resize scales to scales[0, …, nbScales-1], where nbScales is the number of scales that were set. ! ! \param size The number of scales to get. If size != nbScales, no scales will be copied. ! ! \param 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. ! ! \return 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. !
Sourcepub fn setResizeMode(
self: Pin<&mut IResizeLayer>,
interpolationMode: InterpolationMode,
)
pub fn setResizeMode( self: Pin<&mut IResizeLayer>, interpolationMode: InterpolationMode, )
! ! \brief Set resize mode for an input tensor. ! ! Supported resize modes are Nearest Neighbor and Linear. ! ! \see InterpolationMode !
Sourcepub fn getResizeMode(self: &IResizeLayer) -> InterpolationMode
pub fn getResizeMode(self: &IResizeLayer) -> InterpolationMode
! ! \brief Get resize mode for an input tensor. ! ! \return The resize mode. !
Sourcepub fn setCoordinateTransformation(
self: Pin<&mut IResizeLayer>,
coordTransform: ResizeCoordinateTransformation,
)
pub fn setCoordinateTransformation( self: Pin<&mut IResizeLayer>, coordTransform: ResizeCoordinateTransformation, )
! ! \brief 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. ! ! \see ResizeCoordinateTransformation !
Sourcepub fn getCoordinateTransformation(
self: &IResizeLayer,
) -> ResizeCoordinateTransformation
pub fn getCoordinateTransformation( self: &IResizeLayer, ) -> ResizeCoordinateTransformation
! ! \brief Get coordinate transformation function. ! ! \return The coordinate transformation function. !
Sourcepub fn setSelectorForSinglePixel(
self: Pin<&mut IResizeLayer>,
selector: ResizeSelector,
)
pub fn setSelectorForSinglePixel( self: Pin<&mut IResizeLayer>, selector: ResizeSelector, )
! ! \brief 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 ResizeSelector !
Sourcepub fn getSelectorForSinglePixel(self: &IResizeLayer) -> ResizeSelector
pub fn getSelectorForSinglePixel(self: &IResizeLayer) -> ResizeSelector
! ! \brief Get the coordinate selector function when resized to single pixel. ! ! \return The selector function. !
Sourcepub fn setNearestRounding(self: Pin<&mut IResizeLayer>, value: ResizeRoundMode)
pub fn setNearestRounding(self: Pin<&mut IResizeLayer>, value: ResizeRoundMode)
! ! \brief 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 ResizeRoundMode !
Sourcepub fn getNearestRounding(self: &IResizeLayer) -> ResizeRoundMode
pub fn getNearestRounding(self: &IResizeLayer) -> ResizeRoundMode
! ! \brief Get rounding mode for nearest neighbor resize. ! ! \return The rounding mode. !
Sourcepub fn setCubicCoeff(self: Pin<&mut IResizeLayer>, A: f32)
pub fn setCubicCoeff(self: Pin<&mut IResizeLayer>, A: f32)
! ! \brief 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. !
Sourcepub fn getCubicCoeff(self: &IResizeLayer) -> f32
pub fn getCubicCoeff(self: &IResizeLayer) -> f32
! ! \brief Get the coefficient ‘A’ used in cubic interpolation. ! ! \see setCubicCoeff() !
Sourcepub fn setExcludeOutside(self: Pin<&mut IResizeLayer>, excludeFlag: bool)
pub fn setExcludeOutside(self: Pin<&mut IResizeLayer>, excludeFlag: bool)
! ! \brief 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. !
Sourcepub fn getExcludeOutside(self: &IResizeLayer) -> bool
pub fn getExcludeOutside(self: &IResizeLayer) -> bool
! ! \brief Get the state for excluding outside pixels. ! ! \see setExcludeOutside() !