Trait burn::module::Module

source ·
pub trait Module<B>: Clone + Send + Debug
where B: Backend,
{ type Record: Record<B>; // Required methods fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>; fn fork(self, device: &<B as Backend>::Device) -> Self; fn to_device(self, device: &<B as Backend>::Device) -> Self; fn visit<Visitor>(&self, visitor: &mut Visitor) where Visitor: ModuleVisitor<B>; fn map<Mapper>(self, mapper: &mut Mapper) -> Self where Mapper: ModuleMapper<B>; fn load_record(self, record: Self::Record) -> Self; fn into_record(self) -> Self::Record; // Provided methods fn devices(&self) -> Vec<<B as Backend>::Device> { ... } fn no_grad(self) -> Self { ... } fn num_params(&self) -> usize { ... } fn save_file<FR, PB>( self, file_path: PB, recorder: &FR ) -> Result<(), RecorderError> where FR: FileRecorder<B>, PB: Into<PathBuf> { ... } fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as Backend>::Device ) -> Result<Self, RecorderError> where FR: FileRecorder<B>, PB: Into<PathBuf> { ... } }
Expand description

Trait for all neural network modules.

Modules should be created using the derive attribute. This will make your module trainable, savable and loadable via state and load.

§Example

A module should have a backend defined as a generic parameter B. This will be used by the derive attribute to generate the code necessary to optimize and train the module on any backend.

// Not necessary when using the burn crate directly.
use burn_core as burn;

use burn::{
    nn,
    module::Module,
    tensor::Tensor,
    tensor::backend::Backend,
};

#[derive(Module, Debug)]
struct MyModule<B: Backend> {
  my_param: nn::Linear<B>,
  my_other_field: usize,
}

Required Associated Types§

source

type Record: Record<B>

Type to save and load the module.

Required Methods§

source

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

Return all the devices found in the underneath module tree added to the given vector without duplicates.

source

fn fork(self, device: &<B as Backend>::Device) -> Self

Fork the module and all of its sub-modules to the given device.

§Notes

This is similar to to_device, but it ensures the module will have its own autodiff graph.

source

fn to_device(self, device: &<B as Backend>::Device) -> Self

Move the module and all of its sub-modules to the given device.

§Warnings

The device operations will be registered in the autodiff graph. Therefore, be sure to call backward only one time even if you have the same module on multiple devices. If you want to call backward multiple times, look into using fork instead.

source

fn visit<Visitor>(&self, visitor: &mut Visitor)
where Visitor: ModuleVisitor<B>,

Visit each tensor parameter in the module with a visitor.

source

fn map<Mapper>(self, mapper: &mut Mapper) -> Self
where Mapper: ModuleMapper<B>,

Map each tensor parameter in the module with a mapper.

source

fn load_record(self, record: Self::Record) -> Self

Load the module state from a record.

source

fn into_record(self) -> Self::Record

Convert the module into a record containing the state.

Provided Methods§

source

fn devices(&self) -> Vec<<B as Backend>::Device>

Return all the devices found in the underneath module tree without duplicates.

source

fn no_grad(self) -> Self

Each tensor in the module tree will not require grad.

§Warnings

This should not be used for inference, use valid when using AD modules. This is mostly useful when performing partial finetuning, which is updating only a small fraction of the parameters instead of finetuning all of them.

source

fn num_params(&self) -> usize

Get the number of parameters the module has, including all of its sub-modules.

source

fn save_file<FR, PB>( self, file_path: PB, recorder: &FR ) -> Result<(), RecorderError>
where FR: FileRecorder<B>, PB: Into<PathBuf>,

Save the module to a file using the provided file recorder.

List of supported file recorders:

§Notes

The file extension is automatically added depending on the file recorder provided, you don’t have to specify it.

source

fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as Backend>::Device ) -> Result<Self, RecorderError>
where FR: FileRecorder<B>, PB: Into<PathBuf>,

