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
//! # Neural-Network / Module Building Blocks
//!
//! `bunsen::blocks` is a library of reusable `burn::module::Module`
//! components — the *parts* you compose into larger models. Each
//! block ships as a triple:
//!
//! - a `Config` struct (`#[derive(Config)]`),
//! - a `Module` struct (`#[derive(Module)]`),
//! - an `init` constructor connecting the two.
//!
//! Where [`crate::ops`] supplies pure functional tensor operations,
//! `blocks` supplies the *stateful* layers that own parameters and can
//! be trained.
//!
//! Where [`crate::kits`] supplies whole end-to-end models (`ResNet`,
//! `NanoChatGpt`, ...), `blocks` supplies the sub-modules those kits
//! are assembled from. A typical user picks an existing kit; an author
//! building a new model reaches into `blocks`.
//!
//! ## Map of the module
//!
//! - [`transformers`] — building blocks for transformer models.
//! - [`transformers::attention`] — causal self-attention
//! (`CausalSelfAttention`), scaled-dot-product attention helpers
//! (`scaled_dot_product_attention` and friends), and a `KVCache` for
//! autoregressive decoding.
//! - [`transformers::embedding`] — positional embeddings, currently
//! `RotaryEmbedding` (`RoPE`) with a clip-by-range helper for
//! KV-cache-friendly slicing.
//!
//! - [`images`] — building blocks for vision models.
//! - [`conv`] — conv composites: `ConvNorm2d` (conv + batchnorm) and
//! `ConvBlock2d` (conv / norm / activation).
//! - [`images::patching`] — patch tokenization, currently `PatchEmbed`
//! (ViT-style patch → embedding projection).
//! - [`images::pool`] — pooling that doesn't fit `burn`'s defaults,
//! currently `AvgPool2dSame` (TF-style same-padding average pool).
//! - [`images::drop`] — stochastic regularization layers: `DropBlock`
//! (Ghiasi et al., 2018), `DropPath` (stochastic depth, Huang et al.,
//! 2016), and supporting types (`progressive_dpr` rate tables,
//! `SizeConfig`).
//!
//! See the per-item rustdoc for shape contracts, defaults, and the
//! papers each block implements.