pub struct TensorBuilder<const DIM: usize> { /* private fields */ }
Expand description
Helper struct for creating gpu storage buffers (scalars, vectors, matrices, tensors).
When building a scalar, vector, or matrix tensor, it might be more convenient to call
GpuScalar::init
, GpuVector::init
, GpuMatrix::init
(or their encase
variants:
GpuScalar::encase
, GpuVector::encase
, GpuMatrix::encase
; or their uninitialized
variants GpuScalar::uninit
, GpuVector::uninit
, GpuMatrix::uninit
).
Implementations§
Source§impl TensorBuilder<0>
impl TensorBuilder<0>
Sourcepub fn scalar(usage: BufferUsages) -> Self
pub fn scalar(usage: BufferUsages) -> Self
Starts building a storage buffer containing a single scalar value.
Source§impl TensorBuilder<1>
impl TensorBuilder<1>
Sourcepub fn vector(dim: u32, usage: BufferUsages) -> Self
pub fn vector(dim: u32, usage: BufferUsages) -> Self
Starts building a storage buffer containing a vector.
Source§impl TensorBuilder<2>
impl TensorBuilder<2>
Sourcepub fn matrix(nrows: u32, ncols: u32, usage: BufferUsages) -> Self
pub fn matrix(nrows: u32, ncols: u32, usage: BufferUsages) -> Self
Starts building a storage buffer containing a single matrix with nrows
rows and
ncols
columns.
Source§impl<const DIM: usize> TensorBuilder<DIM>
impl<const DIM: usize> TensorBuilder<DIM>
Sourcepub fn tensor(shape: [u32; DIM], usage: BufferUsages) -> Self
pub fn tensor(shape: [u32; DIM], usage: BufferUsages) -> Self
Starts building a storage buffer containing a tensor with the specified shape
.
Sourcepub fn build_bytes<T>(self, device: &Device, data: &[u8]) -> GpuTensor<T, DIM>
pub fn build_bytes<T>(self, device: &Device, data: &[u8]) -> GpuTensor<T, DIM>
Builds this tensor with raw bytes given for its initial value.
Auto Trait Implementations§
impl<const DIM: usize> Freeze for TensorBuilder<DIM>
impl<const DIM: usize> RefUnwindSafe for TensorBuilder<DIM>
impl<const DIM: usize> Send for TensorBuilder<DIM>
impl<const DIM: usize> Sync for TensorBuilder<DIM>
impl<const DIM: usize> Unpin for TensorBuilder<DIM>
impl<const DIM: usize> UnwindSafe for TensorBuilder<DIM>
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
Mutably borrows from an owned value. Read more
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.