-
Notifications
You must be signed in to change notification settings - Fork 37
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
Bug in strides
of reshaped adjoint/transposed arrays
#162
Comments
strides
of reshaped adjoint/transposed/permuted arraysstrides
of reshaped adjoint/transposed arrays
Another example (continuing the one above): julia> ArrayInterface.strides(vec(A'))
(static(1),) This doesn't make sense at all since |
The first example here is fixed. Did we want an error on the second one? This is what we get now: julia> ArrayInterface.strides(vec(A'))
ERROR: ArgumentError: Input is not strided. |
Yes, this sounds reasonable to me since the input is indeed not a plain strided vector.
I get (@v1.7) pkg> activate --temp
Activating new project at `/tmp/jl_4vH1Gz`
(jl_4vH1Gz) pkg> add ArrayInterface
Updating registry at `~/.julia/registries/General.toml`
Resolving package versions...
Updating `/tmp/jl_4vH1Gz/Project.toml`
[4fba245c] + ArrayInterface v6.0.14
julia> using ArrayInterface
julia> A = rand(5,12);
julia> B = reshape(A', (3,4,5));
julia> ArrayInterface.strides(B) # @chriselrod: should be `(5,15,StaticInt{1}())`
(5, 15, 1) When reporting this, @chriselrod mentioned it should be |
It should not be static. julia> A = rand(5,12);
julia> B = reshape(A', (3,4,5));
julia> C = randn(1,60);
julia> D = reshape(C', (3,4,5));
julia> typeof(B) == typeof(D)
true
julia> using ArrayInterface
julia> ArrayInterface.strides(B)
(5, 15, 1)
julia> ArrayInterface.strides(D)
(1, 3, 12) |
Both
|
I know non-static result might cause performance issue. But, the above example shows that we can't derive the dense dimension with the current type information. One possible solution is adding some |
Why is Does base have special casing based on array size changing how cartesian indices are mapped to linear? |
Interesting, those strides are indeed correct. So, when you reshape an axis, the reshape is in column-major order. julia> C = randn(1,60);
julia> D = reshape(C', (3,4,5));
julia> A = rand(5,12);
julia> B = reshape(A', (3,4,5)); Maybe LV should just do a dynamic dispatch (or, hopefully a union-split) in a case like this. |
Reported by @chriselrod in #161 (comment):
The text was updated successfully, but these errors were encountered: