Skip to main content

TensorOps

Trait TensorOps 

Source
pub trait TensorOps: Send + Sync {
Show 15 methods // Required methods fn matmul(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>; fn add(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>; fn sub(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>; fn mul(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>; fn div(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>; fn softmax(&self, tensor: &TensorRef, dim: i32) -> Result<TensorRef>; fn layer_norm( &self, input: &TensorRef, weight: &TensorRef, bias: Option<&TensorRef>, eps: f32, ) -> Result<TensorRef>; fn rms_norm( &self, input: &TensorRef, weight: &TensorRef, eps: f32, ) -> Result<TensorRef>; fn relu(&self, tensor: &TensorRef) -> Result<TensorRef>; fn gelu(&self, tensor: &TensorRef) -> Result<TensorRef>; fn silu(&self, tensor: &TensorRef) -> Result<TensorRef>; fn concat(&self, tensors: &[&TensorRef], dim: usize) -> Result<TensorRef>; fn split( &self, tensor: &TensorRef, sizes: &[usize], dim: usize, ) -> Result<Vec<TensorRef>>; fn transpose( &self, tensor: &TensorRef, dim0: usize, dim1: usize, ) -> Result<TensorRef>; fn permute(&self, tensor: &TensorRef, dims: &[usize]) -> Result<TensorRef>;
}
Expand description

Basic tensor operations

Required Methods§

Source

fn matmul(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>

Matrix multiplication

Source

fn add(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>

Element-wise addition

Source

fn sub(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>

Element-wise subtraction

Source

fn mul(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>

Element-wise multiplication

Source

fn div(&self, a: &TensorRef, b: &TensorRef) -> Result<TensorRef>

Element-wise division

Source

fn softmax(&self, tensor: &TensorRef, dim: i32) -> Result<TensorRef>

Apply softmax along specified dimension

Source

fn layer_norm( &self, input: &TensorRef, weight: &TensorRef, bias: Option<&TensorRef>, eps: f32, ) -> Result<TensorRef>

Apply layer normalization

Source

fn rms_norm( &self, input: &TensorRef, weight: &TensorRef, eps: f32, ) -> Result<TensorRef>

Apply RMS normalization

Source

fn relu(&self, tensor: &TensorRef) -> Result<TensorRef>

Apply ReLU activation

Source

fn gelu(&self, tensor: &TensorRef) -> Result<TensorRef>

Apply GELU activation

Source

fn silu(&self, tensor: &TensorRef) -> Result<TensorRef>

Apply SiLU (Swish) activation

Source

fn concat(&self, tensors: &[&TensorRef], dim: usize) -> Result<TensorRef>

Concatenate tensors along specified dimension

Source

fn split( &self, tensor: &TensorRef, sizes: &[usize], dim: usize, ) -> Result<Vec<TensorRef>>

Split tensor along specified dimension

Source

fn transpose( &self, tensor: &TensorRef, dim0: usize, dim1: usize, ) -> Result<TensorRef>

Transpose tensor dimensions

Source

fn permute(&self, tensor: &TensorRef, dims: &[usize]) -> Result<TensorRef>

Permute tensor dimensions

Implementors§