pub struct IScatterLayer { /* private fields */ }Expand description
IScatterLayer
A scatter layer in a network definition. Supports several kinds of scattering.
The Scatter layer has three input tensors: Data, Indices, and Updates, one output tensor Output, and a scatter mode. When kELEMENT mode is used an optional axis parameter is available.
- Data is a tensor of rank r >= 1 that stores the values to be duplicated in Output.
- Indices is a tensor of rank q that determines which locations in Output to write new values to. Constraints on the rank q depend on the mode: ScatterMode::kND: q >= 1 ScatterMode::kELEMENT: q must be the same as r
- Updates is a tensor of rank s >= 1 that provides the data to write to Output specified by its corresponding location in Indices. Constraints on the rank of Updates depend on the mode: ScatterMode::kND: s = r + q - shape(Indices)[-1] - 1 Scattermode::kELEMENT: s = q = r
- Output is a tensor with the same dimensions as Data that stores the resulting values of the transformation. It must not be a shape tensor. The types of Data, Update, and Output shall be the same, and Indices shall be of type DataType::kINT32 or DataType::kINT64.
The output is computed by copying the data, and then updating elements of it based on indices. How Indices are interpreted depends upon the ScatterMode.
ScatterMode::kND
The indices are interpreted as a tensor of rank q-1 of indexing tuples. The axis parameter is ignored.
Given that data dims are {d_0,…,d_{r-1}} and indices dims are {i_0,…,i_{q-1}}, define k = indices[q-1], it follows that updates dims are {i_0,…,i_{q-2},d_k,…,d_{r-1}} The updating can be computed by: foreach slice in indices[i_0,…,i_{q-2}] output[indicesslice] = updatesslice
ScatterMode::kELEMENT
Here “axis” denotes the result of getAxis().
For each element X of indices: Let J denote a sequence for the subscripts of X Let K = sequence J with element [axis] replaced by X output[K] = updates[J]
For example, if indices has dimensions [N,C,H,W] and axis is 2, then the updates happen as:
for n in [0,n) for c in [0,n) for h in [0,n) for w in [0,n) output[n,c,indices[n,c,h,w],w] = updates[n,c,h,w]
Writes to the same output element cause undefined behavior.
Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.
Implementations§
Source§impl IScatterLayer
impl IScatterLayer
Sourcepub fn setMode(self: Pin<&mut IScatterLayer>, mode: ScatterMode)
pub fn setMode(self: Pin<&mut IScatterLayer>, mode: ScatterMode)
Set the scatter mode.
See [getMode()]
Sourcepub fn getMode(self: &IScatterLayer) -> ScatterMode
pub fn getMode(self: &IScatterLayer) -> ScatterMode
Get the scatter mode.
See [setMode()]
Sourcepub fn setAxis(self: Pin<&mut IScatterLayer>, axis: i32)
pub fn setAxis(self: Pin<&mut IScatterLayer>, axis: i32)
Set the axis used by ScatterMode::kELEMENTS.
The axis defaults to 0.
Sourcepub fn getAxis(self: &IScatterLayer) -> i32
pub fn getAxis(self: &IScatterLayer) -> i32
Get the axis.