JuliaSIMD / JuliaSIMD/LoopVectorization.jl

index error for a high dimensional array contraction

Offen
#370 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Julia
Sterne
789
Forks
73
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

to reproduce

```julia
function simpile_tm(A)
A_dag = permutedims(A, (2, 1, 3))
O = reshape(Consts.O, ntuple(_->2, 8))
lhs = ntuple(_->size(A, 1), 4)
rhs = ntuple(_->size(A, 2), 4)

shape = (lhs..., rhs..., rhs..., lhs...)
T = zeros(shape...)
@avx for a in axes(A, 1), b in axes(A, 2),
c in axes(A, 1), d in axes(A, 2),
e in axes(A, 1), f in axes(A, 2),
g in axes(A, 1), h in axes(A, 2),

m in axes(A, 2), n in axes(A, 1),
o in axes(A, 2), p in axes(A, 1),
q in axes(A, 2), r in axes(A, 1),
s in axes(A, 2), t in axes(A, 1)

S = 0.0
for i in axes(A, 3), j in axes(A, 3),
k in axes(A, 3), l in axes(A, 3),
u in axes(A, 3), v in axes(A, 3),
w in axes(A, 3), x in axes(A, 3)

S += A[a,b,i] * A[c,d,j] * A[e,f,k] * A[g,h,l] *
O[i,j,k,l,u,v,w,x] *
A_dag[m,n,u] * A_dag[o,p,v] * A_dag[q,r,w] * A_dag[s,t,x]
end
T[a,c,e,g,m,o,q,s,b,d,f,h,n,p,r,t] = S
end
return reshape(T, 1296, 1296)
end

simple_tm(rand(2, 3, 2))
```

on LoopVectorization v0.12.99, stacktrace

```julia
julia> T1 = simpile_tm(A1)
ERROR: LoadError: BoundsError: attempt to access 25-element Vector{Int64} at index [0]
Stacktrace:
[1] getindex
@ ./array.jl:861 [inlined]
[2] #77
@ ~/.julia/packages/LoopVectorization/kVenK/src/reconstruct_loopset.jl:427 [inlined]
[3] mapreduce_first
@ ./reduce.jl:394 [inlined]
[4] mapreduce_impl(f::LoopVectorization.var"#77#78"{Vector{Int64}}, op::typeof(max), A::Vector{Int64}, first::Int64, last::Int64)
@ Base ./reduce.jl:614
[5] _mapreduce(f::LoopVectorization.var"#77#78"{Vector{Int64}}, op::typeof(max), #unused#::IndexLinear, A::Vector{Int64})
@ Base ./reduce.jl:417
[6] _mapreduce_dim
@ ./reducedim.jl:330 [inlined]
[7] #mapreduce#725
@ ./reducedim.jl:322 [inlined]
[8] mapreduce
@ ./reducedim.jl:322 [inlined]
[9] #_maximum#743
@ ./reducedim.jl:894 [inlined]
[10] _maximum
@ ./reducedim.jl:894 [inlined]
[11] #maximum#741
@ ./reducedim.jl:890 [inlined]
[12] maximum
@ ./reducedim.jl:890 [inlined]
[13] calcnops
@ ~/.julia/packages/LoopVectorization/kVenK/src/reconstruct_loopset.jl:427 [inlined]
[14] avx_loopset!(ls::LoopVectorization.LoopSet, instr::Vector{LoopVectorization.Instruction}, ops::Vector{LoopVectorization.OperationStruct}, arf::Vector{LoopVectorization.ArrayRefStruct}, AM::Vector{Any}, LPSYM::Vector{Any}, LB::Core.SimpleVector, vargs::Core.SimpleVector)
@ LoopVectorization ~/.julia/packages/LoopVectorization/kVenK/src/reconstruct_loopset.jl:637
[15] _turbo_loopset(OPSsv::Any, ARFsv::Any, AMsv::Any, LPSYMsv::Any, LBsv::Core.SimpleVector, vargs::Core.SimpleVector, UNROLL::Tuple{Bool, Int8, Int8, Int8, Bool, Int64, Int64, Int64, Int64, Int64, Int64, Int64, UInt64})
@ LoopVectorization ~/.julia/packages/LoopVectorization/kVenK/src/reconstruct_loopset.jl:691
[16] #s166#85
@ ~/.julia/packages/LoopVectorization/kVenK/src/reconstruct_loopset.jl:717 [inlined]
[17] var"#s166#85"(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, vargs#::Any, ::Any, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Any, var#arguments#::Any)
@ LoopVectorization ./none:0
[18] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
@ Core ./boot.jl:580
[19] simpile_tm(A::Array{Float64, 3})
@ Main ~/code/julia/RenyiEntropyOfMagic/test/runtests.jl:90
[20] top-level scope
@ ~/code/julia/RenyiEntropyOfMagic/test/runtests.jl:129
in expression starting at /home/roger/code/julia/RenyiEntropyOfMagic/test/runtests.jl:129
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start with the provided @avx reproducer and inspect calcnops in reconstruct_loopset.jl around line 427, then follow the avx_loopset! call in the stack trace. Re-run the example with LoopVectorization v0.12.99; done means the high-dimensional contraction no longer raises the reported BoundsError.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
julia
Bereich
performance
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.