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 Forget for HostBuffer
impl Freeze for HostBufferwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<i8>: Freeze,
PhantomData<u32>: Freeze,
PhantomData<i16>: Freeze,
PhantomData<i32>: Freeze,
PhantomData<i64>: Freeze,
PhantomData<bf16>: Freeze,
PhantomData<f16>: Freeze,
PhantomData<f32>: Freeze,
PhantomData<f64>: Freeze,
PhantomData<F8E4M3>: Freeze,
impl Move for HostBuffer
impl RefUnwindSafe for HostBuffer
impl Send for HostBufferwhere
RawVecInner: Send,
impl Sync for HostBufferwhere
RawVecInner: Sync,
impl Unpin for HostBuffer
impl UnsafeUnpin for HostBufferwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<i8>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
PhantomData<i16>: UnsafeUnpin,
PhantomData<i32>: UnsafeUnpin,
PhantomData<i64>: UnsafeUnpin,
PhantomData<bf16>: UnsafeUnpin,
PhantomData<f16>: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
PhantomData<f64>: UnsafeUnpin,
PhantomData<F8E4M3>: UnsafeUnpin,
impl UnwindSafe for HostBufferwhere
RawVecInner: UnwindSafe,
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