Trait burn::module::Module

pub trait Module<B>:
    Clone
    + Send
    + Debug
where B: Backend,
{ type Record: Record<B>;
Show 13 methods // 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> { ... } fn quantize_weights<C>(self, quantizer: &mut Quantizer<C>) -> Self where C: Calibration { ... }
}
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§

type Record: Record<B>

Type to save and load the module.

Required Methods§

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.

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 output module on the new device will have its own autodiff graph.

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 operation supports autodiff and it will be registered when activated. However, this may not be what you want. The output model will be an intermediary model, meaning that you can’t optimize it with gradient descent. If you want to optimize the output network on the target device, use fork instead.

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

Visit each tensor parameter in the module with a visitor.

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

Map each tensor parameter in the module with a mapper.

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

Load the module state from a record.

fn into_record(self) -> Self::Record

Convert the module into a record containing the state.

Provided Methods§

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

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

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.

fn num_params(&self) -> usize

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

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.

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.

fn quantize_weights<C>(self, quantizer: &mut Quantizer<C>) -> Self
where C: Calibration,

Quantize the weights of the module.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Record = ConstantRecord

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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)

§

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

§

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

§

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

§

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

§

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

§

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)

§

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

§

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>

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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>

§

fn num_params(&self) -> usize

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

fn num_params(&self) -> usize

§

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

§

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

§

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

§

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

§

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

§

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

Implementors§

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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