ModuleAdapter

Trait ModuleAdapter 

Source
pub trait ModuleAdapter: Send + Sync {
    // Required methods
    fn adapt(&self, snapshot: &TensorSnapshot) -> TensorSnapshot;
    fn clone_box(&self) -> Box<dyn ModuleAdapter>;

    // Provided method
    fn get_alternative_param_name(
        &self,
        _param_name: &str,
        _container_type: &str,
    ) -> Option<String> { ... }
}
Expand description

Trait for adapting tensor snapshots between different module formats

Required Methods§

Source

fn adapt(&self, snapshot: &TensorSnapshot) -> TensorSnapshot

Adapt a tensor snapshot based on its container type and parameter name

Source

fn clone_box(&self) -> Box<dyn ModuleAdapter>

Clone the adapter into a boxed trait object

Provided Methods§

Source

fn get_alternative_param_name( &self, _param_name: &str, _container_type: &str, ) -> Option<String>

Get alternative parameter name to try during matching

When looking for a parameter in a module, this method provides an alternative name to try if the direct name doesn’t match. This enables matching parameters with different naming conventions (e.g., PyTorch’s “weight” vs Burn’s “gamma”).

§Arguments
  • param_name - The parameter name we’re looking for
  • container_type - The type of container module (e.g., “BatchNorm”)
§Returns

Alternative parameter name to try, or None if no alternative exists

Trait Implementations§

Source§

impl Clone for Box<dyn ModuleAdapter>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§