Module

Trait Module 

Source
pub trait Module<B: Backend>:
    Clone
    + Send
    + Debug {
    type Record: Record<B>;

Show 13 methods // Required methods fn collect_devices(&self, devices: Devices<B>) -> Devices<B>; fn fork(self, device: &B::Device) -> Self; fn to_device(self, device: &B::Device) -> Self; fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor); fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self; fn load_record(self, record: Self::Record) -> Self; fn into_record(self) -> Self::Record; // Provided methods fn devices(&self) -> Devices<B> { ... } 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::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::{
    module::Module,
    nn::Linear,
    tensor::Tensor,
    tensor::backend::Backend,
};

#[derive(Module, Debug)]
struct MyModule<B: Backend> {
  my_param: 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: Devices<B>) -> Devices<B>

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

Source

fn fork(self, device: &B::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::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: ModuleVisitor<B>>(&self, visitor: &mut Visitor)

Visit each tensor parameter in the module with a visitor.

Source

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

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) -> Devices<B>

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>,

Available on crate feature std only.

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::Device, ) -> Result<Self, RecorderError>
where FR: FileRecorder<B>, PB: Into<PathBuf>,

Available on crate feature std only.

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, 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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::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::Device>) -> Vec<B::Device>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

impl<B: Backend> Module<B> for isize

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &B::Device) -> Self

Source§

fn fork(self, _: &B::Device) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

Source§

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

Source§

type Record = ConstantRecord

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

fn to_device(self, _: &Device<B>) -> Self

Source§

fn fork(self, _: &Device<B>) -> Self

Source§

fn collect_devices(&self, devices: Devices<B>) -> Devices<B>

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: ModuleVisitor<B>>(&self, visitor: &mut V)

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

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

Source§

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

Source§

fn collect_devices(&self, devices: Vec<B::Device>) -> Vec<B::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: ModuleVisitor<B>>(&self, visitor: &mut V)

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

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

Source§

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

Source§

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

Source§

fn collect_devices(&self, devices: Vec<B::Device>) -> Vec<B::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::Device>) -> Vec<B::Device>

Source§

fn num_params(&self) -> usize

Source§

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

Source§

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

Source§

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

Source§

fn into_record(self) -> Self::Record

Source§

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

Source§

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

Implementors§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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