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.
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
Add rules and tests for
kron
#741base: main
Are you sure you want to change the base?
Add rules and tests for
kron
#741Changes from all commits
5bb9766
f0902e3
7c53f4b
c1226eb
236daf1
b2d4f4a
8b94cfc
b71b8ef
2ad5473
fde509e
4386143
1b97828
5b74071
72060d0
6650adc
f104172
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 403 in src/rulesets/LinearAlgebra/dense.jl
GitHub Actions / format
Check warning on line 424 in src/rulesets/LinearAlgebra/dense.jl
GitHub Actions / format
Check warning on line 436 in src/rulesets/LinearAlgebra/dense.jl
GitHub Actions / format
Check warning on line 448 in src/rulesets/LinearAlgebra/dense.jl
GitHub Actions / format
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.
I was wondering if you have to make slices, given that kron is just reshape and
.*
. So here's an attempt to do without:It's a pity to allocate these big arrays
dz4 .* y4
but still seems quicker. Possibly we could use lazy broadcasting to avoid that:On StaticArrays (mentioned above) both at present make a SizedMatrix, which I think is ProjectTo's attempt to fix things up. Surely this reshaping could be done in a static-friendly way but IDK exactly how.
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.
Does this result scale to larger arrays?
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.
Result meaning speed difference? It will vary with size & machine. On very small arrays reshaping is
fasterslower! (Like 3x3 I meant.)Issues with StaticArrays will be similar at all sizes.
I think broadcasting over slices will work badly on CuArrays, and tend to make Arrays. But right now neither idea seems to work, not sure why
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.
If the
reshape
version is not strictly better than the current one, especially for large arrays, I would propose to keep the current version and put further optimizations in a separate PR.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.
A bit curious at what sizes it's slower for you?
But mainly I think the issue is less about the race than that simple solid-array operations have a better chance of behaving well with StaticArrays, and CuArrays. I haven't taken another pass to see if the first draft can be improved on.
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.
I haven't benchmarked anything myself yet. I will give it a go later.
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.
Hmm, results seem to be mixed. For larger sizes the allocations are taking their price:
I would suggest staying with the current implementation.
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.
One way to ensure any implementation isn't excluding all GPU array types would be to toss a
@gpu
in front of the new tests, no?Check warning on line 163 in test/rulesets/LinearAlgebra/dense.jl
GitHub Actions / format