Skip to main content

Tile

Enum Tile 

Source
pub enum Tile<N: Numeric, Sc: TileScope, IO: SliceVisibility> {
    SharedMemory(SharedTile<N, IO>),
    Cmma(CmmaTile<N>),
    Mma(MmaTile<N>),
    Register(RegisterTile<N>),
    PlaneVec(PlaneVecTile<N>),
    Interleaved(InterleavedTile<N>),
    Unit(UnitTile<N>),
    WhiteboxFragment(WhiteboxFragment<N>),
    Bounce(BounceTile<N>),
    Broadcasted(Value<N>),
    None,
    _Phantom(ScopeMarker<Sc>),
}

Variants§

§

SharedMemory(SharedTile<N, IO>)

§

Cmma(CmmaTile<N>)

§

Mma(MmaTile<N>)

§

Register(RegisterTile<N>)

§

PlaneVec(PlaneVecTile<N>)

§

Interleaved(InterleavedTile<N>)

§

Unit(UnitTile<N>)

Each unit holds a full row-major copy of the tile in registers. Only valid when Sc = Unit.

§

WhiteboxFragment(WhiteboxFragment<N>)

The tile is fragmented across plane units, with the layout exposed. Only valid when Sc = Plane.

§

Bounce(BounceTile<N>)

Bundles a cmma fragment, an smem scratch slice, and a WhiteboxFragment view. From the caller’s perspective it is a single tile; the smem round-trip is internal to ops dispatch. Only valid when Sc = Plane.

§

Broadcasted(Value<N>)

§

None

§

_Phantom(ScopeMarker<Sc>)

Implementations§

Source§

impl<N: Numeric, Sc: TileScope, IO: SliceVisibility> Tile<N, Sc, IO>

Source

pub fn new_SharedMemory(_0: SharedTile<N, IO>) -> Self

Source

