order - fuse - order kernel logic#74
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Jutho
reviewed
Jul 15, 2026
Comment on lines
+118
to
+122
| g = 8 * sizeof(Int) - leading_zeros(M + 1) | ||
| importance = 2 .* (1 .<< (g .* (N .- indexorder(strides[1])))) | ||
| for k in 2:M | ||
| importance = importance .+ (1 .<< (g .* (N .- indexorder(strides[k])))) | ||
| end |
Member
There was a problem hiding this comment.
I have to admit that I forgot exactly how this cost model works 😄
Member
There was a problem hiding this comment.
Something like, the importance of a dimension is
sum over arrays of 2^(log2(M+2) * (N - indexorder of dimension in array))
So if an index is the first index in each of the arrays, its importance is
(M+1) * (M+2)^((N-1))
Jutho
reviewed
Jul 15, 2026
Comment on lines
+117
to
+118
| # ceil(Int, log2(M+2)) # to account for the fact that there are M arrays, where the first one is counted with a factor 2 | ||
| g = 8 * sizeof(Int) - leading_zeros(M + 1) |
Member
There was a problem hiding this comment.
Suggested change
| # ceil(Int, log2(M+2)) # to account for the fact that there are M arrays, where the first one is counted with a factor 2 | |
| g = 8 * sizeof(Int) - leading_zeros(M + 1) | |
| g = 8 * sizeof(Int) - leading_zeros(M + 1) # = ceil(Int, log2(M+2)) | |
| # to account for the fact that there are M arrays, where the first one is counted with a factor 2 |
Jutho
approved these changes
Jul 15, 2026
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.
Closes #72.
The previous approach was
fuse-order, where thefuseonly works if at least one of the input arrays is ordered in increasing strides. The pathological case beingpermutedims(A, (2,1)) .= permutedims(B, (2, 1)), where fusion is trivial but never happened.Here, I simply first order, then fuse, and then finally order again to make sure the leftover dim 1's from the fusion are migrated to the end.