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
impl IScaleLayer
Sourcepub fn setMode(self: Pin<&mut IScaleLayer>, mode: ScaleMode)
pub fn setMode(self: Pin<&mut IScaleLayer>, mode: ScaleMode)
Set the scale mode.
See [getMode()]
Sourcepub fn getMode(self: &IScaleLayer) -> ScaleMode
pub fn getMode(self: &IScaleLayer) -> ScaleMode
Get the scale mode.
See [setMode()]
Sourcepub fn setShift(self: Pin<&mut IScaleLayer>, shift: Weights)
pub fn setShift(self: Pin<&mut IScaleLayer>, shift: Weights)
Set the shift value.
See [getShift()]
Sourcepub fn getShift(self: &IScaleLayer) -> Weights
pub fn getShift(self: &IScaleLayer) -> Weights
Get the shift value.
See [setShift()]
Sourcepub fn setScale(self: Pin<&mut IScaleLayer>, scale: Weights)
pub fn setScale(self: Pin<&mut IScaleLayer>, scale: Weights)
Set the scale value.
See [getScale()]
Sourcepub fn getScale(self: &IScaleLayer) -> Weights
pub fn getScale(self: &IScaleLayer) -> Weights
Get the scale value.
See [setScale()]
Sourcepub fn setPower(self: Pin<&mut IScaleLayer>, power: Weights)
pub fn setPower(self: Pin<&mut IScaleLayer>, power: Weights)
Set the power value.
See [getPower()]
Sourcepub fn getPower(self: &IScaleLayer) -> Weights
pub fn getPower(self: &IScaleLayer) -> Weights
Get the power value.
See [setPower()]
Sourcepub fn getChannelAxis(self: &IScaleLayer) -> i32
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()]
Sourcepub fn setChannelAxis(self: Pin<&mut IScaleLayer>, channelAxis: i32)
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()]