#[non_exhaustive]pub struct TiledLayout {
pub tile_shape: Vec<u64>,
pub outer_layout: u8,
pub inner_layout: u8,
pub outer_strides: Option<OuterStrides>,
pub inner_strides: Option<InnerStrides>,
pub inner_tiled: Option<Box<TiledLayout>>,
}Expand description
Descriptor for the tiled / blocked layout.
A tiled layout partitions the tensor index space into uniform rectangular
tiles. Tile ordering is controlled by outer_layout; element ordering
within a tile is controlled by inner_layout. Both accept tags for
row-major (0x01), column-major (0x02), strided (0x03), or, for the
inner layout only, a recursively nested tiled layout (0x04).
Recursive tiling is useful for hierarchical GEMM blocking (e.g., 128×128
L2 tiles subdivided into 32×32 L1 tiles). Maximum nesting depth is
MAX_TILED_DEPTH (8 levels).
§Examples
use hurray_core::layout::{LayoutDescriptor, TiledLayout};
// 2×4 tiles, row-major outer, row-major inner.
let layout = LayoutDescriptor::Tiled(Box::new(
TiledLayout::new(vec![2, 4], 0x01, 0x01, None, None, None).unwrap(),
));
assert_eq!(layout.tag(), 0x04);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tile_shape: Vec<u64>Tile dimensions. Every value MUST be > 0.
tile_shape.len() MUST equal the tensor rank.
outer_layout: u8Layout tag for tile-grid ordering.
MUST be 0x01 (row-major), 0x02 (col-major), or 0x03 (strided).
inner_layout: u8Layout tag for element ordering within a tile.
MUST be 0x01, 0x02, 0x03, or 0x04 (recursive tiling).
outer_strides: Option<OuterStrides>Explicit outer (tile-grid) strides in units of tiles.
Present iff outer_layout == 0x03.
inner_strides: Option<InnerStrides>Explicit inner strides in logical elements within a tile.
Present iff inner_layout == 0x03.
inner_tiled: Option<Box<TiledLayout>>Recursive inner tiling descriptor.
Present iff inner_layout == 0x04.
Implementations§
Source§impl TiledLayout
impl TiledLayout
Sourcepub fn new(
tile_shape: Vec<u64>,
outer_layout: u8,
inner_layout: u8,
outer_strides: Option<OuterStrides>,
inner_strides: Option<InnerStrides>,
inner_tiled: Option<Box<TiledLayout>>,
) -> Result<Self>
pub fn new( tile_shape: Vec<u64>, outer_layout: u8, inner_layout: u8, outer_strides: Option<OuterStrides>, inner_strides: Option<InnerStrides>, inner_tiled: Option<Box<TiledLayout>>, ) -> Result<Self>
Creates a new TiledLayout, validating that:
- all
tile_shapevalues are > 0, outer_layoutis0x01,0x02, or0x03,inner_layoutis0x01,0x02,0x03, or0x04,outer_stridesisSomeiffouter_layout == 0x03,inner_stridesisSomeiffinner_layout == 0x03,inner_tiledisSomeiffinner_layout == 0x04,- recursion depth does not exceed
MAX_TILED_DEPTH.
§Errors
Returns Error::InvalidLayout on any constraint violation.
§Examples
use hurray_core::layout::TiledLayout;
// 4×4 tiles, row-major outer, column-major inner.
let t = TiledLayout::new(vec![4, 4], 0x01, 0x02, None, None, None).unwrap();
assert_eq!(t.tile_shape, [4, 4]);Trait Implementations§
Source§impl Clone for TiledLayout
impl Clone for TiledLayout
Source§fn clone(&self) -> TiledLayout
fn clone(&self) -> TiledLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TiledLayout
impl Debug for TiledLayout
Source§impl ElementAddress for TiledLayout
impl ElementAddress for TiledLayout
impl Eq for TiledLayout
Source§impl Hash for TiledLayout
impl Hash for TiledLayout
Source§impl PartialEq for TiledLayout
impl PartialEq for TiledLayout
Source§fn eq(&self, other: &TiledLayout) -> bool
fn eq(&self, other: &TiledLayout) -> bool
self and other values to be equal, and is used by ==.