pub struct Matrix<C: CubeType> { /* private fields */ }
Expand description
A matrix represent a 2D grid of numbers.
They can either be in a row major or a column major format.
Implementations§
Source§impl<C: CubePrimitive> Matrix<C>
impl<C: CubePrimitive> Matrix<C>
Sourcepub unsafe fn uninitialized(
ident: MatrixIdent,
m: u32,
n: u32,
k: u32,
layout: MatrixLayout,
) -> Self
pub unsafe fn uninitialized( ident: MatrixIdent, m: u32, n: u32, k: u32, layout: MatrixLayout, ) -> Self
Create a new uninitialized matrix that is going to be used in the matrix-multiply and accumulate function.
§Safety
Must be initialized with load
or fill
before use. Using it without initialization is
undefined behaviour on CUDA, and completely invalid on Vulkan.
You have to declare the shape used for the execution. The shape of the current matrix is determined using the MatrixIdent.
- MatrixIdent::A Shape => (M, K)
- MatrixIdent::B Shape => (K, N)
- MatrixIdent::Accumulator Shape => (M, N)
Not all shapes are supported, and the permitted shapes depend on the element type.
Refer to nvidia documentation.
Sourcepub fn from_value(
ident: MatrixIdent,
m: u32,
n: u32,
k: u32,
layout: MatrixLayout,
value: C,
) -> Self
pub fn from_value( ident: MatrixIdent, m: u32, n: u32, k: u32, layout: MatrixLayout, value: C, ) -> Self
Create a new matrix that is going to be used in the
matrix-multiply and accumulate function and is filled with value
.
You have to declare the shape used for the execution. The shape of the current matrix is determined using the MatrixIdent.
- MatrixIdent::A Shape => (M, K)
- MatrixIdent::B Shape => (K, N)
- MatrixIdent::Accumulator Shape => (M, N)
Not all shapes are supported, and the permitted shapes depend on the element type.
Refer to nvidia documentation.
Sourcepub fn from_slice(
ident: MatrixIdent,
m: u32,
n: u32,
k: u32,
layout: MatrixLayout,
value: &Slice<'_, C>,
stride: u32,
) -> Self
pub fn from_slice( ident: MatrixIdent, m: u32, n: u32, k: u32, layout: MatrixLayout, value: &Slice<'_, C>, stride: u32, ) -> Self
Create a new matrix that is going to be used in the
matrix-multiply and accumulate function and is loaded from value
with stride
.
You have to declare the shape used for the execution. The shape of the current matrix is determined using the MatrixIdent.
- MatrixIdent::A Shape => (M, K)
- MatrixIdent::B Shape => (K, N)
- MatrixIdent::Accumulator Shape => (M, N)
Not all shapes are supported, and the permitted shapes depend on the element type.
Refer to nvidia documentation.
pub fn __expand_uninitialized( context: &mut CubeContext, ident: MatrixIdent, m: ExpandElementTyped<u32>, n: ExpandElementTyped<u32>, k: ExpandElementTyped<u32>, layout: MatrixLayout, ) -> MatrixExpand
pub fn __expand_from_value( context: &mut CubeContext, ident: MatrixIdent, m: ExpandElementTyped<u32>, n: ExpandElementTyped<u32>, k: ExpandElementTyped<u32>, layout: MatrixLayout, value: ExpandElementTyped<C>, ) -> MatrixExpand
pub fn __expand_from_slice( context: &mut CubeContext, ident: MatrixIdent, m: ExpandElementTyped<u32>, n: ExpandElementTyped<u32>, k: ExpandElementTyped<u32>, layout: MatrixLayout, value: ExpandElementTyped<Slice<'static, C>>, stride: ExpandElementTyped<u32>, ) -> MatrixExpand
Trait Implementations§
Source§impl<C: CubeType> CubeType for Matrix<C>
impl<C: CubeType> CubeType for Matrix<C>
type ExpandType = MatrixExpand
Source§fn init(context: &mut CubeContext, expand: Self::ExpandType) -> Self::ExpandType
fn init(context: &mut CubeContext, expand: Self::ExpandType) -> Self::ExpandType
Source§impl<C: CubeType> IntoRuntime for Matrix<C>
impl<C: CubeType> IntoRuntime for Matrix<C>
fn __expand_runtime_method(self, _context: &mut CubeContext) -> MatrixExpand
Source§fn runtime(self) -> Self
fn runtime(self) -> Self
impl<C: Copy + CubeType> Copy for Matrix<C>
Auto Trait Implementations§
impl<C> Freeze for Matrix<C>
impl<C> RefUnwindSafe for Matrix<C>where
C: RefUnwindSafe,
impl<C> Send for Matrix<C>where
C: Send,
impl<C> Sync for Matrix<C>where
C: Sync,
impl<C> Unpin for Matrix<C>where
C: Unpin,
impl<C> UnwindSafe for Matrix<C>where
C: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)