pub struct GemmWithArgmax<T: TropicalWithArgmax<Index = u32>> {
pub values: Vec<T>,
pub argmax: Vec<u32>,
pub m: usize,
pub n: usize,
pub ld: usize,
}Expand description
Result of GEMM with argmax tracking.
For each element C[i,j], tracks which k index produced the optimal value: C[i,j] = ⊕_{k} A[i,k] ⊗ B[k,j] argmax[i,j] = argmax_k (A[i,k] ⊗ B[k,j])
Fields§
§values: Vec<T>The result matrix values.
argmax: Vec<u32>The argmax indices for each element.
m: usizeNumber of rows in the result.
n: usizeNumber of columns in the result.
ld: usizeLeading dimension (stride between rows).
Implementations§
Source§impl<T: TropicalWithArgmax<Index = u32>> GemmWithArgmax<T>
impl<T: TropicalWithArgmax<Index = u32>> GemmWithArgmax<T>
Sourcepub fn with_ld(m: usize, n: usize, ld: usize) -> Self
pub fn with_ld(m: usize, n: usize, ld: usize) -> Self
Create a new result container with specified leading dimension.
Sourcepub fn get_argmax(&self, i: usize, j: usize) -> u32
pub fn get_argmax(&self, i: usize, j: usize) -> u32
Get argmax at (i, j).
Sourcepub fn get_mut(&mut self, i: usize, j: usize) -> &mut T
pub fn get_mut(&mut self, i: usize, j: usize) -> &mut T
Get mutable reference to value at (i, j).
Sourcepub fn get_argmax_mut(&mut self, i: usize, j: usize) -> &mut u32
pub fn get_argmax_mut(&mut self, i: usize, j: usize) -> &mut u32
Get mutable reference to argmax at (i, j).
Sourcepub fn as_mut_ptrs(&mut self) -> (*mut T, *mut u32)
pub fn as_mut_ptrs(&mut self) -> (*mut T, *mut u32)
Get raw pointers to the data.
Sourcepub fn argmax_slice(&self) -> &[u32]
pub fn argmax_slice(&self) -> &[u32]
Get the argmax array as a slice.
This is useful for backward pass computation.
Sourcepub fn values_slice(&self) -> &[T]
pub fn values_slice(&self) -> &[T]
Get the values array as a slice.
Trait Implementations§
Source§impl<T: Clone + TropicalWithArgmax<Index = u32>> Clone for GemmWithArgmax<T>
impl<T: Clone + TropicalWithArgmax<Index = u32>> Clone for GemmWithArgmax<T>
Source§fn clone(&self) -> GemmWithArgmax<T>
fn clone(&self) -> GemmWithArgmax<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for GemmWithArgmax<T>
impl<T> RefUnwindSafe for GemmWithArgmax<T>where
T: RefUnwindSafe,
impl<T> Send for GemmWithArgmax<T>
impl<T> Sync for GemmWithArgmax<T>
impl<T> Unpin for GemmWithArgmax<T>where
T: Unpin,
impl<T> UnwindSafe for GemmWithArgmax<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more