-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
With julia --check-bounds=yes, bounds are checked when directly accessing arrays:
julia> using StrideArraysCore
julia> zeros_stridearray(size...) = StrideArray(zeros(Float32, size...), static.(size))
zeros_stridearray (generic function with 1 method)
julia> x = zeros_stridearray(8, 8, 12, 64);
julia> x[1, 1, 1, 65]
ERROR: BoundsError: attempt to access 8×8×12×64 PtrArray [output truncated by me]
No such check happens when creating a view:
julia> view(x, 1, 1, 1, 65)
0-dimensional StrideArray{Float32, 0, (), Tuple{}, Tuple{}, Tuple{}, Array{Float32, 4}}:
0.0
julia> view(x, :, 1, 1, 65)
8-element StrideArray{Float32, 1, (1,), Tuple{StaticInt{8}}, Tuple{Nothing}, Tuple{StaticInt{1}}, Array{Float32, 4}} with indices static(1):static(8):
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
By chance, I also noticed this incorrect behavior:
julia> view(x, 1)
ERROR: StackOverflowError:
julia> x = zeros(8, 8, 12, 64);
julia> view(x, 1)
0-dimensional view(::Vector{Float64}, 1) with eltype Float64:
0.0
Metadata
Metadata
Assignees
Labels
No labels