Skip to main content

CpuStorage

Struct CpuStorage 

Source
pub struct CpuStorage(pub CpuStorage);
Expand description

CPU backend storage: owns raw tensor data as a typed HostBuffer.

Defined in fuel-cpu-backend so the orphan rule allows implementing DynBackendStorage here with full access to CPU kernels.

Tuple Fields§

§0: CpuStorage

Implementations§

Source§

impl CpuStorage

Source

pub fn into_inner(self) -> HostBuffer

Unwrap the inner HostBuffer.

Source

pub fn inner(&self) -> &HostBuffer

Borrow the inner HostBuffer.

Trait Implementations§

Source§

impl Clone for CpuStorage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CpuStorage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl DynBackendStorage for CpuStorage

Source§

fn try_clone_dyn(&self, _layout: &Layout) -> Result<Box<dyn DynBackendStorage>>

Clone the elements described by layout into a new storage.
Source§

fn dtype_dyn(&self) -> DType

The element dtype of this storage.
Source§

fn device_dyn(&self) -> &dyn DynBackendDevice

The device that owns this storage.
Source§

fn device_arc_dyn(&self) -> Arc<dyn DynBackendDevice> ⓘ

Return a cloned Arc handle to the owning device.
Source§

fn to_host_buffer_dyn(&self) -> Result<HostBuffer>

Copy the entire storage to a HostBuffer.
Source§

fn affine_dyn( &self, layout: &Layout, mul: f64, add: f64, ) -> Result<Box<dyn DynBackendStorage>>

Elementwise affine: x * mul + add.
Source§

fn powf_dyn( &self, layout: &Layout, e: f64, ) -> Result<Box<dyn DynBackendStorage>>

Raise every element to the power e.
Source§

fn elu_dyn( &self, layout: &Layout, alpha: f64, ) -> Result<Box<dyn DynBackendStorage>>

ELU activation.
Source§

fn reduce_op_dyn( &self, op: ReduceOp, layout: &Layout, axes: &[usize], ) -> Result<Box<dyn DynBackendStorage>>

Reduction (sum, min, max, …) over axes.
Source§

fn cmp_dyn( &self, op: CmpOp, rhs: &dyn DynBackendStorage, lhs_layout: &Layout, rhs_layout: &Layout, ) -> Result<Box<dyn DynBackendStorage>>

Elementwise comparison, returning a U8 buffer.
Source§

fn to_dtype_dyn( &self, layout: &Layout, dtype: DType, ) -> Result<Box<dyn DynBackendStorage>>

Cast to a different dtype.
Source§

fn unary_op_dyn( &self, layout: &Layout, op: UnaryOp, ) -> Result<Box<dyn DynBackendStorage>>

Elementwise unary operation.
Source§

fn binary_op_dyn( &self, rhs: &dyn DynBackendStorage, lhs_layout: &Layout, rhs_layout: &Layout, op: BinaryOp, ) -> Result<Box<dyn DynBackendStorage>>

Elementwise binary operation.
Source§

fn where_cond_dyn( &self, cond_layout: &Layout, on_true: &dyn DynBackendStorage, on_true_layout: &Layout, on_false: &dyn DynBackendStorage, on_false_layout: &Layout, ) -> Result<Box<dyn DynBackendStorage>>

Select on_true where condition is nonzero, on_false elsewhere.
Source§

fn conv1d_dyn( &self, l: &Layout, kernel: &dyn DynBackendStorage, kernel_l: &Layout, params: &ParamsConv1D, ) -> Result<Box<dyn DynBackendStorage>>

1-D convolution.
Source§

fn conv_transpose1d_dyn( &self, l: &Layout, kernel: &dyn DynBackendStorage, kernel_l: &Layout, params: &ParamsConvTranspose1D, ) -> Result<Box<dyn DynBackendStorage>>

1-D transposed convolution.
Source§

fn conv2d_dyn( &self, l: &Layout, kernel: &dyn DynBackendStorage, kernel_l: &Layout, params: &ParamsConv2D, ) -> Result<Box<dyn DynBackendStorage>>

2-D convolution.
Source§

fn conv_transpose2d_dyn( &self, l: &Layout, kernel: &dyn DynBackendStorage, kernel_l: &Layout, params: &ParamsConvTranspose2D, ) -> Result<Box<dyn DynBackendStorage>>

2-D transposed convolution.
Source§