Load the module from a file using the provided file recorder.

The recorder should be the same as the one used to save the module, see save_file.

§Notes

The file extension is automatically added depending on the file recorder provided, you don’t have to specify it.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<B> Module<B> for bool
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> bool
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <bool as Module<B>>::Record) -> bool

source§

fn into_record(self) -> <bool as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> bool

source§

fn fork(self, _: &<B as Backend>::Device) -> bool

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for f32
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> f32
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <f32 as Module<B>>::Record) -> f32

source§

fn into_record(self) -> <f32 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> f32

source§

fn fork(self, _: &<B as Backend>::Device) -> f32

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for f64
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> f64
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <f64 as Module<B>>::Record) -> f64

source§

fn into_record(self) -> <f64 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> f64

source§

fn fork(self, _: &<B as Backend>::Device) -> f64

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for i8
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> i8
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <i8 as Module<B>>::Record) -> i8

source§

fn into_record(self) -> <i8 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> i8

source§

fn fork(self, _: &<B as Backend>::Device) -> i8

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for i16
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> i16
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <i16 as Module<B>>::Record) -> i16

source§

fn into_record(self) -> <i16 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> i16

source§

fn fork(self, _: &<B as Backend>::Device) -> i16

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for i32
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> i32
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <i32 as Module<B>>::Record) -> i32

source§

fn into_record(self) -> <i32 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> i32

source§

fn fork(self, _: &<B as Backend>::Device) -> i32

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for i64
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> i64
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <i64 as Module<B>>::Record) -> i64

source§

fn into_record(self) -> <i64 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> i64

source§

fn fork(self, _: &<B as Backend>::Device) -> i64

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for u8
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> u8
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <u8 as Module<B>>::Record) -> u8

source§

fn into_record(self) -> <u8 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> u8

source§

fn fork(self, _: &<B as Backend>::Device) -> u8

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for u16
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> u16
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <u16 as Module<B>>::Record) -> u16

source§

fn into_record(self) -> <u16 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> u16

source§

fn fork(self, _: &<B as Backend>::Device) -> u16

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for u32
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> u32
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <u32 as Module<B>>::Record) -> u32

source§

fn into_record(self) -> <u32 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> u32

source§

fn fork(self, _: &<B as Backend>::Device) -> u32

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for u64
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> u64
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <u64 as Module<B>>::Record) -> u64

source§

fn into_record(self) -> <u64 as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> u64

source§

fn fork(self, _: &<B as Backend>::Device) -> u64

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for usize
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> usize
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <usize as Module<B>>::Record) -> usize

source§

fn into_record(self) -> <usize as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> usize

source§

fn fork(self, _: &<B as Backend>::Device) -> usize

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for String
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> String
where M: ModuleMapper<B>,

source§

fn load_record(self, _record: <String as Module<B>>::Record) -> String

source§

fn into_record(self) -> <String as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> String

source§

fn fork(self, _: &<B as Backend>::Device) -> String

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B> Module<B> for PhantomData<B>
where B: Backend,

§

type Record = ConstantRecord

source§

fn visit<V>(&self, _visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, _mapper: &mut M) -> PhantomData<B>
where M: ModuleMapper<B>,

source§

fn load_record( self, _record: <PhantomData<B> as Module<B>>::Record ) -> PhantomData<B>

source§

fn into_record(self) -> <PhantomData<B> as Module<B>>::Record

source§

fn to_device(self, _: &<B as Backend>::Device) -> PhantomData<B>

source§

fn fork(self, _: &<B as Backend>::Device) -> PhantomData<B>

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<B, L0, L1> Module<B> for (L0, L1)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork(self, device: &<B as Backend>::Device) -> (L0, L1)

source§

fn to_device(self, device: &<B as Backend>::Device) -> (L0, L1)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1)
where M: ModuleMapper<B>,

source§

fn load_record(self, record: <(L0, L1) as Module<B>>::Record) -> (L0, L1)

source§

