Skip to content
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

Some reshapes of subarrays are strided, but StrideIndex fails. #10

Open
chriselrod opened this issue Nov 17, 2021 · 2 comments
Open

Some reshapes of subarrays are strided, but StrideIndex fails. #10

chriselrod opened this issue Nov 17, 2021 · 2 comments

Comments

@chriselrod
Copy link
Contributor

julia> ix = 2;

julia> A = rand(7, 5, 6);

julia> src = view(view(A,ix, :, :),:);

julia> ArrayInterface.StrideIndex(src)
ERROR: TypeError: in typeassert, expected Tuple{Int64}, got a value of type Nothing
Stacktrace:
 [1] (ArrayInterface.StrideIndex{1, nothing, nothing})(s::Tuple{StaticInt{1}}, o::Tuple{StaticInt{1}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:197
 [2] (ArrayInterface.StrideIndex{1, nothing, nothing})(a::SubArray{Float64, 1, Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:200
 [3] ArrayInterface.StrideIndex(a::SubArray{Float64, 1, Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:203
 [4] top-level scope
   @ REPL[25]:1

julia> ArrayInterface.StrideIndex(vec(view(A,ix,:,:)))
ERROR: TypeError: in typeassert, expected Tuple{Int64}, got a value of type Nothing
Stacktrace:
 [1] (ArrayInterface.StrideIndex{1, nothing, nothing})(s::Tuple{StaticInt{1}}, o::Tuple{StaticInt{1}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:197
 [2] (ArrayInterface.StrideIndex{1, nothing, nothing})(a::Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:200
 [3] ArrayInterface.StrideIndex(a::Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:203
 [4] top-level scope
   @ REPL[26]:1

Basically, if collapsed dims are dense with respect to one another, collapsing them presevers strided-ness.

We should also redefine dense dims as necessary to be a statement only about that dim.

julia> ArrayInterface.dense_dims(view(A,ix,:,:))
(static(false), static(false))

So that the first dim is not dense, but the second one still is w/ respect to the first.

@chriselrod
Copy link
Contributor Author

Would fix: JuliaSIMD/LoopVectorization.jl#365

@Tokazama
Copy link
Member

So could we solve this by just fixing dense_dims?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants