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: CpuStorageImplementations§
Source§impl CpuStorage
impl CpuStorage
Sourcepub fn into_inner(self) -> HostBuffer
pub fn into_inner(self) -> HostBuffer
Unwrap the inner HostBuffer.
Sourcepub fn inner(&self) -> &HostBuffer
pub fn inner(&self) -> &HostBuffer
Borrow the inner HostBuffer.
Trait Implementations§
Source§impl Clone for CpuStorage
impl Clone for CpuStorage
Source§impl Debug for CpuStorage
impl Debug for CpuStorage
Source§impl DynBackendStorage for CpuStorage
impl DynBackendStorage for CpuStorage
Source§fn try_clone_dyn(&self, _layout: &Layout) -> Result<Box<dyn DynBackendStorage>>
fn try_clone_dyn(&self, _layout: &Layout) -> Result<Box<dyn DynBackendStorage>>
Clone the elements described by
layout into a new storage.Source§fn device_dyn(&self) -> &dyn DynBackendDevice
fn device_dyn(&self) -> &dyn DynBackendDevice
The device that owns this storage.
Source§fn device_arc_dyn(&self) -> Arc<dyn DynBackendDevice> ⓘ
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>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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<()>
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<()>
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>>
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>>
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>>
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<()>
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<()>
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<()>
fn const_set_dyn(&mut self, value: Scalar, layout: &Layout) -> Result<()>
Set every element described by
layout to value.Source§fn as_any_mut(&mut self) -> &mut dyn Any
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>
fn to_cpu_storage_dyn(&self) -> Result<HostBuffer, Error>
Deprecated alias for
to_host_buffer_dyn.Source§impl From<CpuStorage> for CpuStorage
impl From<CpuStorage> for CpuStorage
Source§fn from(s: CpuStorage) -> Self
fn from(s: CpuStorage) -> Self
Converts to this type from the input type.
Source§impl From<HostBuffer> for CpuStorage
impl From<HostBuffer> for CpuStorage
Source§fn from(s: HostBuffer) -> Self
fn from(s: HostBuffer) -> Self
Converts to this type from the input type.
Source§impl HostStorage for CpuStorage
impl HostStorage for CpuStorage
Source§fn as_host_buffer_ref(&self) -> Result<HostBufferRef<'_>>
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>
fn into_host_buffer(self) -> Result<HostBuffer>
Extract the underlying data as an owned
HostBuffer. Read moreAuto Trait Implementations§
impl Freeze for CpuStorage
impl RefUnwindSafe for CpuStorage
impl Send for CpuStorage
impl Sync for CpuStorage
impl Unpin for CpuStorage
impl UnsafeUnpin for CpuStorage
impl UnwindSafe for CpuStorage
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
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,
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> ⓘ
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 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> ⓘ
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