fn into_record(self) -> <(L0, L1) as Module<B>>::Record

source§

impl<B, L0, L1, L2> Module<B> for (L0, L1, L2)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork(self, device: &<B as Backend>::Device) -> (L0, L1, L2)

source§

fn to_device(self, device: &<B as Backend>::Device) -> (L0, L1, L2)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2) as Module<B>>::Record ) -> (L0, L1, L2)

source§

fn into_record(self) -> <(L0, L1, L2) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3> Module<B> for (L0, L1, L2, L3)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3)

source§

fn to_device(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3) as Module<B>>::Record ) -> (L0, L1, L2, L3)

source§

fn into_record(self) -> <(L0, L1, L2, L3) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3, L4> Module<B> for (L0, L1, L2, L3, L4)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone, L4: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record, <L4 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3, L4)

source§

fn to_device(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3, L4)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3, L4)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3, L4) as Module<B>>::Record ) -> (L0, L1, L2, L3, L4)

source§

fn into_record(self) -> <(L0, L1, L2, L3, L4) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3, L4, L5> Module<B> for (L0, L1, L2, L3, L4, L5)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone, L4: Module<B> + Debug + Send + Clone, L5: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record, <L4 as Module<B>>::Record, <L5 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3, L4, L5)

source§

fn to_device(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3, L4, L5)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3, L4, L5)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3, L4, L5) as Module<B>>::Record ) -> (L0, L1, L2, L3, L4, L5)

source§

fn into_record(self) -> <(L0, L1, L2, L3, L4, L5) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3, L4, L5, L6> Module<B> for (L0, L1, L2, L3, L4, L5, L6)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone, L4: Module<B> + Debug + Send + Clone, L5: Module<B> + Debug + Send + Clone, L6: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record, <L4 as Module<B>>::Record, <L5 as Module<B>>::Record, <L6 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork(self, device: &<B as Backend>::Device) -> (L0, L1, L2, L3, L4, L5, L6)

source§

fn to_device( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3, L4, L5, L6)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3, L4, L5, L6) as Module<B>>::Record ) -> (L0, L1, L2, L3, L4, L5, L6)

source§

fn into_record(self) -> <(L0, L1, L2, L3, L4, L5, L6) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3, L4, L5, L6, L7> Module<B> for (L0, L1, L2, L3, L4, L5, L6, L7)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone, L4: Module<B> + Debug + Send + Clone, L5: Module<B> + Debug + Send + Clone, L6: Module<B> + Debug + Send + Clone, L7: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record, <L4 as Module<B>>::Record, <L5 as Module<B>>::Record, <L6 as Module<B>>::Record, <L7 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6, L7)

source§

fn to_device( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6, L7)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3, L4, L5, L6, L7)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3, L4, L5, L6, L7) as Module<B>>::Record ) -> (L0, L1, L2, L3, L4, L5, L6, L7)

source§

fn into_record(self) -> <(L0, L1, L2, L3, L4, L5, L6, L7) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3, L4, L5, L6, L7, L8> Module<B> for (L0, L1, L2, L3, L4, L5, L6, L7, L8)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone, L4: Module<B> + Debug + Send + Clone, L5: Module<B> + Debug + Send + Clone, L6: Module<B> + Debug + Send + Clone, L7: Module<B> + Debug + Send + Clone, L8: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record, <L4 as Module<B>>::Record, <L5 as Module<B>>::Record, <L6 as Module<B>>::Record, <L7 as Module<B>>::Record, <L8 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8)

source§

fn to_device( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3, L4, L5, L6, L7, L8) as Module<B>>::Record ) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8)

source§

fn into_record( self ) -> <(L0, L1, L2, L3, L4, L5, L6, L7, L8) as Module<B>>::Record

source§

