Repository navigation
Conversation
Fused dimensions are kept as trailing dimensions of size 1, which still cost a loop each in the kernel. The kernel now forwards to the kernel for its non-singleton dimensions. The views are rewrapped with the lower dimensionality, so that this kernel is the same one that arrays of that dimensionality compile, rather than one extra kernel per dimensionality and type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Builds on #97.
order_and_fuse_dimskeeps fused dimensions as trailing dimensions of size 1, and the kernel still runs a loop for each of them. This PR makes the kernel forward to the kernel for its non-singleton dimensions instead.Compiling a lower-dimensional kernel for every dimensionality would add to the compile time of every first call. To limit that, the views are rewrapped with the lower dimensionality via
StridedViews.unsafe_stridedview, so the forwarded kernel is the same method instance that arrays of that dimensionality compile. The kernel only indexes the parents with the strides it is given, so the view strides need no normalization. This requires StridedViews 0.5.5.Trade-off
The runtime gain is modest, and the compile-time cost is real, so this is a draft to discuss whether it is worth it.
Runtime,
C = α * permutedims(A, p)via_mapreducedim!, ns, against #97:The difference beyond 4 elements is within the noise. The gain is larger for direct kernel calls that leave many trailing singletons, such as the
permutedims!in the follow-up PR.First calls in a fresh session:
map!(different functions and types)The rewrapping makes the lower-dimensional kernels shared when the function and element types repeat, but each distinct call still compiles about 1.5× more. The test suite also takes noticeably longer to compile.
The tests pass, single- and multi-threaded (4 threads), including the JLArray and Aqua tests.
🤖 Generated with Claude Code