pub struct SoftmaxOperation<'c> { /* private fields */ }
Expand description
A softmax
operation. Softmax operator.
linalg.softmax computes a numerically stable version of softmax.
For a given input tensor and a specified dimension d
, compute:
- the max
m
along that dimensiond
- f(x) = exp(x - m)
- sum f(x) along dimension d to get l(x).
- compute the final result f(x) / l(x).
This is an aggregate linalg operation that further reduces to a small DAG of structured operations.
Warning: Regarding the tiling capabilities, the implementation doesn’t check that the provided dimensions make sense. This is the responsability of the transformation calling the tiling to ensure that the provided sizes for each dimension make sense with respect to the semantic of softmax.
Implementations§
source§impl<'c> SoftmaxOperation<'c>
impl<'c> SoftmaxOperation<'c>
sourcepub fn as_operation(&self) -> &Operation<'c>
pub fn as_operation(&self) -> &Operation<'c>
Returns a generic operation.
sourcepub fn builder(
context: &'c Context,
location: Location<'c>
) -> SoftmaxOperationBuilder<'c, Unset, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> SoftmaxOperationBuilder<'c, Unset, Unset, Unset, Unset>
Creates a builder.
pub fn result(&self) -> impl Iterator<Item = OperationResult<'c, '_>>
pub fn input(&self) -> Result<Value<'c, '_>, Error>
pub fn output(&self) -> Result<Value<'c, '_>, Error>
pub fn dimension(&self) -> Result<IntegerAttribute<'c>, Error>
pub fn set_dimension(&mut self, value: IntegerAttribute<'c>)
Trait Implementations§
source§impl<'c> From<SoftmaxOperation<'c>> for Operation<'c>
impl<'c> From<SoftmaxOperation<'c>> for Operation<'c>
source§fn from(operation: SoftmaxOperation<'c>) -> Self
fn from(operation: SoftmaxOperation<'c>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<'c> RefUnwindSafe for SoftmaxOperation<'c>
impl<'c> !Send for SoftmaxOperation<'c>
impl<'c> !Sync for SoftmaxOperation<'c>
impl<'c> Unpin for SoftmaxOperation<'c>
impl<'c> UnwindSafe for SoftmaxOperation<'c>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more