impl<B, L0, L1, L2, L3, L4, L5, L6, L7, L8, L9> Module<B> for (L0, L1, L2, L3, L4, L5, L6, L7, L8, L9)
where B: Backend, L0: Module<B> + Debug + Send + Clone, L1: Module<B> + Debug + Send + Clone, L2: Module<B> + Debug + Send + Clone, L3: Module<B> + Debug + Send + Clone, L4: Module<B> + Debug + Send + Clone, L5: Module<B> + Debug + Send + Clone, L6: Module<B> + Debug + Send + Clone, L7: Module<B> + Debug + Send + Clone, L8: Module<B> + Debug + Send + Clone, L9: Module<B> + Debug + Send + Clone,

§

type Record = (<L0 as Module<B>>::Record, <L1 as Module<B>>::Record, <L2 as Module<B>>::Record, <L3 as Module<B>>::Record, <L4 as Module<B>>::Record, <L5 as Module<B>>::Record, <L6 as Module<B>>::Record, <L7 as Module<B>>::Record, <L8 as Module<B>>::Record, <L9 as Module<B>>::Record)

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn fork( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8, L9)

source§

fn to_device( self, device: &<B as Backend>::Device ) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8, L9)

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8, L9)
where M: ModuleMapper<B>,

source§

fn load_record( self, record: <(L0, L1, L2, L3, L4, L5, L6, L7, L8, L9) as Module<B>>::Record ) -> (L0, L1, L2, L3, L4, L5, L6, L7, L8, L9)

source§

fn into_record( self ) -> <(L0, L1, L2, L3, L4, L5, L6, L7, L8, L9) as Module<B>>::Record

source§

impl<T, B> Module<B> for Option<T>
where T: Module<B> + Debug + Send + Clone, B: Backend,

§

type Record = Option<<T as Module<B>>::Record>

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> Option<T>
where M: ModuleMapper<B>,

source§

fn load_record(self, record: <Option<T> as Module<B>>::Record) -> Option<T>

source§

fn into_record(self) -> <Option<T> as Module<B>>::Record

source§

fn to_device(self, device: &<B as Backend>::Device) -> Option<T>

source§

fn fork(self, device: &<B as Backend>::Device) -> Option<T>

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<T, B> Module<B> for Vec<T>
where T: Module<B> + Debug + Send + Clone, B: Backend,

§

type Record = Vec<<T as Module<B>>::Record>

source§

fn num_params(&self) -> usize

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> Vec<T>
where M: ModuleMapper<B>,

source§

fn into_record(self) -> <Vec<T> as Module<B>>::Record

source§

fn load_record(self, record: <Vec<T> as Module<B>>::Record) -> Vec<T>

source§

fn to_device(self, device: &<B as Backend>::Device) -> Vec<T>

source§

fn fork(self, device: &<B as Backend>::Device) -> Vec<T>

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

impl<const N: usize, T, B> Module<B> for [T; N]
where T: Module<B> + Debug + Send + Clone + Copy, <T as Module<B>>::Record: Debug, B: Backend,

§

type Record = [<T as Module<B>>::Record; N]

source§

fn collect_devices( &self, devices: Vec<<B as Backend>::Device> ) -> Vec<<B as Backend>::Device>

source§

fn num_params(&self) -> usize

source§

fn visit<V>(&self, visitor: &mut V)
where V: ModuleVisitor<B>,

source§

fn map<M>(self, mapper: &mut M) -> [T; N]
where M: ModuleMapper<B>,

source§

fn load_record(self, record: <[T; N] as Module<B>>::Record) -> [T; N]

source§

fn into_record(self) -> <[T; N] as Module<B>>::Record

source§

fn to_device(self, device: &<B as Backend>::Device) -> [T; N]

source§

fn fork(self, device: &<B as Backend>::Device) -> [T; N]

Implementors§

source§

impl<B> Module<B> for PaddingConfig1d
where B: Backend,

source§

impl<B> Module<B> for PaddingConfig2d
where B: Backend,

source§

impl<B> Module<B> for MultiHeadAttention<B>
where B: Backend,

source§

