Trait Module

Source
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(self, quantizer: &mut Quantizer) -> Self { ... }
}
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 output module on the new device 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 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.

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.

Source

fn quantize_weights(self, quantizer: &mut Quantizer) -> Self

Quantize the weights of the module.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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 isize
where B: Backend,

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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, B: Backend,

Source§

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 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 Conv3d<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 ConvTranspose3d<B>
where B: Backend,

Source§

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

Source§

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

Source§

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

Source§

impl<B> Module<B> for Interpolate2d
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
where B: Backend,

Source§

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

Source§

impl<B> Module<B> for PoissonNllLoss
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 BiLstm<B>
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 HardSigmoid
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
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 Sigmoid
where B: Backend,

Source§

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

Source§

impl<B> Module<B> for Tanh
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, T> Module<B> for Ignored<T>
where B: Backend, T: Sync + Send + Debug + Clone,

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,

Source§

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

Source§

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

Source§

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

Source§

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