Skip to main content

TensorOps

Trait TensorOps 

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

Basic tensor operations

Required Methods§

Source

fn matmul( &self, a: &Arc<dyn TensorLike>, b: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Matrix multiplication

Source

fn add( &self, a: &Arc<dyn TensorLike>, b: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Element-wise addition

Source

fn sub( &self, a: &Arc<dyn TensorLike>, b: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Element-wise subtraction

Source

fn mul( &self, a: &Arc<dyn TensorLike>, b: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Element-wise multiplication

Source

fn div( &self, a: &Arc<dyn TensorLike>, b: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Element-wise division

Source

fn softmax( &self, tensor: &Arc<dyn TensorLike>, dim: i32, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Apply softmax along specified dimension

Source

fn layer_norm( &self, input: &Arc<dyn TensorLike>, weight: &Arc<dyn TensorLike>, bias: Option<&Arc<dyn TensorLike>>, eps: f32, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Apply layer normalization

Source

fn rms_norm( &self, input: &Arc<dyn TensorLike>, weight: &Arc<dyn TensorLike>, eps: f32, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Apply RMS normalization

Source

fn relu( &self, tensor: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Apply ReLU activation

Source

fn gelu( &self, tensor: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Apply GELU activation

Source

fn silu( &self, tensor: &Arc<dyn TensorLike>, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Apply SiLU (Swish) activation

Source

fn concat( &self, tensors: &[&Arc<dyn TensorLike>], dim: usize, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Concatenate tensors along specified dimension

Source

fn split( &self, tensor: &Arc<dyn TensorLike>, sizes: &[usize], dim: usize, ) -> Result<Vec<Arc<dyn TensorLike>>, FerrumError>

Split tensor along specified dimension

Source

fn transpose( &self, tensor: &Arc<dyn TensorLike>, dim0: usize, dim1: usize, ) -> Result<Arc<dyn TensorLike>, FerrumError>

Transpose tensor dimensions

Source

fn permute( &self, tensor: &Arc<dyn TensorLike>, dims: &[usize], ) -> Result<Arc<dyn TensorLike>, FerrumError>

Permute tensor dimensions

Implementors§