-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
@inbounds
isn't propagated for CartesianIndices
#42115
Comments
Those implementations look ok to me; |
K. Trying with this ERROR: BoundsError: attempt to access 2-element Base.OneTo{Int64} at index [3]
Stacktrace:
[1] throw_boundserror(A::Base.OneTo{Int64}, I::Int64)
@ Base ./abstractarray.jl:691
[2] getindex
@ ./range.jl:863 [inlined]
[3] _broadcast_getindex_evalf
@ ./broadcast.jl:670 [inlined]
[4] _broadcast_getindex
@ ./broadcast.jl:643 [inlined]
[5] #29
@ ./broadcast.jl:1119 [inlined]
[6] ntuple
@ ./ntuple.jl:49 [inlined]
[7] copy
@ ./broadcast.jl:1119 [inlined]
[8] materialize
@ ./broadcast.jl:904 [inlined]
[9] getindex
@ ./multidimensional.jl:357 [inlined]
[10] inbounds_getindex(x::CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, i1::Int64, i2::Int64)
@ Main ./REPL[8]:1
[11] top-level scope
@ REPL[10]:1 This doesn't happen with I'm assuming that once we get into the broadcasting machinery there's a big risk of inadvertently messing things up, so could we just avoid broadcasting here: julia/base/multidimensional.jl Line 361 in 027071f
and instead just call |
Recent discussion in ArrayInterface.jl demonstrated that
@inbounds
isn't fully propagated when usingCartesianIndices
to convert an integer to aCartesianIndex
.Examples across multiple versions and hardware are more fully demonstrated here JuliaArrays/ArrayInterface.jl#199).
I think the offending line is the missing
@propagate_inbounds
here:julia/base/abstractarray.jl
Line 1254 in 027071f
This could probably be fixed here also:
julia/base/abstractarray.jl
Line 1242 in 027071f
I think @timholy and @mbauman wrote the original code here.
Can we just put
@propagate_inbounds
in front of these?The text was updated successfully, but these errors were encountered: