-
Notifications
You must be signed in to change notification settings - Fork 584
perf: skip bincount if unnecessary #4773
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
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.
Pull Request Overview
The PR aims to optimize performance by skipping the costly bincount operation when it is unnecessary. Key changes include adding a conditional to determine whether to compute torch.bincount, updating the logic to adjust the output tensor shape based on available information, and overriding num_owner in specific cases.
Comments suppressed due to low confidence (1)
deepmd/pt/model/network/utils.py:40
- Overriding 'num_owner' with bin_count.shape[0] in the else branch may ignore a user-provided value when average is True. Please confirm if this behavior is intentional and update the docstring if needed for clarity.
else:
📝 Walkthrough""" WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant aggregate
Caller->>aggregate: Call aggregate(src, index, num_owner, avg)
alt num_owner is None or avg is True
aggregate->>aggregate: Compute bin_count
alt num_owner specified and larger
aggregate->>aggregate: Extend bin_count with ones
end
aggregate->>aggregate: Replace zero bin_count with ones
else
aggregate->>aggregate: Skip bin_count computation
end
aggregate->>aggregate: Initialize output tensor with zeros
aggregate->>aggregate: Perform index_add_ aggregation
alt avg is True
aggregate->>aggregate: Divide output by bin_count
end
aggregate-->>Caller: Return aggregated output
""" 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (30)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #4773 +/- ##
=======================================
Coverage 84.79% 84.79%
=======================================
Files 698 698
Lines 67734 67750 +16
Branches 3540 3540
=======================================
+ Hits 57432 57449 +17
Misses 9171 9171
+ Partials 1131 1130 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit