oa::ml::nn::Embedding

Trainable FP32 lookup table indexed by an arbitrary-shape U8, U32, or I32 matrix.

StRust public API

Declaration

pub struct Embedding { /* private fields */ }
Public Rust declaration.

Public Methods

pub fn forward(&self, indices: &Matrix) -> Result<Matrix>
pub const fn num_embeddings(&self) -> usize
pub const fn embedding_dim(&self) -> usize
pub fn weight(&self) -> Parameter
pub fn parameters(&self) -> [Parameter; 1]
fn forward(&self, input: &Matrix) -> Result<Matrix>
fn registry(&self) -> &ModuleRegistry
fn parameters(&self) -> Vec<Parameter>
fn named_parameters(&self) -> Vec<NamedParameter>
fn buffers(&self) -> Vec<Matrix>
fn named_buffers(&self) -> Vec<NamedBuffer>
fn all_parameters(&self) -> Result<Vec<Parameter>>
fn all_named_parameters(&self) -> Result<Vec<NamedParameter>>
fn all_named_buffers(&self) -> Result<Vec<NamedBuffer>>
fn all_named_state_u32(&self) -> Result<Vec<NamedStateU32>>
fn num_parameters(&self) -> Result<usize>
fn train(&self, training: bool)
fn eval(&self)
fn is_training(&self) -> bool
fn scoped_eval(&self) -> ScopedEval<'_>

Associated Functions

pub fn with_seed( engine: &Engine, num_embeddings: usize, embedding_dim: usize, seed: u64, ) -> Result<Self>
pub fn from_matrix(weight: Matrix) -> Result<Self>

Public Method Documentation

pub fn forward( &self, indices: &Matrix ) -> Result<Matrix>
No public source comment is attached to this declaration.
pub const fn num_embeddings( &self ) -> usize
Construct a deterministically initialized embedding table. Errors Returns an error when either dimension is zero, shape arithmetic overflows, or allocation/upload fails.
pub const fn embedding_dim( &self ) -> usize
Construct a deterministically initialized embedding table. Errors Returns an error when either dimension is zero, shape arithmetic overflows, or allocation/upload fails.
pub fn weight( &self ) -> Parameter
Construct a deterministically initialized embedding table. Errors Returns an error when either dimension is zero, shape arithmetic overflows, or allocation/upload fails.
pub fn parameters( &self ) -> [Parameter; 1]
Construct a deterministically initialized embedding table. Errors Returns an error when either dimension is zero, shape arithmetic overflows, or allocation/upload fails.
fn forward( &self, input: &Matrix ) -> Result<Matrix>
No public source comment is attached to this declaration.
fn registry( &self ) -> &ModuleRegistry
No public source comment is attached to this declaration.
fn parameters( &self ) -> Vec<Parameter>
No public source comment is attached to this declaration.
fn named_parameters( &self ) -> Vec<NamedParameter>
No public source comment is attached to this declaration.
fn buffers( &self ) -> Vec<Matrix>
No public source comment is attached to this declaration.
fn named_buffers( &self ) -> Vec<NamedBuffer>
No public source comment is attached to this declaration.
fn all_parameters( &self ) -> Result<Vec<Parameter>>
No public source comment is attached to this declaration.
fn all_named_parameters( &self ) -> Result<Vec<NamedParameter>>
No public source comment is attached to this declaration.
fn all_named_buffers( &self ) -> Result<Vec<NamedBuffer>>
No public source comment is attached to this declaration.
fn all_named_state_u32( &self ) -> Result<Vec<NamedStateU32>>
No public source comment is attached to this declaration.
fn num_parameters( &self ) -> Result<usize>
No public source comment is attached to this declaration.
fn train( &self, training: bool )
No public source comment is attached to this declaration.
fn eval( &self )
No public source comment is attached to this declaration.
fn is_training( &self ) -> bool
No public source comment is attached to this declaration.
fn scoped_eval( &self ) -> ScopedEval<'_>
No public source comment is attached to this declaration.
pub fn with_seed( engine: &Engine, num_embeddings: usize, embedding_dim: usize, seed: u64 ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn from_matrix( weight: Matrix ) -> Result<Self>
No public source comment is attached to this declaration.