Skip to main content

TiledLayout

Struct TiledLayout 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: u8

Layout tag for tile-grid ordering. MUST be 0x01 (row-major), 0x02 (col-major), or 0x03 (strided).

§inner_layout: u8

Layout 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

Source

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_shape values are > 0,
  • outer_layout is 0x01, 0x02, or 0x03,
  • inner_layout is 0x01, 0x02, 0x03, or 0x04,
  • outer_strides is Some iff outer_layout == 0x03,
  • inner_strides is Some iff inner_layout == 0x03,
  • inner_tiled is Some iff inner_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

Source§

fn clone(&self) -> TiledLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TiledLayout

Source§

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

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

impl ElementAddress for TiledLayout

Source§

fn element_offset(&self, index: &[u64], shape: &Shape) -> Result<u64>

Returns the linear element offset (in logical elements) for the given index.
Source§

impl Eq for TiledLayout

Source§

impl Hash for TiledLayout

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TiledLayout

Source§

fn eq(&self, other: &TiledLayout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for TiledLayout

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.