Repository navigation
Specialize ∇getindex! on the indices - #876
Merged
Merged
Conversation
Julia does not specialize on `inds...` that are only passed through, so the broadcasting `∇getindex!` methods allocated on every call (6 allocations and ~190 ns instead of 0 allocations and ~16 ns for a 100-element column). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #876 +/- ##
=======================================
Coverage 96.65% 96.65%
=======================================
Files 28 28
Lines 3615 3615
=======================================
Hits 3494 3494
Misses 121 121 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Julia doesn't specialize on Vararg arguments that are only passed through to another function (performance tips). As a result, the broadcasting
∇getindex!methods allocate on every call. These methods are used byunthunkandadd!of thegetindex/viewcotangents. Writinginds::Vararg{Any,N}) where {N}forces specialization.Example: accumulating a 100-element column,
∇getindex!(dx, dy, Base.Slice(Base.OneTo(100)), 7)mainThe PR adds a test that checks
∇getindex!doesn't allocate. It is independent of #875; whichever PR is merged second only needs a version bump.🤖 Generated with Claude Code