Skip to main content

Linear

Trait Linear 

Source
pub trait Linear<B: Backend>: Send + Sync {
    // Required methods
    fn in_features(&self) -> usize;
    fn out_features(&self) -> usize;
    fn forward(
        &self,
        ctx: &mut B::Context,
        input: &B::Buffer,
        out: &mut B::Buffer,
        m: usize,
    );
}
Expand description

A weight-bearing linear projection.

forward computes out[m, out_features] = input[m, in_features] @ W^T. Implementations are responsible for calling the right backend kernel (B::gemm for dense, B::gemm_quant for quantized variants).

Required Methods§

Source

fn in_features(&self) -> usize

Source

fn out_features(&self) -> usize

Source

fn forward( &self, ctx: &mut B::Context, input: &B::Buffer, out: &mut B::Buffer, m: usize, )

Append GEMM work onto ctx. Caller flushes the context when results must be materialised.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§