Skip to main content

IScaleLayer

Struct IScaleLayer 

Source
pub struct IScaleLayer { /* private fields */ }
Expand description

IScaleLayer

A Scale layer in a network definition.

This layer applies a per-element computation to its input:

output = ( input* scale + shift)^ power

The coefficients can be applied on a per-tensor, per-channel, or per-element basis.

If the number of weights is 0, then a default value is used for shift, power, and scale. The default shift is 0, the default power is 1, and the default scale is 1.

The output size is the same as the input size.

The input tensor is required to have at least 4 dimensions.

A scale layer may be used as an INT8 quantization node in a graph, if the output is constrained to INT8 and the input to FP32. Quantization rounds ties to even, and clamps to [-128, 127].

See ScaleMode

Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.

Implementations§

Source§

impl IScaleLayer

Source

pub fn setMode(self: Pin<&mut IScaleLayer>, mode: ScaleMode)

Set the scale mode.

See [getMode()]

Source

pub fn getMode(self: &IScaleLayer) -> ScaleMode

Get the scale mode.

See [setMode()]

Source

pub fn setShift(self: Pin<&mut IScaleLayer>, shift: Weights)

Set the shift value.

See [getShift()]

Source

pub fn getShift(self: &IScaleLayer) -> Weights

Get the shift value.

See [setShift()]

Source

pub fn setScale(self: Pin<&mut IScaleLayer>, scale: Weights)

Set the scale value.

See [getScale()]

Source

pub fn getScale(self: &IScaleLayer) -> Weights

Get the scale value.

See [setScale()]

Source

pub fn setPower(self: Pin<&mut IScaleLayer>, power: Weights)

Set the power value.

See [getPower()]

Source

pub fn getPower(self: &IScaleLayer) -> Weights

Get the power value.

See [setPower()]

Source

pub fn getChannelAxis(self: &IScaleLayer) -> i32

Get the channel axis.

channelAxis parameter passed to addScaleNd() or set by setChannelAxis()

The value is the index of the channel axis in the input tensor’s dimensions. Scaling happens along the channel axis when ScaleMode::kCHANNEL is enabled.

See [addScaleNd()]

Source

pub fn setChannelAxis(self: Pin<&mut IScaleLayer>, channelAxis: i32)

Set the channel axis.

The value is the index of the channel axis in the input tensor’s dimensions.

For ScaleMode::kCHANNEL, there can be distinct scale, shift, and power weights for each channel coordinate. For ScaleMode::kELEMENTWISE, there can be distinct scale, shift, and power weights for each combination of coordinates from the channel axis and axes after it.

For example, suppose the input tensor has dimensions [10,20,30,40] and the channel axis is 1. Let [n,c,h,w] denote an input coordinate. For ScaleMode::kCHANNEL, the scale, shift, and power weights are indexed by c. For ScaleMode::kELEMENTWISE, the scale, shift, and power weights are indexed by [c,h,w].

See [addScaleNd()]

Trait Implementations§

Source§

impl AsLayer for IScaleLayer

Source§

fn as_layer(&self) -> &ILayer

Source§

fn as_layer_pin_mut(&mut self) -> Pin<&mut ILayer>

Source§

impl AsLayerTyped for IScaleLayer

Source§

const TYPE: LayerType = LayerType::kSCALE

Source§

impl AsRef<ILayer> for IScaleLayer

Source§

fn as_ref(self: &IScaleLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl ExternType for IScaleLayer

Source§

type Id = (n, v, i, n, f, e, r, _1, (), I, S, c, a, l, e, L, a, y, e, r)

A type-level representation of the type’s C++ namespace and type name. Read more
Source§

type Kind = Opaque

Source§

impl MakeCppStorage for IScaleLayer

Source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut IScaleLayer

Allocates heap space for this type in C++ and return a pointer to that space, but do not initialize that space (i.e. do not yet call a constructor). Read more
Source§

unsafe fn free_uninitialized_cpp_storage(arg0: *mut IScaleLayer)

Frees a C++ allocation which has not yet had a constructor called. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.