pub enum HostBuffer {
}Expand description
Host-addressable tensor storage holding a typed vector of elements.
This is the universal interchange format for moving tensor data
between backends: every BackendStorage can produce one via
to_host_buffer(), and every BackendDevice can ingest one via
storage_from_host_buffer().
Previously named CpuStorage — that name remains as a type alias.
Variants§
U8(Vec<u8>)
I8(Vec<i8>)
U32(Vec<u32>)
I16(Vec<i16>)
I32(Vec<i32>)
I64(Vec<i64>)
BF16(Vec<bf16>)
F16(Vec<f16>)
F32(Vec<f32>)
F64(Vec<f64>)
F8E4M3(Vec<F8E4M3>)
F6E2M3(Vec<u8>)
F6E3M2(Vec<u8>)
F4(Vec<u8>)
F8E8M0(Vec<u8>)
Bool(Vec<u8>)
Boolean mask storage (GAP-168(c)). One byte per element (0/1),
byte-identical to U8 — but a DISTINCT variant so a Bool buffer can
never be silently consumed as U8. The comparison kernels write 0/1
bytes here; where_cond/masked_fill read it as a byte mask.
Implementations§
Source§impl HostBuffer
impl HostBuffer
Sourcepub fn as_slice<D>(&self) -> Result<&[D], Error>where
D: HostDType,
pub fn as_slice<D>(&self) -> Result<&[D], Error>where
D: HostDType,
Returns a typed slice of the stored data.
Sourcepub fn concat(storages: &[HostBuffer]) -> Result<HostBuffer, Error>
pub fn concat(storages: &[HostBuffer]) -> Result<HostBuffer, Error>
Concatenates multiple storages of the same dtype into one.
Sourcepub fn as_ref(&self) -> HostBufferRef<'_>
pub fn as_ref(&self) -> HostBufferRef<'_>
Borrow this buffer as a HostBufferRef (zero-copy).
The ref form is the common shape for HostStorage::as_host_buffer_ref;
owned-buffer implementors delegate through here.
Trait Implementations§
Source§impl Clone for HostBuffer
impl Clone for HostBuffer
Source§fn clone(&self) -> HostBuffer
fn clone(&self) -> HostBuffer
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 HostBuffer
impl Debug for HostBuffer
Source§impl From<CpuStorage> for HostBuffer
impl From<CpuStorage> for HostBuffer
Source§fn from(s: CpuStorage) -> HostBuffer
fn from(s: CpuStorage) -> HostBuffer
Auto Trait Implementations§
impl Freeze for HostBuffer
impl RefUnwindSafe for HostBuffer
impl Send for HostBuffer
impl Sync for HostBuffer
impl Unpin for HostBuffer
impl UnsafeUnpin for HostBuffer
impl UnwindSafe for HostBuffer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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