Skip to content

Conversation

Tokazama
Copy link
Member

@Tokazama Tokazama commented Jun 10, 2022

This is intended to fix #304. There were two examples where we had errors in that PR.

This is what I get with this PR.

julia> n = 4;

julia> u_plain = randn(1, n, n, 1);

julia> u_vectors = reshape(reinterpret(Tuple{eltype(u_plain)}, u_plain), n, n, 1);

julia> u_view = view(u_vectors, :, 1, 1);

julia> u_final = reshape(reinterpret(eltype(u_plain), u_view), 1, length(u_view));

julia> ArrayInterface.StrideIndex(u_final)
ArrayInterface.StrideIndex{2, (1, 2), 1, Tuple{Static.StaticInt{1}, Int64}, Tuple{Static.StaticInt{1}, Static.StaticInt{1}}}((static(1), 1), (static(1), static(1)))

and...

julia> ArrayInterface.contiguous_axis(Base.ReshapedArray{Float64, 2,
    Base.ReinterpretArray{Float64, 1,
         StaticArrays.SVector{1, Float64},
            SubArray{StaticArrays.SVector{1, Float64}, 1,
                Base.ReshapedArray{StaticArrays.SVector{1, Float64}, 3,
                    Base.ReinterpretArray{
                        StaticArrays.SVector{1, Float64}, 4, Float64,
                        Array{Float64, 4}, false},
                         Tuple{}},
                 Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Int64}, true}, false}, Tuple{}}})
static(1)

This also changes dense_dims(::ReshapedArray) to return all falses when we know that the parent array isn't dense.

@codecov
Copy link

codecov bot commented Jun 10, 2022

Codecov Report

Merging #307 (d7a022e) into master (4245ffe) will increase coverage by 0.19%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##           master     #307      +/-   ##
==========================================
+ Coverage   90.93%   91.13%   +0.19%     
==========================================
  Files           9        9              
  Lines        1401     1398       -3     
==========================================
  Hits         1274     1274              
+ Misses        127      124       -3     
Impacted Files Coverage Δ
src/stridelayout.jl 89.80% <88.88%> (+0.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4245ffe...d7a022e. Read the comment docs.

@Tokazama Tokazama changed the title Avoid ReshapedArray error when contiguous_axis is nothing Avoid ReshapedArray error when contiguous_axis is nothing and fix dense_dims Jun 10, 2022
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

Successfully merging this pull request may close these issues.

Error in ArrayInterface.StrideIndex introduced between v6.0.11 and v6.0.12
2 participants