-
Notifications
You must be signed in to change notification settings - Fork 79
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
[WIP] fix permutedims #334
Conversation
Why does this work with a NTuple of 16 elements+ but not with a similar CartesianIndex? I'd rather not duplicate the Cartesian<->Linear conversions here... |
julia> x = (fill(2, 15)...,)
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
julia> @benchmark CartesianIndices($x)[3]
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 84.947 ns (0.00% GC)
median time: 85.537 ns (0.00% GC)
mean time: 86.939 ns (0.00% GC)
maximum time: 183.274 ns (0.00% GC)
--------------
samples: 10000
evals/sample: 963
julia> x = (fill(2, 16)...,)
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
julia> @benchmark CartesianIndices($x)[3]
BenchmarkTools.Trial:
memory estimate: 4.39 KiB
allocs estimate: 73
--------------
minimum time: 3.644 μs (0.00% GC)
median time: 3.713 μs (0.00% GC)
mean time: 4.002 μs (0.98% GC)
maximum time: 68.644 μs (92.66% GC)
--------------
samples: 10000
evals/sample: 8 I think it might be related to tuple splatting. Current CartesianIndices getindex is
Related issues JuliaLang/julia#27398 , but it seems was fixed since 2018... |
For
|
@maleadt Maybe we should not use e.g.
Shall I go ahead to remove all CartesianIndices? Or maybe I should submit a PR to julia base to change the behavior of CartesianIndices? EDIT: just looked into the Julia base code, it is not easy to fix. |
That seems like the nuclear option. As I already expressed in this PR, I'm really not a fan of duplicating functionality, let alone removing reuse of functionality that works just fine in almost all cases. Could you isolate the actual problem with permutedims, or CartesianIndices in general? I'd rather parametrize the compiler such that these patterns do just work. |
Close because this issue is reolved by @kshyatt 's PR in upstream: JuliaLang/julia#40468 One can upgrade Julia to 1.7 to get rid of this issue. |
Fix the its behavior on high dimensional arrays, see issue #333