Skip to content

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

@chriselrod

Description

@chriselrod
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions