⚡️ Speed up function point_line_distance by 28%#29
Open
codeflash-ai[bot] wants to merge 2 commits into
Open
Conversation
### Changes Made. 1. **In-place Operations**: Used `abs_()` to modify `numerator` in-place to save time by not creating a new object. 2. **Pre-calculation**: Calculated `denom_norm` only once instead of using `norm` to reduce function calls. 3. **Simplified Norm Calculation**: Calculated the norm manually without calling `norm` method for efficiency. This avoids potential overheads from additional checks or support for other configurations.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within 7 days. Thank you for your contributions! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📄 28% (0.28x) speedup for
point_line_distanceinkornia/geometry/linalg.py⏱️ Runtime :
5.39 milliseconds→4.22 milliseconds(best of104runs)📝 Explanation and details
Changes Made.
abs_()to modifynumeratorin-place to save time by not creating a new object.denom_normonly once instead of usingnormto reduce function calls.normmethod for efficiency. This avoids potential overheads from additional checks or support for other configurations.✅ Correctness verification report:
⚙️ Existing Unit Tests Details
🌀 Generated Regression Tests Details
To edit these changes
git checkout codeflash/optimize-point_line_distance-m8oc2zz0and push.