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
//! # Convolution support
//!
//! Everything around convolution that is not itself a trainable layer. The
//! layers are burn's ([`Conv1d`], [`Conv2d`]); the composites built from them
//! are in [`crate::blocks::conv`].
//!
//! ## Why pure shape functions
//!
//! Given a convolution's kernel size, stride, padding, and dilation, what
//! output shape does it produce? burn answers this implicitly when you call
//! `forward`. This module gives the same answer as a pure function, which is
//! what a config or a `{Name}Meta` trait needs to advertise its output size
//! before any tensor exists. [`ConvBlock2dMeta::try_output_resolution`] and
//! the `ResNet` downsample are built on it.
//!
//! ## Map
//!
//! - **Shape arithmetic.** [`maybe_conv1d_output_size`] for one axis;
//! [`maybe_conv_output_shape`] over a `[usize; D]` shape, and
//! [`maybe_conv_output_shape_dyn`] over slices, for a rank known only at run
//! time. Each `maybe_*` returns `None` when no output is legal (the kernel
//! does not fit the padded input); its `expect_*` twin panics instead.
//! [`stride_div_output_resolution`] is the downsample-by-stride shortcut.
//! - **Padding.** [`get_square_conv2d_padding`] and
//! [`build_square_conv2d_padding_config`] give the symmetric padding for a
//! square kernel. [`get_same_padding`] and [`pad_same`] give TensorFlow-style
//! "SAME" padding, which may be asymmetric and is applied to the input rather
//! than configured on the layer; [`AvgPool2dSame`] uses it.
//! - **Initialization.** [`CONV_INTO_RELU_INITIALIZER`] for a conv layer
//! feeding a `ReLU`.
//! - **Functional convolution.** [`convolve_func_2d`] unfolds every window of a
//! `[batch, c_in, height, width]` input and hands them to one closure in a
//! single call, for window functions that are not a linear `Conv2d`.
//! - **Filters.** [`conv2d_kernel_midpoint_filter`] builds a 0/1 mask of the
//! positions where a kernel's midpoint can land;
//! [`drop_block_2d`](crate::ops::drop::drop_block_2d) uses it.
//!
//! [`Conv1d`]: burn::nn::conv::Conv1d
//! [`Conv2d`]: burn::nn::conv::Conv2d
//! [`ConvBlock2dMeta::try_output_resolution`]: crate::blocks::conv::ConvBlock2dMeta::try_output_resolution
//! [`AvgPool2dSame`]: crate::blocks::images::pool::AvgPool2dSame
pub use *;
pub use *;
pub use *;
pub use *;