pub struct NullBackend;Expand description
A no-op backend whose operations all return
BackendError::Unsupported.
Implementations§
Source§impl NullBackend
impl NullBackend
Trait Implementations§
Source§impl Clone for NullBackend
impl Clone for NullBackend
Source§fn clone(&self) -> NullBackend
fn clone(&self) -> NullBackend
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ComputeBackend for NullBackend
impl ComputeBackend for NullBackend
Source§fn init(&mut self) -> BackendResult<()>
fn init(&mut self) -> BackendResult<()>
Initialize the backend (select device, create context). Read more
Source§fn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
Returns
true if the backend is ready for operations.Source§fn capabilities(&self) -> Capabilities
fn capabilities(&self) -> Capabilities
Report this backend’s capabilities (precision support, Tensor Cores,
unified memory, thread/shared-memory limits, …). Read more
Source§fn available_devices(&self) -> BackendResult<Vec<DeviceInfo>>
fn available_devices(&self) -> BackendResult<Vec<DeviceInfo>>
Enumerate the devices this backend exposes, in a backend-agnostic
DeviceInfo shape. Read moreSource§fn gemm(
&self,
_trans_a: BackendTranspose,
_trans_b: BackendTranspose,
_m: usize,
_n: usize,
_k: usize,
_alpha: f64,
_a_ptr: u64,
_lda: usize,
_b_ptr: u64,
_ldb: usize,
_beta: f64,
_c_ptr: u64,
_ldc: usize,
) -> BackendResult<()>
fn gemm( &self, _trans_a: BackendTranspose, _trans_b: BackendTranspose, _m: usize, _n: usize, _k: usize, _alpha: f64, _a_ptr: u64, _lda: usize, _b_ptr: u64, _ldb: usize, _beta: f64, _c_ptr: u64, _ldc: usize, ) -> BackendResult<()>
General matrix multiply:
C = alpha * op(A) * op(B) + beta * C. Read moreSource§fn conv2d_forward(
&self,
_input_ptr: u64,
_input_shape: &[usize],
_filter_ptr: u64,
_filter_shape: &[usize],
_output_ptr: u64,
_output_shape: &[usize],
_stride: &[usize],
_padding: &[usize],
) -> BackendResult<()>
fn conv2d_forward( &self, _input_ptr: u64, _input_shape: &[usize], _filter_ptr: u64, _filter_shape: &[usize], _output_ptr: u64, _output_shape: &[usize], _stride: &[usize], _padding: &[usize], ) -> BackendResult<()>
2D convolution forward pass. Read more
Source§fn attention(
&self,
_q_ptr: u64,
_k_ptr: u64,
_v_ptr: u64,
_o_ptr: u64,
_batch: usize,
_heads: usize,
_seq_q: usize,
_seq_kv: usize,
_head_dim: usize,
_scale: f64,
_causal: bool,
) -> BackendResult<()>
fn attention( &self, _q_ptr: u64, _k_ptr: u64, _v_ptr: u64, _o_ptr: u64, _batch: usize, _heads: usize, _seq_q: usize, _seq_kv: usize, _head_dim: usize, _scale: f64, _causal: bool, ) -> BackendResult<()>
Scaled dot-product attention. Read more
Source§fn reduce(
&self,
_op: ReduceOp,
_input_ptr: u64,
_output_ptr: u64,
_shape: &[usize],
_axis: usize,
) -> BackendResult<()>
fn reduce( &self, _op: ReduceOp, _input_ptr: u64, _output_ptr: u64, _shape: &[usize], _axis: usize, ) -> BackendResult<()>
Reduction along an axis. Read more
Source§fn unary(
&self,
_op: UnaryOp,
_input_ptr: u64,
_output_ptr: u64,
_n: usize,
) -> BackendResult<()>
fn unary( &self, _op: UnaryOp, _input_ptr: u64, _output_ptr: u64, _n: usize, ) -> BackendResult<()>
Element-wise unary operation. Read more
Source§fn binary(
&self,
_op: BinaryOp,
_a_ptr: u64,
_b_ptr: u64,
_output_ptr: u64,
_n: usize,
) -> BackendResult<()>
fn binary( &self, _op: BinaryOp, _a_ptr: u64, _b_ptr: u64, _output_ptr: u64, _n: usize, ) -> BackendResult<()>
Element-wise binary operation. Read more
Source§fn synchronize(&self) -> BackendResult<()>
fn synchronize(&self) -> BackendResult<()>
Synchronize all pending operations on this backend. Read more
Source§fn free(&self, _ptr: u64) -> BackendResult<()>
fn free(&self, _ptr: u64) -> BackendResult<()>
Free device memory previously allocated with
alloc.Source§fn copy_htod(&self, _dst: u64, _src: &[u8]) -> BackendResult<()>
fn copy_htod(&self, _dst: u64, _src: &[u8]) -> BackendResult<()>
Copy data from host memory to device memory. Read more
Source§fn copy_dtoh(&self, _dst: &mut [u8], _src: u64) -> BackendResult<()>
fn copy_dtoh(&self, _dst: &mut [u8], _src: u64) -> BackendResult<()>
Copy data from device memory to host memory. Read more
Source§fn recommended_tile_for(&self, m: usize, n: usize, k: usize) -> TileShape
fn recommended_tile_for(&self, m: usize, n: usize, k: usize) -> TileShape
Suggest a GEMM tile shape
(tile_m, tile_n, tile_k) for the given
problem dimensions, to seed an autotuner. Read moreSource§fn gemm_mixed_precision(
&self,
prec: MixedPrecision,
trans_a: BackendTranspose,
trans_b: BackendTranspose,
m: usize,
n: usize,
k: usize,
alpha: f32,
a_ptr: u64,
lda: usize,
b_ptr: u64,
ldb: usize,
beta: f32,
c_ptr: u64,
ldc: usize,
) -> BackendResult<()>
fn gemm_mixed_precision( &self, prec: MixedPrecision, trans_a: BackendTranspose, trans_b: BackendTranspose, m: usize, n: usize, k: usize, alpha: f32, a_ptr: u64, lda: usize, b_ptr: u64, ldb: usize, beta: f32, c_ptr: u64, ldc: usize, ) -> BackendResult<()>
Mixed-precision GEMM:
C = alpha * op(A) * op(B) + beta * C where the
A/B operands are stored in a reduced 16-bit format
(MixedPrecision::F16 or MixedPrecision::Bf16) but the dot
products accumulate in f32 — the Tensor-Core / WMMA contract. Read moreSource§fn conv2d_backward_data(
&self,
grad_output_ptr: u64,
grad_output_shape: &[usize],
filter_ptr: u64,
filter_shape: &[usize],
grad_input_ptr: u64,
grad_input_shape: &[usize],
stride: &[usize],
padding: &[usize],
) -> BackendResult<()>
fn conv2d_backward_data( &self, grad_output_ptr: u64, grad_output_shape: &[usize], filter_ptr: u64, filter_shape: &[usize], grad_input_ptr: u64, grad_input_shape: &[usize], stride: &[usize], padding: &[usize], ) -> BackendResult<()>
Backward pass of
conv2d_forward w.r.t. the
input (data gradient): given the upstream gradient grad_output,
produce grad_input of the same shape as the forward input. Read moreSource§fn conv2d_backward_filter(
&self,
input_ptr: u64,
input_shape: &[usize],
grad_output_ptr: u64,
grad_output_shape: &[usize],
grad_filter_ptr: u64,
grad_filter_shape: &[usize],
stride: &[usize],
padding: &[usize],
) -> BackendResult<()>
fn conv2d_backward_filter( &self, input_ptr: u64, input_shape: &[usize], grad_output_ptr: u64, grad_output_shape: &[usize], grad_filter_ptr: u64, grad_filter_shape: &[usize], stride: &[usize], padding: &[usize], ) -> BackendResult<()>
Backward pass of
conv2d_forward w.r.t. the
filter (weight gradient): given the forward input and the upstream
gradient grad_output, produce grad_filter of the same shape as the
forward filter. Read moreSource§fn softmax(
&self,
input_ptr: u64,
output_ptr: u64,
shape: &[usize],
axis: usize,
) -> BackendResult<()>
fn softmax( &self, input_ptr: u64, output_ptr: u64, shape: &[usize], axis: usize, ) -> BackendResult<()>
Source§fn gather(
&self,
input_ptr: u64,
indices: &[usize],
output_ptr: u64,
rows: usize,
cols: usize,
) -> BackendResult<()>
fn gather( &self, input_ptr: u64, indices: &[usize], output_ptr: u64, rows: usize, cols: usize, ) -> BackendResult<()>
Row-gather: copy the rows named by
indices out of a rows × cols
(f32, row-major) table into a contiguous output of
indices.len() × cols. Read moreSource§fn scatter(
&self,
input_ptr: u64,
indices: &[usize],
output_ptr: u64,
rows: usize,
cols: usize,
) -> BackendResult<()>
fn scatter( &self, input_ptr: u64, indices: &[usize], output_ptr: u64, rows: usize, cols: usize, ) -> BackendResult<()>
Row-scatter: write each input row (
indices.len() × cols, f32) into
output at the destination row given by indices, preserving
unreferenced rows of the rows × cols output table. Read moreSource§fn batched_gemm(
&self,
trans_a: BackendTranspose,
trans_b: BackendTranspose,
m: usize,
n: usize,
k: usize,
alpha: f64,
a_ptr: u64,
lda: usize,
stride_a: usize,
b_ptr: u64,
ldb: usize,
stride_b: usize,
beta: f64,
c_ptr: u64,
ldc: usize,
stride_c: usize,
batch_count: usize,
) -> BackendResult<()>
fn batched_gemm( &self, trans_a: BackendTranspose, trans_b: BackendTranspose, m: usize, n: usize, k: usize, alpha: f64, a_ptr: u64, lda: usize, stride_a: usize, b_ptr: u64, ldb: usize, stride_b: usize, beta: f64, c_ptr: u64, ldc: usize, stride_c: usize, batch_count: usize, ) -> BackendResult<()>
Strided batched GEMM: for each batch
b in 0..batch_count,
compute C_b = alpha * op(A_b) * op(B_b) + beta * C_b
where A_b starts at a_ptr + b * stride_a * 4 bytes (f32 elements), etc. Read moreimpl Copy for NullBackend
Source§impl Debug for NullBackend
impl Debug for NullBackend
Source§impl Default for NullBackend
impl Default for NullBackend
Source§fn default() -> NullBackend
fn default() -> NullBackend
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for NullBackend
impl RefUnwindSafe for NullBackend
impl Send for NullBackend
impl Sync for NullBackend
impl Unpin for NullBackend
impl UnsafeUnpin for NullBackend
impl UnwindSafe for NullBackend
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