pub struct CpuBackend;Expand description
CPU backend for tensor operations.
Implementations§
Source§impl CpuBackend
impl CpuBackend
Source§impl CpuBackend
impl CpuBackend
Sourcepub fn add_scalar<T: Numeric>(dst: &mut [T], a: &[T], scalar: T)
pub fn add_scalar<T: Numeric>(dst: &mut [T], a: &[T], scalar: T)
Adds a scalar to each element.
Sourcepub fn mul_scalar<T: Numeric>(dst: &mut [T], a: &[T], scalar: T)
pub fn mul_scalar<T: Numeric>(dst: &mut [T], a: &[T], scalar: T)
Multiplies each element by a scalar.
Source§impl CpuBackend
impl CpuBackend
Source§impl CpuBackend
impl CpuBackend
Source§impl CpuBackend
impl CpuBackend
Sourcepub fn matmul<T: Numeric>(
c: &mut [T],
a: &[T],
b: &[T],
m: usize,
n: usize,
k: usize,
)
pub fn matmul<T: Numeric>( c: &mut [T], a: &[T], b: &[T], m: usize, n: usize, k: usize, )
Performs matrix multiplication: C = A @ B.
A is (m x k), B is (k x n), C is (m x n). Uses optimized GEMM from matrixmultiply crate for f32/f64, falls back to cache-efficient tiled implementation for other types.
Sourcepub fn sgemm(
c: &mut [f32],
a: &[f32],
b: &[f32],
m: usize,
n: usize,
k: usize,
alpha: f32,
beta: f32,
)
pub fn sgemm( c: &mut [f32], a: &[f32], b: &[f32], m: usize, n: usize, k: usize, alpha: f32, beta: f32, )
Performs optimized f32 matrix multiplication using matrixmultiply crate.
C = alpha * A @ B + beta * C
Sourcepub fn dgemm(
c: &mut [f64],
a: &[f64],
b: &[f64],
m: usize,
n: usize,
k: usize,
alpha: f64,
beta: f64,
)
pub fn dgemm( c: &mut [f64], a: &[f64], b: &[f64], m: usize, n: usize, k: usize, alpha: f64, beta: f64, )
Performs optimized f64 matrix multiplication using matrixmultiply crate.
C = alpha * A @ B + beta * C
Sourcepub fn matmul_f32(
c: &mut [f32],
a: &[f32],
b: &[f32],
m: usize,
n: usize,
k: usize,
)
pub fn matmul_f32( c: &mut [f32], a: &[f32], b: &[f32], m: usize, n: usize, k: usize, )
Performs f32 matrix multiplication: C = A @ B using optimized GEMM.
Sourcepub fn matmul_f64(
c: &mut [f64],
a: &[f64],
b: &[f64],
m: usize,
n: usize,
k: usize,
)
pub fn matmul_f64( c: &mut [f64], a: &[f64], b: &[f64], m: usize, n: usize, k: usize, )
Performs f64 matrix multiplication: C = A @ B using optimized GEMM.
Trait Implementations§
Source§impl Backend for CpuBackend
impl Backend for CpuBackend
Source§fn is_available(&self) -> bool
fn is_available(&self) -> bool
Returns whether this backend is available on the current system.
Source§fn capabilities(&self) -> DeviceCapabilities
fn capabilities(&self) -> DeviceCapabilities
Returns the device capabilities.
Source§fn copy_to_device(&self, dst: *mut u8, src: *const u8, size: usize)
fn copy_to_device(&self, dst: *mut u8, src: *const u8, size: usize)
Copies data from host to device.
Source§fn copy_to_host(&self, dst: *mut u8, src: *const u8, size: usize)
fn copy_to_host(&self, dst: *mut u8, src: *const u8, size: usize)
Copies data from device to host.
Source§fn copy_device_to_device(&self, dst: *mut u8, src: *const u8, size: usize)
fn copy_device_to_device(&self, dst: *mut u8, src: *const u8, size: usize)
Copies data within the device.
Source§fn synchronize(&self)
fn synchronize(&self)
Synchronizes the device (waits for all operations to complete).
Source§impl Clone for CpuBackend
impl Clone for CpuBackend
Source§fn clone(&self) -> CpuBackend
fn clone(&self) -> CpuBackend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CpuBackend
impl Debug for CpuBackend
Source§impl Default for CpuBackend
impl Default for CpuBackend
Source§fn default() -> CpuBackend
fn default() -> CpuBackend
Returns the “default value” for a type. Read more
impl Copy for CpuBackend
Auto Trait Implementations§
impl Freeze for CpuBackend
impl RefUnwindSafe for CpuBackend
impl Send for CpuBackend
impl Sync for CpuBackend
impl Unpin for CpuBackend
impl UnwindSafe for CpuBackend
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> 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