-
Notifications
You must be signed in to change notification settings - Fork 584
Perf: replace unnecessary torch.split with indexing
#4505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Some operations only use the first segment of the result tensor of `torch.split`. In this case, all the other segments are created and discarded. This slightly adds an overhead to the training process.
📝 WalkthroughWalkthroughThis pull request introduces minor modifications in two Python files within the DeepMD project. The changes primarily focus on simplifying tensor manipulation by replacing Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (2)deepmd/pt/utils/nlist.py (1)
This change eliminates the overhead of creating unnecessary tensor segments. The direct slice deepmd/pt/model/descriptor/repformer_layer.py (1)
Replacing Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## devel #4505 +/- ##
==========================================
+ Coverage 84.41% 84.58% +0.17%
==========================================
Files 670 675 +5
Lines 62152 63575 +1423
Branches 3486 3486
==========================================
+ Hits 52465 53778 +1313
- Misses 8561 8671 +110
Partials 1126 1126 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
) Some operations only use the first segment of the result tensor of `torch.split`. In this case, all the other segments are created and discarded. This slightly adds an overhead to the training process. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Simplified tensor slicing operations in the `RepformerLayer` class and the `nlist_distinguish_types` function, enhancing readability and performance. - **Documentation** - Updated comments for clarity regarding tensor shapes in the `RepformerLayer` class. <!-- end of auto-generated comment: release notes by coderabbit.ai --> (cherry picked from commit 3cecca4)

Some operations only use the first segment of the result tensor of
torch.split. In this case, all the other segments are created and discarded. This slightly adds an overhead to the training process.Summary by CodeRabbit
Bug Fixes
RepformerLayerclass and thenlist_distinguish_typesfunction, enhancing readability and performance.Documentation
RepformerLayerclass.