v2.1.6 - Release 2.1.6 (#174)
🌟 Summary
🚀 THOP 2.1.6 is a patch release that improves model-operation profiling accuracy and robustness while preserving the existing API and behavior for typical users.
📊 Key Changes
-
📦 Released THOP 2.1.6
- Updated the package version from
2.1.5to2.1.6. - No intentional breaking API changes.
- Updated the package version from
-
🧮 More accurate recurrent-layer profiling
- Packed RNN, GRU, and LSTM inputs are now counted using their actual processed sequence steps instead of the larger padded shape.
- LSTM projection layers now account for
proj_size, including the additional projection work and reduced recurrent width. - This produces more realistic operation estimates for variable-length sequences and projected LSTMs.
-
🧩 Improved custom operation support
profile_origin()now applies custom profiling rules to composite modules, matching the behavior of the standardprofile()function.- Custom operations that may have nonlinear computational costs now use direct profiling instead of inaccurate linear extrapolation.
-
🧱 Better handling of container and zero-operation modules
- Added support for containers such as
ModuleList,ModuleDict,ParameterList, andParameterDict. - Max-unpool layers are recognized as performing no arithmetic operations.
- Embedding lookups are correctly treated as data gathering rather than arithmetic computation.
- Embedding layers using
max_normemit a warning because their data-dependent renormalization is not counted. EmbeddingBagremains unregistered because its reduction cost depends on the input contents.
- Added support for containers such as
-
🛡️ Safer
total_opshandling- THOP now rejects modules that already use
total_opsfor parameters, child modules, or class-level properties. - This prevents profiling from silently corrupting module structure, parameter counts, or reported operation totals.
- THOP now rejects modules that already use
-
✅ Validation
- The complete test suite passed: 20 tests successful.
🎯 Purpose & Impact
- 📈 More trustworthy profiling results for packed sequences, projected LSTMs, custom modules, and complex model containers.
- ⚙️ Fewer false warnings when profiling models that use common PyTorch containers or embedding layers.
- 🧠 Better support for advanced architectures with custom operation rules and nonlinear computation patterns.
- 🔒 Improved reliability and error reporting when a model conflicts with THOP’s internal
total_opsbookkeeping. - 👍 For most users, this is a drop-in upgrade with no code changes required.
What's Changed
- Count a packed sequence by its real steps and read the LSTM projection by @raimbekovm in #160
- Let profile_origin count a composite module's own rule by @raimbekovm in #168
- Register the container and max-unpool types that compute nothing by @raimbekovm in #161
- Stop extrapolating a quadratic custom_ops rule as if it were affine by @raimbekovm in #167
- Register the embedding lookup and record why the bag is not counted by @raimbekovm in #165
- Reject a total_ops name a module already owns instead of misreading it by @raimbekovm in #171
- Release 2.1.6 by @glenn-jocher in #174
Full Changelog: v2.1.5...v2.1.6