pub struct Cpu;Expand description
The CPU device: a zero-sized type tag. All ops are associated functions.
Trait Implementations§
Source§impl BoolOps<Cpu> for Cpu
impl BoolOps<Cpu> for Cpu
fn b_falses( shape: &Shape, _device: &Cpu, _dtype: BoolDType, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_trues( shape: &Shape, _device: &Cpu, _dtype: BoolDType, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_from_bool<'a>( data: impl Into<Cow<'a, [bool]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_from_bytes<'a>( bytes: impl Into<Cow<'a, [u8]>>, _shape: &Shape, _device: &Cpu, _dtype: BoolDType, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_contiguous( x: &<Cpu as Device>::BoolStorage, l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_cast_float( x: &CpuBoolStorage, layout: &Layout, to: FloatDType, ) -> Result<CpuFloatStorage>
fn b_cast_int( x: &CpuBoolStorage, layout: &Layout, to: IntDType, ) -> Result<CpuIntStorage>
fn b_cast_bool( x: &CpuBoolStorage, layout: &Layout, _to: BoolDType, ) -> Result<CpuBoolStorage>
Source§fn b_to_vec(
x: &<Cpu as Device>::BoolStorage,
layout: &Layout,
) -> Result<Vec<bool>>
fn b_to_vec( x: &<Cpu as Device>::BoolStorage, layout: &Layout, ) -> Result<Vec<bool>>
Read all elements into a
Vec<bool> in logical (layout) order.Source§fn b_to_bytes<'a>(
x: &'a <Cpu as Device>::BoolStorage,
layout: &Layout,
) -> Result<Cow<'a, [u8]>>
fn b_to_bytes<'a>( x: &'a <Cpu as Device>::BoolStorage, layout: &Layout, ) -> Result<Cow<'a, [u8]>>
Read raw bytes (0/1 per element) in logical (layout) order.
Returns
Cow::Borrowed when the underlying storage is already contiguous
(zero-copy); Cow::Owned otherwise.fn b_and( lhs: &<Cpu as Device>::BoolStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::BoolStorage, rhs_l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_or( lhs: &<Cpu as Device>::BoolStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::BoolStorage, rhs_l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_xor( lhs: &<Cpu as Device>::BoolStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::BoolStorage, rhs_l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_not( x: &<Cpu as Device>::BoolStorage, l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_reduce_all( x: &<Cpu as Device>::BoolStorage, l: &Layout, dims: &[usize], keepdim: bool, ) -> Result<(<Cpu as Device>::BoolStorage, Shape)>
fn b_reduce_any( x: &<Cpu as Device>::BoolStorage, l: &Layout, dims: &[usize], keepdim: bool, ) -> Result<(<Cpu as Device>::BoolStorage, Shape)>
fn b_true_count(x: &<Cpu as Device>::BoolStorage, l: &Layout) -> Result<usize>
fn b_cat( srcs: &[(&<Cpu as Device>::BoolStorage, &Layout)], dim: usize, ) -> Result<(<Cpu as Device>::BoolStorage, Shape)>
fn b_pick( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, on_true: &<Cpu as Device>::BoolStorage, true_l: &Layout, on_false: &<Cpu as Device>::BoolStorage, false_l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_pick_true( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, value: bool, on_false: &<Cpu as Device>::BoolStorage, false_l: &Layout, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_pick_false( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, on_true: &<Cpu as Device>::BoolStorage, true_l: &Layout, value: bool, ) -> Result<<Cpu as Device>::BoolStorage>
fn b_allclose( a: &CpuBoolStorage, a_l: &Layout, b: &CpuBoolStorage, b_l: &Layout, ) -> Result<bool>
Source§fn b_view(
_src: &D::BoolStorage,
_src_l: &Layout,
_dst_l: &Layout,
_view: ViewOp,
) -> Result<Option<D::BoolStorage>>
fn b_view( _src: &D::BoolStorage, _src_l: &Layout, _dst_l: &Layout, _view: ViewOp, ) -> Result<Option<D::BoolStorage>>
Produce the storage for a view of
src under dst_l. See [FloatOps::f_view].impl Copy for Cpu
Source§impl Device for Cpu
impl Device for Cpu
type FloatStorage = CpuFloatStorage
type IntStorage = CpuIntStorage
type BoolStorage = CpuBoolStorage
fn name(&self) -> String
Source§fn same_device(&self, _other: &Self) -> bool
fn same_device(&self, _other: &Self) -> bool
Whether two handles refer to the same underlying device. Read more
impl Eq for Cpu
Source§impl FloatOps<Cpu> for Cpu
impl FloatOps<Cpu> for Cpu
fn f_zeros( shape: &Shape, _device: &Cpu, dtype: FloatDType, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_ones( shape: &Shape, _device: &Cpu, dtype: FloatDType, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_full( shape: &Shape, value: f64, _device: &Cpu, dtype: FloatDType, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_from_f64<'a>( data: impl Into<Cow<'a, [f64]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_from_f32<'a>( data: impl Into<Cow<'a, [f32]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_from_bytes<'a>( bytes: impl Into<Cow<'a, [u8]>>, _shape: &Shape, _device: &Cpu, dtype: FloatDType, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_rand_uniform( shape: &Shape, lo: f64, hi: f64, _device: &Cpu, dtype: FloatDType, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_rand_normal( shape: &Shape, mean: f64, std: f64, _device: &Cpu, dtype: FloatDType, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_contiguous( x: &<Cpu as Device>::FloatStorage, l: &Layout, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_cast_float( x: &CpuFloatStorage, layout: &Layout, to: FloatDType, ) -> Result<CpuFloatStorage>
fn f_cast_int( x: &CpuFloatStorage, layout: &Layout, to: IntDType, ) -> Result<CpuIntStorage>
fn f_cast_bool( x: &CpuFloatStorage, layout: &Layout, _to: BoolDType, ) -> Result<CpuBoolStorage>
Source§fn f_to_vec(
x: &<Cpu as Device>::FloatStorage,
layout: &Layout,
) -> Result<Vec<f64>>
fn f_to_vec( x: &<Cpu as Device>::FloatStorage, layout: &Layout, ) -> Result<Vec<f64>>
Read all elements into a
Vec<f64> in logical (layout) order.Source§fn f_to_bytes<'a>(
x: &'a <Cpu as Device>::FloatStorage,
layout: &Layout,
) -> Result<Cow<'a, [u8]>>
fn f_to_bytes<'a>( x: &'a <Cpu as Device>::FloatStorage, layout: &Layout, ) -> Result<Cow<'a, [u8]>>
Read raw little-endian bytes in logical (layout) order.
Returns
Cow::Borrowed when the underlying storage is already contiguous
(zero-copy); Cow::Owned otherwise.fn f_binary( lhs: &<Cpu as Device>::FloatStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::FloatStorage, rhs_l: &Layout, op: BinaryOp, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_binary_scalar( lhs: &<Cpu as Device>::FloatStorage, lhs_l: &Layout, rhs: f64, op: BinaryOp, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_binary_scalar_( dst: &mut <Cpu as Device>::FloatStorage, dst_l: &Layout, rhs: f64, op: BinaryOp, ) -> Result<()>
fn f_binary_scalar_lhs( scalar: f64, rhs: &CpuFloatStorage, rhs_l: &Layout, op: BinaryOp, ) -> Result<CpuFloatStorage>
fn f_unary( x: &<Cpu as Device>::FloatStorage, l: &Layout, op: UnaryOp<f64>, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_float_unary( x: &<Cpu as Device>::FloatStorage, l: &Layout, op: FloatUnaryOp, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_unary_( dst: &mut <Cpu as Device>::FloatStorage, dst_l: &Layout, op: UnaryOp<f64>, ) -> Result<()>
fn f_float_unary_( dst: &mut <Cpu as Device>::FloatStorage, dst_l: &Layout, op: FloatUnaryOp, ) -> Result<()>
fn f_cmp( lhs: &<Cpu as Device>::FloatStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::FloatStorage, rhs_l: &Layout, op: CmpOp, ) -> Result<<Cpu as Device>::BoolStorage>
fn f_cmp_scalar( lhs: &<Cpu as Device>::FloatStorage, lhs_l: &Layout, rhs: f64, op: CmpOp, ) -> Result<<Cpu as Device>::BoolStorage>
fn f_reduce( x: &<Cpu as Device>::FloatStorage, l: &Layout, dims: &[usize], keepdim: bool, op: ReduceOp, ) -> Result<(<Cpu as Device>::FloatStorage, Shape)>
fn f_arg_reduce( x: &<Cpu as Device>::FloatStorage, l: &Layout, dim: usize, keepdim: bool, take_max: bool, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
fn f_matmul( lhs: &<Cpu as Device>::FloatStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::FloatStorage, rhs_l: &Layout, ) -> Result<(<Cpu as Device>::FloatStorage, Shape)>
fn f_add_matmul_( dst: &mut <Cpu as Device>::FloatStorage, dst_l: &Layout, lhs: &<Cpu as Device>::FloatStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::FloatStorage, rhs_l: &Layout, ) -> Result<()>
fn f_binary_( dst: &mut <Cpu as Device>::FloatStorage, dst_l: &Layout, src: &<Cpu as Device>::FloatStorage, src_l: &Layout, op: BinaryOp, ) -> Result<()>
fn f_index_select( x: &<Cpu as Device>::FloatStorage, x_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, dim: usize, ) -> Result<(<Cpu as Device>::FloatStorage, Shape)>
fn f_gather( x: &<Cpu as Device>::FloatStorage, x_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, dim: usize, ) -> Result<(<Cpu as Device>::FloatStorage, Shape)>
fn f_index_add( init: &<Cpu as Device>::FloatStorage, init_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, src: &<Cpu as Device>::FloatStorage, _src_l: &Layout, dim: usize, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_scatter_add( init: &<Cpu as Device>::FloatStorage, init_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, src: &<Cpu as Device>::FloatStorage, _src_l: &Layout, dim: usize, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_cat( srcs: &[(&<Cpu as Device>::FloatStorage, &Layout)], dim: usize, ) -> Result<(<Cpu as Device>::FloatStorage, Shape)>
fn f_softmax( x: &<Cpu as Device>::FloatStorage, l: &Layout, dim: usize, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_rms_norm( x: &<Cpu as Device>::FloatStorage, x_l: &Layout, weight: &<Cpu as Device>::FloatStorage, weight_l: &Layout, eps: f64, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_pick( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, on_true: &<Cpu as Device>::FloatStorage, true_l: &Layout, on_false: &<Cpu as Device>::FloatStorage, false_l: &Layout, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_pick_true( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, value: f64, on_false: &<Cpu as Device>::FloatStorage, false_l: &Layout, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_pick_false( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, on_true: &<Cpu as Device>::FloatStorage, true_l: &Layout, value: f64, ) -> Result<<Cpu as Device>::FloatStorage>
fn f_allclose( a: &CpuFloatStorage, a_l: &Layout, b: &CpuFloatStorage, b_l: &Layout, rtol: f64, atol: f64, ) -> Result<bool>
fn f_view( _src: &D::FloatStorage, _src_l: &Layout, _dst_l: &Layout, _view: ViewOp, ) -> Result<Option<D::FloatStorage>>
Source§impl IntOps<Cpu> for Cpu
impl IntOps<Cpu> for Cpu
fn i_zeros( shape: &Shape, _device: &Cpu, dtype: IntDType, ) -> Result<<Cpu as Device>::IntStorage>
fn i_ones( shape: &Shape, _device: &Cpu, dtype: IntDType, ) -> Result<<Cpu as Device>::IntStorage>
fn i_full( shape: &Shape, value: i64, _device: &Cpu, dtype: IntDType, ) -> Result<<Cpu as Device>::IntStorage>
fn i_from_i64<'a>( data: impl Into<Cow<'a, [i64]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::IntStorage>
fn i_from_i32<'a>( data: impl Into<Cow<'a, [i32]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::IntStorage>
fn i_from_u32<'a>( data: impl Into<Cow<'a, [u32]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::IntStorage>
fn i_from_u8<'a>( data: impl Into<Cow<'a, [u8]>>, _device: &Cpu, ) -> Result<<Cpu as Device>::IntStorage>
fn i_from_bytes<'a>( bytes: impl Into<Cow<'a, [u8]>>, _shape: &Shape, _device: &Cpu, dtype: IntDType, ) -> Result<<Cpu as Device>::IntStorage>
fn i_arange( start: i64, end: i64, step: i64, _device: &Cpu, dtype: IntDType, ) -> Result<(<Cpu as Device>::IntStorage, usize)>
fn i_contiguous( x: &<Cpu as Device>::IntStorage, l: &Layout, ) -> Result<<Cpu as Device>::IntStorage>
fn i_cast_float( x: &CpuIntStorage, layout: &Layout, to: FloatDType, ) -> Result<CpuFloatStorage>
fn i_cast_int( x: &CpuIntStorage, layout: &Layout, to: IntDType, ) -> Result<CpuIntStorage>
fn i_cast_bool( x: &CpuIntStorage, layout: &Layout, _to: BoolDType, ) -> Result<CpuBoolStorage>
Source§fn i_to_vec(
x: &<Cpu as Device>::IntStorage,
layout: &Layout,
) -> Result<Vec<i64>>
fn i_to_vec( x: &<Cpu as Device>::IntStorage, layout: &Layout, ) -> Result<Vec<i64>>
Read all elements into a
Vec<i64> in logical (layout) order.Source§fn i_to_bytes<'a>(
x: &'a <Cpu as Device>::IntStorage,
layout: &Layout,
) -> Result<Cow<'a, [u8]>>
fn i_to_bytes<'a>( x: &'a <Cpu as Device>::IntStorage, layout: &Layout, ) -> Result<Cow<'a, [u8]>>
Read raw little-endian bytes in logical (layout) order.
Returns
Cow::Borrowed when the underlying storage is already contiguous
(zero-copy); Cow::Owned otherwise.fn i_binary( lhs: &<Cpu as Device>::IntStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::IntStorage, rhs_l: &Layout, op: BinaryOp, ) -> Result<<Cpu as Device>::IntStorage>
fn i_binary_scalar( lhs: &<Cpu as Device>::IntStorage, lhs_l: &Layout, rhs: i64, op: BinaryOp, ) -> Result<<Cpu as Device>::IntStorage>
fn i_binary_( dst: &mut <Cpu as Device>::IntStorage, dst_l: &Layout, src: &<Cpu as Device>::IntStorage, src_l: &Layout, op: BinaryOp, ) -> Result<()>
fn i_binary_scalar_( dst: &mut <Cpu as Device>::IntStorage, dst_l: &Layout, rhs: i64, op: BinaryOp, ) -> Result<()>
fn i_binary_scalar_lhs( scalar: i64, rhs: &<Cpu as Device>::IntStorage, rhs_l: &Layout, op: BinaryOp, ) -> Result<<Cpu as Device>::IntStorage>
fn i_unary( x: &<Cpu as Device>::IntStorage, l: &Layout, op: UnaryOp<i64>, ) -> Result<<Cpu as Device>::IntStorage>
fn i_unary_( dst: &mut <Cpu as Device>::IntStorage, dst_l: &Layout, op: UnaryOp<i64>, ) -> Result<()>
fn i_matmul( lhs: &<Cpu as Device>::IntStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::IntStorage, rhs_l: &Layout, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
fn i_cmp( lhs: &<Cpu as Device>::IntStorage, lhs_l: &Layout, rhs: &<Cpu as Device>::IntStorage, rhs_l: &Layout, op: CmpOp, ) -> Result<<Cpu as Device>::BoolStorage>
fn i_cmp_scalar( lhs: &<Cpu as Device>::IntStorage, lhs_l: &Layout, rhs: i64, op: CmpOp, ) -> Result<<Cpu as Device>::BoolStorage>
fn i_reduce( x: &<Cpu as Device>::IntStorage, l: &Layout, dims: &[usize], keepdim: bool, op: ReduceOp, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
fn i_index_select( x: &<Cpu as Device>::IntStorage, x_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, dim: usize, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
fn i_gather( x: &<Cpu as Device>::IntStorage, x_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, dim: usize, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
fn i_cat( srcs: &[(&<Cpu as Device>::IntStorage, &Layout)], dim: usize, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
Source§fn i_arg_reduce(
x: &<Cpu as Device>::IntStorage,
layout: &Layout,
dim: usize,
keepdim: bool,
take_max: bool,
) -> Result<(<Cpu as Device>::IntStorage, Shape)>
fn i_arg_reduce( x: &<Cpu as Device>::IntStorage, layout: &Layout, dim: usize, keepdim: bool, take_max: bool, ) -> Result<(<Cpu as Device>::IntStorage, Shape)>
argmin/argmax return int-kind indices.
fn i_index_add( init: &<Cpu as Device>::IntStorage, init_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, src: &<Cpu as Device>::IntStorage, _src_l: &Layout, dim: usize, ) -> Result<<Cpu as Device>::IntStorage>
fn i_scatter_add( init: &<Cpu as Device>::IntStorage, init_l: &Layout, idx: &<Cpu as Device>::IntStorage, idx_l: &Layout, src: &<Cpu as Device>::IntStorage, _src_l: &Layout, dim: usize, ) -> Result<<Cpu as Device>::IntStorage>
fn i_pick( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, on_true: &<Cpu as Device>::IntStorage, true_l: &Layout, on_false: &<Cpu as Device>::IntStorage, false_l: &Layout, ) -> Result<<Cpu as Device>::IntStorage>
fn i_pick_true( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, value: i64, on_false: &<Cpu as Device>::IntStorage, false_l: &Layout, ) -> Result<<Cpu as Device>::IntStorage>
fn i_pick_false( mask: &<Cpu as Device>::BoolStorage, mask_l: &Layout, on_true: &<Cpu as Device>::IntStorage, true_l: &Layout, value: i64, ) -> Result<<Cpu as Device>::IntStorage>
fn i_allclose( a: &CpuIntStorage, a_l: &Layout, b: &CpuIntStorage, b_l: &Layout, ) -> Result<bool>
Source§fn i_view(
_src: &D::IntStorage,
_src_l: &Layout,
_dst_l: &Layout,
_view: ViewOp,
) -> Result<Option<D::IntStorage>>
fn i_view( _src: &D::IntStorage, _src_l: &Layout, _dst_l: &Layout, _view: ViewOp, ) -> Result<Option<D::IntStorage>>
Produce the storage for a view of
src under dst_l. See [FloatOps::f_view].impl StructuralPartialEq for Cpu
Auto Trait Implementations§
impl Freeze for Cpu
impl RefUnwindSafe for Cpu
impl Send for Cpu
impl Sync for Cpu
impl Unpin for Cpu
impl UnsafeUnpin for Cpu
impl UnwindSafe for Cpu
Blanket Implementations§
impl<T> Boilerplate for T
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