-
Notifications
You must be signed in to change notification settings - Fork 525
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
fix(pt): optimize createNlistTensor #4403
Conversation
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
Files not reviewed (2)
- source/api_cc/src/DeepPotPT.cc: Language not supported
- source/api_cc/src/DeepSpinPT.cc: Language not supported
📝 WalkthroughWalkthroughThe changes in this pull request involve significant refactoring of the tensor creation logic and error handling in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
source/api_cc/src/DeepPotPT.cc (1)
38-42
: Consider pre-allocating the flat_data vector with reserve.While the current implementation uses
reserve
, it could be more efficient to pre-allocate the exact size since we already know it.- flat_data.reserve(total_size); + flat_data.resize(total_size); + size_t offset = 0; for (const auto& row : data) { - flat_data.insert(flat_data.end(), row.begin(), row.end()); + std::copy(row.begin(), row.end(), flat_data.begin() + offset); + offset += row.size(); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
source/api_cc/src/DeepPotPT.cc
(1 hunks)source/api_cc/src/DeepSpinPT.cc
(1 hunks)
🔇 Additional comments (2)
source/api_cc/src/DeepPotPT.cc (2)
Line range hint 15-31
: LGTM! Improved error handling with specific PyTorch exception types.
The error handling implementation is well-structured and provides clear error messages for different types of PyTorch exceptions.
34-47
: LGTM! Efficient tensor creation implementation.
The implementation efficiently creates tensors by flattening the data first and then reshaping, which eliminates intermediate tensor structures.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## devel #4403 +/- ##
=======================================
Coverage 84.59% 84.59%
=======================================
Files 614 614
Lines 57009 57012 +3
Branches 3486 3486
=======================================
+ Hits 48224 48227 +3
+ Misses 7660 7659 -1
- Partials 1125 1126 +1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Summary by CodeRabbit
New Features
Bug Fixes