Repository navigation
v2.1.4 - Count nn.Bilinear instead of charging it nothing (#158)
馃専 Summary
THOP 2.1.4 now accurately counts nn.Bilinear operations instead of treating them as free, improving model complexity and compute reporting. 馃幆
馃搳 Key Changes
- Added
nn.Bilinearsupport to THOP鈥檚 operation-counting registry. - Introduced a dedicated
count_bilinearhook that accounts for both contractions performed by PyTorch. - Counts operations across standard, batched, and higher-dimensional inputs using the output tensor size.
- Updated the package version from 2.1.3 to 2.1.4.
- Change contributed by @raimbekovm in PR #158.
馃幆 Purpose & Impact
- More accurate profiling: Models using bilinear layers no longer report artificially low operation counts.
- Better comparisons: FLOPs/MACs estimates now better reflect the actual computational cost of architectures such as attention, fusion, and multimodal networks.
- Consistent behavior: The implementation follows THOP鈥檚 existing linear-layer counting convention without adding shape-specific branches.
- Improved resource planning: More reliable estimates can help users compare models and anticipate inference or training costs. 馃殌
What's Changed
- Count nn.Bilinear instead of charging it nothing by @raimbekovm in #158
Full Changelog: v2.1.3...v2.1.4