Skip to main content

IScatterLayer

Struct IScatterLayer 

Source
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

Source

pub fn setMode(self: Pin<&mut IScatterLayer>, mode: ScatterMode)

Set the scatter mode.

See [getMode()]

Source

pub fn getMode(self: &IScatterLayer) -> ScatterMode

Get the scatter mode.

See [setMode()]

Source

pub fn setAxis(self: Pin<&mut IScatterLayer>, axis: i32)

Set the axis used by ScatterMode::kELEMENTS.

The axis defaults to 0.

Source

pub fn getAxis(self: &IScatterLayer) -> i32

Get the axis.

Trait Implementations§

Source§

impl AsLayer for IScatterLayer

Source§

fn as_layer(&self) -> &ILayer

Source§

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

Source§

impl AsLayerTyped for IScatterLayer

Source§

const TYPE: LayerType = LayerType::kSCATTER

Source§

impl AsRef<ILayer> for IScatterLayer

Source§

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

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

impl ExternType for IScatterLayer

Source§

type Id = (n, v, i, n, f, e, r, _1, (), I, S, c, a, t, t, e, r, 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 IScatterLayer

Source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut IScatterLayer

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 IScatterLayer)

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.