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
impl ICumulativeLayer
Sourcepub fn setOperation(
self: Pin<&mut ICumulativeLayer>,
op: CumulativeOperation,
) -> bool
pub fn setOperation( self: Pin<&mut ICumulativeLayer>, op: CumulativeOperation, ) -> bool
Set the cumulative operation for the layer.
opThe reduction operation to be performed
Whether op is valid and the operation successfully set
See [getOperation()], CumulativeOperation
Sourcepub fn getOperation(self: &ICumulativeLayer) -> CumulativeOperation
pub fn getOperation(self: &ICumulativeLayer) -> CumulativeOperation
Get the cumulative operation for the layer.
The reduction operation to be performed
See [setOperation()], CumulativeOperation
Sourcepub fn setExclusive(self: Pin<&mut ICumulativeLayer>, exclusive: bool)
pub fn setExclusive(self: Pin<&mut ICumulativeLayer>, exclusive: bool)
Set whether it is an exclusive accumulation or inclusive accumulation.
exclusiveWhether the operation will exclude the element at the current index
See [getExclusive]
Sourcepub fn getExclusive(self: &ICumulativeLayer) -> bool
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]
Sourcepub fn setReverse(self: Pin<&mut ICumulativeLayer>, reverse: bool)
pub fn setReverse(self: Pin<&mut ICumulativeLayer>, reverse: bool)
Specify whether the cumulative operation should be applied backward.
reverseWhether the cumulative will run in the reverse direction from the last element
See [getReverse]
Sourcepub fn getReverse(self: &ICumulativeLayer) -> bool
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]