pub struct Cpu;
Expand description
The CPU device
Trait Implementations
sourceimpl AllocateZeros for Cpu
impl AllocateZeros for Cpu
sourcefn zeros<T: CountElements>() -> Box<T>
fn zeros<T: CountElements>() -> Box<T>
Allocates using alloc_zeroed.
sourceimpl<L: CountElements, R: CountElements, const M: usize> BroadcastForEach<[L; M], [R; M]> for Cpu where
Self: BroadcastForEach<L, R>,
impl<L: CountElements, R: CountElements, const M: usize> BroadcastForEach<[L; M], [R; M]> for Cpu where
Self: BroadcastForEach<L, R>,
sourcefn foreach_mb<F>(l: &mut [L; M], r: Broadcast<'_, [R; M]>, f: &mut F) where
F: FnMut(&mut L::Dtype, &R::Dtype),
fn foreach_mb<F>(l: &mut [L; M], r: Broadcast<'_, [R; M]>, f: &mut F) where
F: FnMut(&mut L::Dtype, &R::Dtype),
Applies f
to each element of l
and r
, where r
is broadcasted to be the same size as l
.
sourceimpl<const M: usize> BroadcastForEach<[f32; M], f32> for Cpu
impl<const M: usize> BroadcastForEach<[f32; M], f32> for Cpu
sourcefn foreach_mb<F>(l: &mut [f32; M], r: Broadcast<'_, f32>, f: &mut F) where
F: FnMut(&mut f32, &f32),
fn foreach_mb<F>(l: &mut [f32; M], r: Broadcast<'_, f32>, f: &mut F) where
F: FnMut(&mut f32, &f32),
Applies f
to each element of l
and r
, where r
is broadcasted to be the same size as l
.
sourceimpl BroadcastForEach<f32, f32> for Cpu
impl BroadcastForEach<f32, f32> for Cpu
sourcefn foreach_mb<F>(l: &mut f32, r: Broadcast<'_, f32>, f: &mut F) where
F: FnMut(&mut f32, &f32),
fn foreach_mb<F>(l: &mut f32, r: Broadcast<'_, f32>, f: &mut F) where
F: FnMut(&mut f32, &f32),
Applies f
to each element of l
and r
, where r
is broadcasted to be the same size as l
.
sourceimpl<T: CountElements, const M: usize> Device<[T; M]> for Cpu where
Cpu: Device<T> + ReduceLastDim<[T; M]> + BroadcastForEach<[T; M], <Self as ReduceLastDim<[T; M]>>::Reduced>,
impl<T: CountElements, const M: usize> Device<[T; M]> for Cpu where
Cpu: Device<T> + ReduceLastDim<[T; M]> + BroadcastForEach<[T; M], <Self as ReduceLastDim<[T; M]>>::Reduced>,
sourcefn map<F: FnMut(&T::Dtype) -> T::Dtype>(t: &T, f: F) -> Box<T>
fn map<F: FnMut(&T::Dtype) -> T::Dtype>(t: &T, f: F) -> Box<T>
Allocate a new T
and then store f
applied to t
in the new T
. Uses ForEachElement::foreach_mr.
sourcefn add(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
fn add(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
Computes lhs += rhs
, using ForEachElement::foreach_mr.
sourcefn badd(lhs: &mut T, rhs: Broadcast<'_, <Self as ReduceLastDim<T>>::Reduced>) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
fn badd(lhs: &mut T, rhs: Broadcast<'_, <Self as ReduceLastDim<T>>::Reduced>) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
Computes lhs += rhs
, where rhs
’s last dimension is broadcasted. Uses BroadcastForEach::foreach_mb
sourcefn sub(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> SubAssign<&'r T::Dtype> + Copy,
fn sub(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> SubAssign<&'r T::Dtype> + Copy,
Computes lhs -= rhs
using ForEachElement::foreach_mr
sourceimpl Device<f32> for Cpu
impl Device<f32> for Cpu
sourcefn map<F: FnMut(&T::Dtype) -> T::Dtype>(t: &T, f: F) -> Box<T>
fn map<F: FnMut(&T::Dtype) -> T::Dtype>(t: &T, f: F) -> Box<T>
Allocate a new T
and then store f
applied to t
in the new T
. Uses ForEachElement::foreach_mr.
sourcefn add(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
fn add(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
Computes lhs += rhs
, using ForEachElement::foreach_mr.
sourcefn badd(lhs: &mut T, rhs: Broadcast<'_, <Self as ReduceLastDim<T>>::Reduced>) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
fn badd(lhs: &mut T, rhs: Broadcast<'_, <Self as ReduceLastDim<T>>::Reduced>) where
T::Dtype: for<'r> AddAssign<&'r T::Dtype> + Copy,
Computes lhs += rhs
, where rhs
’s last dimension is broadcasted. Uses BroadcastForEach::foreach_mb
sourcefn sub(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> SubAssign<&'r T::Dtype> + Copy,
fn sub(lhs: &mut T, rhs: &T) where
T::Dtype: for<'r> SubAssign<&'r T::Dtype> + Copy,
Computes lhs -= rhs
using ForEachElement::foreach_mr
sourceimpl<T: CountElements, const M: usize> FillElements<[T; M]> for Cpu where
Self: FillElements<T>,
impl<T: CountElements, const M: usize> FillElements<[T; M]> for Cpu where
Self: FillElements<T>,
sourceimpl FillElements<f32> for Cpu
impl FillElements<f32> for Cpu
sourceimpl<T: CountElements, const M: usize> ForEachElement<[T; M]> for Cpu where
Self: ForEachElement<T>,
impl<T: CountElements, const M: usize> ForEachElement<[T; M]> for Cpu where
Self: ForEachElement<T>,
sourcefn foreach_m<F: FnMut(&mut <[T; M] as CountElements>::Dtype)>(
a: &mut [T; M],
f: &mut F
)
fn foreach_m<F: FnMut(&mut <[T; M] as CountElements>::Dtype)>(
a: &mut [T; M],
f: &mut F
)
Mutate elements of a
by applying f
to all elements of a.
sourcefn foreach_mm<F>(a: &mut [T; M], b: &mut [T; M], f: &mut F) where
F: FnMut(&mut T::Dtype, &mut T::Dtype),
fn foreach_mm<F>(a: &mut [T; M], b: &mut [T; M], f: &mut F) where
F: FnMut(&mut T::Dtype, &mut T::Dtype),
Mutate elements of a
and b
by applying f
to all elements of (a, b).
mm
stands for mut mut Read more
sourcefn foreach_mr<F>(a: &mut [T; M], b: &[T; M], f: &mut F) where
F: FnMut(&mut T::Dtype, &T::Dtype),
fn foreach_mr<F>(a: &mut [T; M], b: &[T; M], f: &mut F) where
F: FnMut(&mut T::Dtype, &T::Dtype),
Mutate elements of a
by applying f
to all elements of (a, b).
mr
stands for mut ref Read more
sourceimpl ForEachElement<f32> for Cpu
impl ForEachElement<f32> for Cpu
sourcefn foreach_m<F: FnMut(&mut <f32 as CountElements>::Dtype)>(
a: &mut f32,
f: &mut F
)
fn foreach_m<F: FnMut(&mut <f32 as CountElements>::Dtype)>(
a: &mut f32,
f: &mut F
)
Mutate elements of a
by applying f
to all elements of a.
sourcefn foreach_mm<F: FnMut(&mut f32, &mut f32)>(a: &mut f32, b: &mut f32, f: &mut F)
fn foreach_mm<F: FnMut(&mut f32, &mut f32)>(a: &mut f32, b: &mut f32, f: &mut F)
Mutate elements of a
and b
by applying f
to all elements of (a, b).
mm
stands for mut mut Read more
sourcefn foreach_mr<F: FnMut(&mut f32, &f32)>(a: &mut f32, b: &f32, f: &mut F)
fn foreach_mr<F: FnMut(&mut f32, &f32)>(a: &mut f32, b: &f32, f: &mut F)
Mutate elements of a
by applying f
to all elements of (a, b).
mr
stands for mut ref Read more
sourceimpl<O: CountElements, L: CountElements + MultiDimensional, R: CountElements, const M: usize> ForEachLast<[O; M], [L; M], [R; M]> for Cpu where
Cpu: ForEachLast<O, L, R>,
impl<O: CountElements, L: CountElements + MultiDimensional, R: CountElements, const M: usize> ForEachLast<[O; M], [L; M], [R; M]> for Cpu where
Cpu: ForEachLast<O, L, R>,
sourceimpl<const M: usize> ForEachLast<f32, [f32; M], usize> for Cpu
impl<const M: usize> ForEachLast<f32, [f32; M], usize> for Cpu
sourceimpl<T: CountElements, const M: usize> ReduceElements<[T; M]> for Cpu where
Self: ReduceElements<T>,
impl<T: CountElements, const M: usize> ReduceElements<[T; M]> for Cpu where
Self: ReduceElements<T>,
sourceimpl ReduceElements<f32> for Cpu
impl ReduceElements<f32> for Cpu
sourceimpl<T: MultiDimensional, const M: usize> ReduceLastDim<[T; M]> for Cpu where
Self: ReduceLastDim<T, Reduced = T::Reduced>,
impl<T: MultiDimensional, const M: usize> ReduceLastDim<[T; M]> for Cpu where
Self: ReduceLastDim<T, Reduced = T::Reduced>,
const LAST_DIM: usize = T::LAST_DIM_SIZE
type Reduced = [<T as MultiDimensional>::Reduced; M]
fn reduce_last_dim_into<F>(inp: &[T; M], out: &mut Self::Reduced, f: &mut F) where
F: FnMut(T::Dtype, T::Dtype) -> T::Dtype,
fn reduce_last_dim<F>(inp: &T, f: &mut F) -> Box<Self::Reduced> where
F: FnMut(T::Dtype, T::Dtype) -> T::Dtype,
sourceimpl ReduceLastDim<f32> for Cpu
impl ReduceLastDim<f32> for Cpu
Auto Trait Implementations
impl RefUnwindSafe for Cpu
impl Send for Cpu
impl Sync for Cpu
impl Unpin for Cpu
impl UnwindSafe for Cpu
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more