Skip to main content

ICumulativeLayer

Struct ICumulativeLayer 

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

ICumulativeLayer

Layer that represents a cumulative operation across a tensor.

It computes successive reductions across an axis of a tensor. The output always has the same shape as the input.

If the reduction operation is summation, then this is also known as prefix-sum or cumulative sum.

The operation has forward vs. reverse variants, and inclusive vs. exclusive variants.

For example, let the input be a vector x of length n and the output be vector y. Then y[j] = sum(x[…]) where … denotes a sequence of indices from this table:

| forward | reverse –––––|———–| ——— inclusive | 0..j | j..n-1 exclusive | 0..j-1 | j+1..n-1

For multidimensional tensors, the reductions apply across a specified axis. For example, given a 2D input, a forward inclusive cumulative operation across axis 0 generates cumulative sums within each column.

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

Implementations§

Source§

impl ICumulativeLayer

Source

pub fn setOperation( self: Pin<&mut ICumulativeLayer>, op: CumulativeOperation, ) -> bool

Set the cumulative operation for the layer.

  • op The reduction operation to be performed

Whether op is valid and the operation successfully set

See [getOperation()], CumulativeOperation

Source

pub fn getOperation(self: &ICumulativeLayer) -> CumulativeOperation

Get the cumulative operation for the layer.

The reduction operation to be performed

See [setOperation()], CumulativeOperation

Source

pub fn setExclusive(self: Pin<&mut ICumulativeLayer>, exclusive: bool)

Set whether it is an exclusive accumulation or inclusive accumulation.

  • exclusive Whether the operation will exclude the element at the current index

See [getExclusive]

Source

pub fn getExclusive(self: &ICumulativeLayer) -> bool

Get whether it is exclusive accumulation or inclusive accumulation.

Whether the operation will exclude the element at the current index

See [setExclusive]

Source

pub fn setReverse(self: Pin<&mut ICumulativeLayer>, reverse: bool)

Specify whether the cumulative operation should be applied backward.

  • reverse Whether the cumulative will run in the reverse direction from the last element

See [getReverse]

Source

pub fn getReverse(self: &ICumulativeLayer) -> bool

Get the boolean that specifies whether the cumulative operation should be applied backward.

Whether the cumulative will run in the reverse direction from the last element

See [setReverse]

Trait Implementations§

Source§

impl AsLayer for ICumulativeLayer

Source§

fn as_layer(&self) -> &ILayer

Source§

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

Source§

impl AsLayerTyped for ICumulativeLayer

Source§

const TYPE: LayerType = LayerType::kCUMULATIVE

Source§

impl AsRef<ILayer> for ICumulativeLayer

Source§

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

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

impl ExternType for ICumulativeLayer

Source§

type Id = (n, v, i, n, f, e, r, _1, (), I, C, u, m, u, l, a, t, i, v, 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 ICumulativeLayer

Source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut ICumulativeLayer

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

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.