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: BackendStorageBackend variant + the bytes themselves.
dtype: DTypeHow 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: STypeHow 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
impl Storage
Sourcepub fn new(inner: BackendStorage, dtype: DType) -> Self
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.
Sourcepub fn new_bundled(
inner: BackendStorage,
dtype: DType,
bundle: Arc<[OutputView]>,
) -> Result<Self>
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).
Sourcepub fn with_bundle(self, bundle: Arc<[OutputView]>) -> Result<Self>
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).
Sourcepub fn is_bundled(&self) -> bool
pub fn is_bundled(&self) -> bool
Whether this storage carries multi-output bundle metadata.
Sourcepub fn slot_count(&self) -> usize
pub fn slot_count(&self) -> usize
Number of logical output slots. 1 for single-output;
bundle.len() for bundled.
Sourcepub fn bundle(&self) -> Option<&[OutputView]>
pub fn bundle(&self) -> Option<&[OutputView]>
Borrow the bundle slice, or None for single-output storage.
Sourcepub fn slot_view(&self, idx: usize) -> Option<&OutputView>
pub fn slot_view(&self, idx: usize) -> Option<&OutputView>
Per-slot view; None for out-of-range or single-output.
Sourcepub fn elem_count(&self) -> usize
pub fn elem_count(&self) -> usize
Element count = len_bytes / dtype.size_in_bytes().
Sourcepub fn with_stype(self, stype: SType) -> Self
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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