pub fn __expand_new_SharedMemory( _: &mut Scope, _0: <SharedTile<N, IO> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Cmma(_0: CmmaTile<N>) -> Self

Source

pub fn __expand_new_Cmma( _: &mut Scope, _0: <CmmaTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Mma(_0: MmaTile<N>) -> Self

Source

pub fn __expand_new_Mma( _: &mut Scope, _0: <MmaTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Register(_0: RegisterTile<N>) -> Self

Source

pub fn __expand_new_Register( _: &mut Scope, _0: <RegisterTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_PlaneVec(_0: PlaneVecTile<N>) -> Self

Source

pub fn __expand_new_PlaneVec( _: &mut Scope, _0: <PlaneVecTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Interleaved(_0: InterleavedTile<N>) -> Self

Source

pub fn __expand_new_Interleaved( _: &mut Scope, _0: <InterleavedTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Unit(_0: UnitTile<N>) -> Self

Source

pub fn __expand_new_Unit( _: &mut Scope, _0: <UnitTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_WhiteboxFragment(_0: WhiteboxFragment<N>) -> Self

Source

pub fn __expand_new_WhiteboxFragment( _: &mut Scope, _0: <WhiteboxFragment<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Bounce(_0: BounceTile<N>) -> Self

Source

pub fn __expand_new_Bounce( _: &mut Scope, _0: <BounceTile<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_Broadcasted(_0: Value<N>) -> Self

Source

pub fn __expand_new_Broadcasted( _: &mut Scope, _0: <Value<N> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source

pub fn new_None() -> Self

Source

pub fn __expand_new_None(_: &mut Scope) -> TileExpand<N, Sc, IO>

Source

pub fn new__Phantom(_0: ScopeMarker<Sc>) -> Self

Source

pub fn __expand_new__Phantom( _: &mut Scope, _0: <ScopeMarker<Sc> as CubeType>::ExpandType, ) -> TileExpand<N, Sc, IO>

Source§

impl<N: Numeric, Sc: TileScope> Tile<N, Sc, ReadWrite>

Source

pub fn mma<L: Numeric, R: Numeric>( &mut self, lhs: &Tile<L, Sc, ReadWrite>, rhs: &Tile<R, Sc, ReadWrite>, )

Executes lhs · rhs, accumulating the result into self.

Source

pub fn __expand_mma<L: Numeric, R: Numeric>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, lhs: <Tile<L, Sc, ReadWrite> as CubeType>::ExpandType, rhs: <Tile<R, Sc, ReadWrite> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

impl<E: Float> Tile<E, Plane, ReadWrite>

Source

pub fn row_max(&self, acc: &mut RowWise<E>, base: &RowWise<E>)

Source

pub fn row_sum(&self, acc: &mut RowWise<E>)

Source

pub fn exp_diff(&mut self, rowwise: &RowWise<E>)

Source

pub fn rowwise_scale(&mut self, scale: &RowWise<E>)

Source

pub fn __expand_row_max( scope: &mut Scope, this: <Self as CubeType>::ExpandType, acc: <RowWise<E> as CubeType>::ExpandType, base: <RowWise<E> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source

pub fn __expand_row_sum( scope: &mut Scope, this: <Self as CubeType>::ExpandType, acc: <RowWise<E> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source

pub fn __expand_exp_diff( scope: &mut Scope, this: <Self as CubeType>::ExpandType, rowwise: <RowWise<E> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source

pub fn __expand_rowwise_scale( scope: &mut Scope, this: <Self as CubeType>::ExpandType, scale: <RowWise<E> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

impl<N: Numeric, Sc: TileScope> Tile<N, Sc, ReadWrite>

Source

pub fn copy_from<SE: Numeric, SS: Size, L: Numeric, R: Numeric, A: Numeric, SIO: SliceVisibility>( &mut self, source: &Tile<SE, Sc, SIO>, ident: StageIdent, )

Copies data from source into self.

SS is the vector size of the shared memory tile involved in the copy (whether that’s the source on a load, or the destination on a write). L/R/A are the matrix-level numeric types needed by the MMA readers/writers — they are unused on non-MMA paths.

Source

pub fn __expand_copy_from<SE: Numeric, SS: Size, L: Numeric, R: Numeric, A: Numeric, SIO: SliceVisibility>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, source: <Tile<SE, Sc, SIO> as CubeType>::ExpandType, ident: StageIdent, ) -> <() as CubeType>::ExpandType

Source§

impl<E: Float> Tile<E, Plane, ReadWrite>

Source

pub fn scale_and_mask<M: Mask>(&mut self, scale: E, mask: &M)

Multiplies each element by scale and adds -inf at masked positions. scale is a scalar; mask.should_mask((r, c)) is element-wise.

Source

pub fn fill_zero(&mut self)

Zeros every element in the tile.

Source

pub fn __expand_scale_and_mask<M: Mask>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, scale: <E as CubeType>::ExpandType, mask: <M as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source

pub fn __expand_fill_zero( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

impl<N: Numeric, Sc: TileScope> Tile<N, Sc, ReadWrite>

Source

pub fn load_mask_from_strided_tile<E: Numeric, ES: Size>( &mut self, tile: &StridedTile<E, ES>, )

Loads the data from an external strided tile into the inner storage of a Tile::Unit or Tile::WhiteboxFragment. Used to materialize a mask fragment.

Source

pub fn __expand_load_mask_from_strided_tile<E: Numeric, ES: Size>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, tile: <StridedTile<E, ES> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source§

impl<Acc: Float> Tile<Acc, Plane, ReadWrite>

Source

pub fn softmax<Lhs: Float, M: Mask>( &mut self, mask: &M, softmaxed_tile: &mut Tile<Lhs, Plane, ReadWrite>, state: &mut (RowWise<Acc>, RowWise<Acc>), head_dim_factor: Acc, ) -> RowWise<Acc>

Online softmax update over a single attention tile, fused with the precision-cast write into a value-matmul lhs tile. Dispatches on the score variant — each variant owns the algorithm best suited to its storage and is polymorphic in the destination: a Bounce score can be written into any compatible softmaxed tile (Bounce, fragment, …), not just another Bounce.

Returns the per-row scaling factor α_i = e^(m_old - m_new) used by the caller to rescale running output accumulators.

Source

pub fn scale_mul<SM: Float>(&mut self, scale: &RowWise<SM>)

Multiplies each row of self by the corresponding scale[r]. The Bounce arm round-trips through smem so the cmma fragment is current for the next mma; the others operate in place on their native storage.

Source

pub fn scale_div<SM: Float>(&mut self, running_state_l: &RowWise<SM>)

Divides each row of self by the corresponding running_state_l[r], guarding against zero (a fully-masked row stays zero).

Source

pub fn write_results<DE: Float, DS: Size>( &self, dest: &mut Tile<DE, Plane, ReadWrite>, )

Copies self into dest (a stage-side strided/shared tile in the caller’s downstream write path).

Source

pub fn __expand_softmax<Lhs: Float, M: Mask>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, mask: <M as CubeType>::ExpandType, softmaxed_tile: <Tile<Lhs, Plane, ReadWrite> as CubeType>::ExpandType, state: <(RowWise<Acc>, RowWise<Acc>) as CubeType>::ExpandType, head_dim_factor: <Acc as CubeType>::ExpandType, ) -> <RowWise<Acc> as CubeType>::ExpandType

Source

pub fn __expand_scale_mul<SM: Float>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, scale: <RowWise<SM> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source

pub fn __expand_scale_div<SM: Float>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, running_state_l: <RowWise<SM> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Source

pub fn __expand_write_results<DE: Float, DS: Size>( scope: &mut Scope, this: <Self as CubeType>::ExpandType, dest: <Tile<DE, Plane, ReadWrite> as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType

Trait Implementations§

Source§

impl<N: Numeric, Sc: TileScope, IO: SliceVisibility> CubeDebug for Tile<N, Sc, IO>

Source§

fn set_debug_name(&self, scope: &mut Scope, name: &'static str)

Set the debug name of this type’s expansion. Should do nothing for types that don’t appear at runtime
Source§

impl<N: Numeric, Sc: TileScope, IO: SliceVisibility> CubeType for Tile<N, Sc, IO>

Source§

type ExpandType = TileExpand<N, Sc, IO>

Source§

impl<E: Numeric, Sc: TileScope, IO: SliceVisibility> Mask for Tile<E, Sc, IO>

Source§

fn should_mask(&self, local_pos: Coords2d) -> bool

Source§

fn __expand_should_mask( scope: &mut Scope, this: <Self as CubeType>::ExpandType, local_pos: <Coords2d as CubeType>::ExpandType, ) -> <bool as CubeType>::ExpandType

Auto Trait Implementations§

§

impl<N, Sc, IO> Freeze for Tile<N, Sc, IO>
where N: Freeze,

§

impl<N, Sc, IO> RefUnwindSafe for Tile<N, Sc, IO>

§

impl<N, Sc, IO> Send for Tile<N, Sc, IO>

§

impl<N, Sc, IO> Sync for Tile<N, Sc, IO>

§

impl<N, Sc, IO> Unpin for Tile<N, Sc, IO>
where N: Unpin, Sc: Unpin, IO: Unpin,

§

impl<N, Sc, IO> UnsafeUnpin for Tile<N, Sc, IO>
where N: UnsafeUnpin,

§

impl<N, Sc, IO> UnwindSafe for Tile<N, Sc, IO>
where N: UnwindSafe, Sc: UnwindSafe, IO: UnwindSafe,

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> 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> IntoComptime for T

Source§

fn comptime(self) -> Self

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.