1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # Module Support
//!
//! Helpers for building `burn` modules from configs, and for working with
//! them once built.
//!
//! - [`ModuleInit`] — the Config → Module step. A bunsen config that
//! builds its module from a device alone implements it, with a fallible
//! `try_init` and a panicking `init`. Its docs are the reference for the
//! config lifecycle: the Simple Config and Stacked Config shapes, each with a
//! compiled example.
//! - [`ToStructureConfig`] — the config-side twin of `ModuleInit`: it
//! lowers an upper policy config of a Stacked Config family to its structure
//! config, and a blanket impl gives every implementor `ModuleInit` through
//! that structure.
//! - [`InputDTypes`], [`CoercesInput`], [`ResultDType`] and [`DTypeWrapped`]
//! — a block's float dtypes: the one it computes in and casts its
//! inputs to, and the one its output is in (see [`InputDTypes`]).
//! - [`HasDType`] — reports the [`DType`](burn::tensor::DType) a value
//! that is not a block works in: a simulation's state, a dynamic tensor.
//! - [`DTypeMapper`] — a [`ModuleMapper`](burn::module::ModuleMapper)
//! that casts every float parameter of a built module to one `DType`
//! (`model.map(&mut DTypeMapper::new(DType::F16))`).
//! - [`reflection`] — (feature `reflection`) a queryable XML view of a
//! built module tree, for selecting parameters with `XPath`.
//! - [`Rekey`] — a checkpoint's tensor names to a module's paths, built
//! from rules: a kit routes a checkpoint's prefixes onto its model's fields
//! and mounts each block's own map for the checkpoint's format there.
//! - [`CanonicalKeys`] — a module's canonical weight names, and the map
//! from them onto its record paths: a kit's map lands a checkpoint on the
//! canonical names, and [`Rekey::then`] the module's map takes them on.
//!
//! - [`Forward1Module`] … [`Forward4Module`] (and [`ForwardModule`], the
//! first's common name) — a module's forward by its number of
//! arguments, for code generic over the modules it calls ([Forward
//! modules](#forward-modules)).
//! - [`Gate`] — a view of two modules as a gate, `a(x) ⊙ b(gate)`, its
//! product taken in a [`Widening`](crate::burner::tensor::Widening).
//!
//! `ModuleInit` and `ToStructureConfig` are also in [`crate::prelude`].
//!
//! ## Forward modules
//!
//! burn gives a module's forward no trait: each module has an inherent
//! `forward`, of its own arguments. [`Forward1Module`] … [`Forward4Module`]
//! name one by its number of arguments, `ForwardN<A1, …, AN>`, its result
//! the associated `Output`; `forward` takes `&self`. They stand in for the
//! `Fn` traits, which a type cannot implement on stable Rust; they are
//! restricted to modules (a [`Module`](burn::module::Module) supertrait),
//! and give way to the `Fn` traits when a module can implement those.
//!
//! A module implements them by delegating to its inherent `forward`, which
//! method calls on the concrete type still resolve to first. Code bounded
//! on two of them for one type names the trait it calls,
//! `Forward1Module::forward(module, x)`: the method's name is the same.
//!
//! The norm and activation seams implement [`Forward1Module`] at every rank.
//! A view such as [`Gate`] borrows modules, and is not one.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;