Use the `pytorch` backend for CNN analytics
masterThe pytorch backend is a legacy mode that considers nn.Modules only. It is recommended for CNNs because it provides better per-layer analytics. Do not use this backend for Transformer architectures.
Supported Layers:
- Conv1d/2d/3d (including grouping)
- ConvTranspose1d/2d/3d (including grouping)
- BatchNorm1d/2d/3d, GroupNorm, InstanceNorm1d/2d/3d, LayerNorm
- Activations (ReLU, PReLU, ELU, ReLU6, LeakyReLU, GELU)
- Linear
- Upsample
- Poolings (AvgPool1d/2d/3d, MaxPool1d/2d/3d and adaptive ones)
- Experimental: RNN, LSTM, GRU, MultiheadAttention, DeformConv2d, and
timmvision transformers.
Usage Tips:
- If functional-level hooks conflict with custom
nn.Modulehooks, disable them usingbackend_specific_config={"count_functional": False}. - To handle models with multiple or optional inputs, use the
input_constructorargument. This is a function that takes the input spatial resolution as a tuple and returns a dictionary of named input arguments. - Use
ignore_modulesto skip specific layers (e.g.,ignore_modules=[torch.nn.Conv2d]). - Use
verbose=Trueto see modules that do not contribute to the final complexity count.