impl<B> Module<B> for Conv1d<B>
where B: Backend,

source§

impl<B> Module<B> for Conv2d<B>
where B: Backend,

source§

impl<B> Module<B> for ConvTranspose1d<B>
where B: Backend,

source§

impl<B> Module<B> for ConvTranspose2d<B>
where B: Backend,

source§

impl<B> Module<B> for Gru<B>
where B: Backend,

source§

impl<B> Module<B> for BinaryCrossEntropyLoss<B>
where B: Backend,

source§

impl<B> Module<B> for CrossEntropyLoss<B>
where B: Backend,

source§

impl<B> Module<B> for HuberLoss<B>
where B: Backend,

source§

impl<B> Module<B> for AdaptiveAvgPool1d
where B: Backend,

source§

impl<B> Module<B> for AdaptiveAvgPool2d
where B: Backend,

source§

impl<B> Module<B> for AvgPool1d
where B: Backend,

source§

impl<B> Module<B> for AvgPool2d
where B: Backend,

source§

impl<B> Module<B> for MaxPool1d
where B: Backend,

source§

impl<B> Module<B> for MaxPool2d
where B: Backend,

source§

impl<B> Module<B> for Dropout
where B: Backend,

source§

impl<B> Module<B> for Embedding<B>
where B: Backend,

source§

impl<B> Module<B> for GateController<B>
where B: Backend,

source§

impl<B> Module<B> for Gelu
where B: Backend,

source§

impl<B> Module<B> for GroupNorm<B>
where B: Backend,

source§

impl<B> Module<B> for InstanceNorm<B>
where B: Backend,

source§

impl<B> Module<B> for LayerNorm<B>
where B: Backend,

source§

impl<B> Module<B> for LeakyRelu<B>
where B: Backend,

source§

impl<B> Module<B> for Linear<B>
where B: Backend,

source§

impl<B> Module<B> for Lstm<B>
where B: Backend,

source§

impl<B> Module<B> for PRelu<B>
where B: Backend,

source§

impl<B> Module<B> for PositionalEncoding<B>
where B: Backend,

source§

impl<B> Module<B> for Relu
where B: Backend,

source§

impl<B> Module<B> for RmsNorm<B>
where B: Backend,

source§

impl<B> Module<B> for RotaryEncoding<B>
where B: Backend,

source§

impl<B> Module<B> for SwiGlu<B>
where B: Backend,

source§

impl<B> Module<B> for Unfold4d
where B: Backend,

source§

impl<B> Module<B> for PositionWiseFeedForward<B>
where B: Backend,

source§

impl<B> Module<B> for TransformerDecoder<B>
where B: Backend,

source§

impl<B> Module<B> for TransformerDecoderLayer<B>
where B: Backend,

source§

impl<B> Module<B> for TransformerEncoder<B>
where B: Backend,

source§

impl<B> Module<B> for TransformerEncoderLayer<B>
where B: Backend,

source§

impl<B> Module<B> for bf16
where B: Backend,

source§

impl<B> Module<B> for f16
where B: Backend,

source§

impl<B, const D: usize> Module<B> for BatchNorm<B, D>
where B: Backend,

source§

impl<const D: usize, B> Module<B> for Param<Tensor<B, D>>
where B: Backend,

§

type Record = Param<Tensor<B, D>>

source§

impl<const D: usize, B> Module<B> for Param<Tensor<B, D, Bool>>
where B: Backend,

§

type Record = Param<Tensor<B, D, Bool>>

source§

impl<const D: usize, B> Module<B> for Param<Tensor<B, D, Int>>
where B: Backend,

§

type Record = Param<Tensor<B, D, Int>>

source§

impl<const D: usize, B> Module<B> for RunningState<Tensor<B, D>>
where B: Backend,

§

type Record = Param<Tensor<B, D>>

source§

impl<const D: usize, B, K> Module<B> for Tensor<B, D, K>
where B: Backend, K: BasicOps<B>,