Skip to main content

Storage

Struct Storage 

Source
pub struct Storage {
    pub inner: BackendStorage,
    pub dtype: DType,
    pub bundle: Option<Arc<[OutputView]>>,
    pub stype: SType,
}
Expand description

Top-level storage type: byte-erased payload + runtime dtype tag. Layout (shape + strides + start_offset) lives separately on the consuming Tensor — Storage owns only the bytes and which device/dtype they represent.

Optionally carries a bundle side-table describing how the inner byte buffer is partitioned into multiple logically independent outputs. Set by multi-output op authors via Storage::with_bundle / Storage::new_bundled; consumed by Op::View / Op::ViewOwned at realize time. See OutputView.

Fields§

§inner: BackendStorage

Backend variant + the bytes themselves.

§dtype: DType

How to interpret the bytes. Storage’s len_bytes is the byte count; the element count is len_bytes / dtype.size_in_bytes().

§bundle: Option<Arc<[OutputView]>>

None for single-output storage (today’s default). Some(_) for multi-output bundles: a shared Arc’d slice of per-slot OutputView entries, one per logical output. Op::View nodes share this Arc so the bundle stays alive as long as any view holds a reference.

§stype: SType

How the bytes are ENCODED (orthogonal to dtype, which is the logical element type). Empty = plain dense dtype, byte-identical to pre-SType behaviour. v1: PRIMARY storage only — bundle slots keep dtype only (per-slot SType is a future addition). See fuel_ir::SType and docs/specs/storage-encoding.md.

Implementations§

Source§

impl Storage

Source

pub fn new(inner: BackendStorage, dtype: DType) -> Self

Build a Storage from an already-allocated backend variant plus its dtype tag. Single-output (no bundle metadata); use Self::with_bundle / Self::new_bundled for the multi-output case.

Source

pub fn new_bundled( inner: BackendStorage, dtype: DType, bundle: Arc<[OutputView]>, ) -> Result<Self>

Build a Storage from a backend variant + dtype tag + bundle side-table in one shot. Validates that the bundle is non-empty and that slot 0’s dtype matches the storage’s primary dtype (the bundled-storage invariant: slot 0 IS the primary).

Source

pub fn with_bundle(self, bundle: Arc<[OutputView]>) -> Result<Self>

Attach a bundle side-table to an existing single-output Storage. Same validation as Self::new_bundled; panics in debug mode if a bundle is already attached (re-bundling is a contract bug).

Source

pub fn is_bundled(&self) -> bool

Whether this storage carries multi-output bundle metadata.

Source

pub fn slot_count(&self) -> usize

Number of logical output slots. 1 for single-output; bundle.len() for bundled.

Source

pub fn bundle(&self) -> Option<&[OutputView]>

Borrow the bundle slice, or None for single-output storage.

Source

pub fn slot_view(&self, idx: usize) -> Option<&OutputView>

Per-slot view; None for out-of-range or single-output.

Source

pub fn dtype(&self) -> DType

The DType tag attached to these bytes.

Source

pub fn len_bytes(&self) -> usize

Total addressable byte count.

Source

pub fn elem_count(&self) -> usize

Element count = len_bytes / dtype.size_in_bytes().

Source

pub fn with_stype(self, stype: SType) -> Self

Attach an encoding scheme to this storage (consuming builder). Does not touch the bytes or the logical dtype — only describes HOW the bytes are encoded. See fuel_ir::SType.

Source

pub fn stype(&self) -> &SType

The encoding scheme. Empty = plain dense dtype.

Trait Implementations§

Source§

impl Debug for Storage

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V