fn avg_pool2d_dyn( &self, layout: &Layout, kernel: (usize, usize), stride: (usize, usize), ) -> Result<Box<dyn DynBackendStorage>>

2-D average pooling.
Source§

fn max_pool2d_dyn( &self, layout: &Layout, kernel: (usize, usize), stride: (usize, usize), ) -> Result<Box<dyn DynBackendStorage>>

2-D max pooling.
Source§

fn upsample_nearest1d_dyn( &self, layout: &Layout, target_size: usize, ) -> Result<Box<dyn DynBackendStorage>>

1-D nearest-neighbor upsampling.
Source§

fn upsample_nearest2d_dyn( &self, layout: &Layout, target_h: usize, target_w: usize, ) -> Result<Box<dyn DynBackendStorage>>

2-D nearest-neighbor upsampling.
Source§

fn upsample_bilinear2d_dyn( &self, layout: &Layout, target_h: usize, target_w: usize, align_corners: bool, scale_h: Option<f64>, scale_w: Option<f64>, ) -> Result<Box<dyn DynBackendStorage>>

2-D bilinear upsampling.
Source§

fn gather_dyn( &self, src_layout: &Layout, ids: &dyn DynBackendStorage, ids_layout: &Layout, dim: usize, ) -> Result<Box<dyn DynBackendStorage>>

Gather elements along dim using ids.
Source§

fn scatter_set_dyn( &mut self, self_layout: &Layout, src: &dyn DynBackendStorage, src_layout: &Layout, ids: &dyn DynBackendStorage, ids_layout: &Layout, dim: usize, ) -> Result<()>

Scatter-set src into self along dim at positions in ids.
Source§

fn scatter_add_set_dyn( &mut self, self_layout: &Layout, src: &dyn DynBackendStorage, src_layout: &Layout, ids: &dyn DynBackendStorage, ids_layout: &Layout, dim: usize, ) -> Result<()>

Scatter-add src into self along dim at positions in ids.
Source§

fn index_select_dyn( &self, ids: &dyn DynBackendStorage, src_layout: &Layout, ids_layout: &Layout, dim: usize, ) -> Result<Box<dyn DynBackendStorage>>

Select slices along dim at positions in ids.
Source§

fn index_add_dyn( &self, self_layout: &Layout, ids: &dyn DynBackendStorage, ids_layout: &Layout, src: &dyn DynBackendStorage, src_layout: &Layout, dim: usize, ) -> Result<Box<dyn DynBackendStorage>>

Index-add: accumulate src slices into self along dim at ids.
Source§

fn matmul_dyn( &self, rhs: &dyn DynBackendStorage, bmnk: (usize, usize, usize, usize), lhs_layout: &Layout, rhs_layout: &Layout, ) -> Result<Box<dyn DynBackendStorage>>

Matrix multiply.
Source§

fn copy_strided_src_dyn( &self, dst: &mut dyn DynBackendStorage, dst_offset: usize, src_layout: &Layout, ) -> Result<()>

Copy strided source into dst starting at dst_offset.
Source§

fn copy2d_dyn( &self, dst: &mut dyn DynBackendStorage, d1: usize, d2: usize, src_stride1: usize, dst_stride1: usize, src_offset: usize, dst_offset: usize, ) -> Result<()>

Copy a 2-D tile from self into dst.
Source§

fn const_set_dyn(&mut self, value: Scalar, layout: &Layout) -> Result<()>

Set every element described by layout to value.
Source§

fn as_any(&self) -> &dyn Any

Downcast to the concrete storage type.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast to the concrete storage type (mutable).
Source§

fn to_cpu_storage_dyn(&self) -> Result<HostBuffer, Error>

Deprecated alias for to_host_buffer_dyn.
Source§

impl From<CpuStorage> for CpuStorage

Source§

fn from(s: CpuStorage) -> Self

Converts to this type from the input type.
Source§

impl From<HostBuffer> for CpuStorage

Source§

fn from(s: HostBuffer) -> Self

Converts to this type from the input type.
Source§

impl HostStorage for CpuStorage

Source§

fn as_host_buffer_ref(&self) -> Result<HostBufferRef<'_>>

Borrow the underlying data as a HostBufferRef (zero-copy).
Source§

fn into_host_buffer(self) -> Result<HostBuffer>

Extract the underlying data as an owned HostBuffer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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