Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/reinterpretarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ stride(A::Union{DenseArray,StridedReshapedArray,StridedReinterpretArray}, k::Int
k ≤ ndims(A) ? strides(A)[k] : length(A)

function strides(a::ReinterpretArray{T,<:Any,S,<:AbstractArray{S},IsReshaped}) where {T,S,IsReshaped}
_checkcontiguous(Bool, a) && return size_to_strides(1, size(a))
_checkcontiguous(Bool, a) && return size_to_strides(1, size(a)...)
stp = strides(parent(a))
els, elp = sizeof(T), sizeof(S)
els == elp && return stp # 0dim parent is also handled here.
Expand Down
3 changes: 3 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,9 @@ Base.size(::FakeZeroDimArray) = ()
# Zero dimensional parent
a = reshape(FakeZeroDimArray(),1,1,1)
@test @inferred(strides(a)) == (1, 1, 1)
# Dense parent (but not StridedArray)
A = reinterpret(Int8, reinterpret(reshape, Int16, rand(Int8, 2, 3, 3)))
@test check_strides(reshape(A, 3, 2, 3))
end

@testset "stride for 0 dims array #44087" begin
Expand Down
3 changes: 3 additions & 0 deletions test/reinterpretarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ end
end
@test check_strides(reinterpret(Float32, view(A, 8:-1:1, viewax2)))
end
# issue 46113
A = reinterpret(Int8, reinterpret(reshape, Int16, rand(Int8, 2, 3, 3)))
@test check_strides(A)
end

@testset "strides for ReshapedReinterpretArray" begin
Expand Down