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.