SparseMFMAOperation

Struct SparseMFMAOperation 

Source
pub struct SparseMFMAOperation<'c> { /* private fields */ }
Expand description

A sparse_mfma operation. MLIR wrapper for CDNA sparse mfma (smfmac) instructions.

The amdgpu.sparse_mfma op is an MLIR wrapper around intrinsics for various smfmac instructions in the AMDGPU architecture, which perform matrix multiply-accumulate operations using 2:4 structured sparsity on matrix A with dense matrices B, C, and D.

On gfx942, smfmac intrinsics support:

  • M=N=16, K=32 and M=N=32, K=16 for f16 and bf16 sources
  • M=N=16, K=64 and M=N=32, K=32 for i8 and fp8 sources

On gfx950, smfmac intrinsics additionally support:

  • M=N=16, K=64 and M=N=32, K=32 for f16 and bf16 sources
  • M=N=16, K=128 and M=N=32, K=64 for i8 and fp8 sources

The sparseIdx parameter contains packed indices identifying the positions of non-zero elements in the 2:4 sparse matrix A. For 16-bit source data, use vector<4xi8> (four 8-bit indices). For 8-bit source data, use vector<2xi16> (two 16-bit indices).

The cbsz and abid parameters are repurposed to select the index set. If cbsz == 0, then abid[1:0] selects which index set to use. If cbsz != 0, then the very first is selected.

Example:

  %0 = amdgpu.sparse_mfma 16x16x32 %matA * %matB + %matC sparse(%idx : vector<4xi8>)
    : vector<4xf16>, vector<8xf16>, vector<4xf32>

  %1 = amdgpu.sparse_mfma 16x16x64 %matA * %matB + %matC sparse(%idx : vector<2xi16>)
    : vector<8xi8>, vector<16xi8>, vector<4xi32>

  %2 = amdgpu.sparse_mfma 16x16x64 %matA * %matB + %matC sparse(%idx : vector<2xi16>)
    { cbsz = 0 : i32, abid = 1 : i32 }
    : vector<8xf8E4M3FNUZ>, vector<16xf8E4M3FNUZ>, vector<4xf32>

Implementations§

Source§

impl<'c> SparseMFMAOperation<'c>

Source

pub fn name() -> &'static str

Returns a name.

Source

pub fn as_operation(&self) -> &Operation<'c>

Returns a generic operation.

Source

pub fn builder( context: &'c Context, location: Location<'c>, ) -> SparseMFMAOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset, Unset, Unset, Unset>

Creates a builder.

Source

pub fn dest_d(&self) -> Result<OperationResult<'c, '_>, Error>

Source

pub fn source_a(&self) -> Result<Value<'c, '_>, Error>

Source

pub fn source_b(&self) -> Result<Value<'c, '_>, Error>

Source

pub fn dest_c(&self) -> Result<Value<'c, '_>, Error>

Source

pub fn sparse_idx(&self) -> Result<Value<'c, '_>, Error>

Source

pub fn m(&self) -> Result<IntegerAttribute<'c>, Error>

Source

pub fn set_m(&mut self, value: IntegerAttribute<'c>)

Source

pub fn n(&self) -> Result<IntegerAttribute<'c>, Error>

Source

pub fn set_n(&mut self, value: IntegerAttribute<'c>)

Source

pub fn k(&self) -> Result<IntegerAttribute<'c>, Error>

Source

pub fn set_k(&mut self, value: IntegerAttribute<'c>)

Source

pub fn cbsz(&self) -> Result<IntegerAttribute<'c>, Error>

Source

pub fn set_cbsz(&mut self, value: IntegerAttribute<'c>)

Source

pub fn remove_cbsz(&mut self) -> Result<(), Error>

Source

pub fn abid(&self) -> Result<IntegerAttribute<'c>, Error>

Source

pub fn set_abid(&mut self, value: IntegerAttribute<'c>)

Source

pub fn remove_abid(&mut self) -> Result<(), Error>

Trait Implementations§

Source§

impl<'c> Clone for SparseMFMAOperation<'c>

Source§

fn clone(&self) -> SparseMFMAOperation<'c>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'c> Debug for SparseMFMAOperation<'c>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'b> From<SparseMFMAOperation<'b>> for AmdgpuDialectOperation<'b>

Source§

fn from(op: SparseMFMAOperation<'b>) -> Self

Converts to this type from the input type.
Source§

impl<'c> From<SparseMFMAOperation<'c>> for Operation<'c>

Source§

fn from(operation: SparseMFMAOperation<'c>) -> Self

Converts to this type from the input type.
Source§

impl<'c> PartialEq for SparseMFMAOperation<'c>

Source§

fn eq(&self, other: &SparseMFMAOperation<'c>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'c> TryFrom<Operation<'c>> for SparseMFMAOperation<'c>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(operation: Operation<'c>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'c> Eq for SparseMFMAOperation<'c>

Source§

impl<'c> StructuralPartialEq for SparseMFMAOperation<'c>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.