cubecl_matmul/components/tile/
io.rs

1use cubecl::prelude::*;
2use cubecl_core as cubecl;
3
4use cubecl_std::CubeOption;
5
6use crate::components::tile::StridedTile;
7
8/// Kind (family) of the tiles returned by a stage and ingested by a tile matmul reader
9pub trait TileKind<IO: SliceVisibility = ReadOnly>: CubeType + Send + Sync + 'static {
10    /// Concrete tile instantiated with the element type
11    type Tile<E: Numeric>: CubeType;
12}
13
14/// Tile is a slice of memory with a stride
15#[derive(CubeType)]
16pub struct Strided {}
17
18/// Tile is a single value that gets filled in everywhere
19#[derive(CubeType)]
20pub struct Filled {}
21
22impl<IO: SliceVisibility> TileKind<IO> for Strided {
23    type Tile<E: Numeric> = StridedTile<E, IO>;
24}
25
26impl TileKind<ReadOnly> for Filled {
27    type Tile<E: Numeric> = E;
28}
29
30impl<Inner: TileKind<IO>, IO: SliceVisibility> TileKind<IO> for CubeOption<Inner> {
31    type Tile<E: Numeric> = CubeOption<Inner::Tile<E>>;
32}
33
34pub type Tile<K, E> = <K as TileKind>::Tile<E>;
35pub type TileMut<K, E> = <K as TileKind<ReadWrite>>::Tile<E>;