Open bartvanerp opened 2 years ago
I am not sure what is causing this issue
Basically, LoopVectorization parses the expression in a single pass. If you write
for m ∈ axes(A,1), n ∈ axes(B,2)
Cmn = zero(T)
then it records that Cmn
depends on m
and n
.
If you write
for m ∈ axes(A,1), n ∈ axes(B,2)
Cmn = b[m]
then it records that Cmn
depends on m
, because it doesn't know yet you're going to sum over it.
In hindsight, single-pass parsing that also deduces the structure/behavior of the loop was not a good idea. It'd be better to first build an analyzable internal representation, and then use this to derive meaning.
Long term, I am rewriting LoopVectorization, which will address that issue (among others).
Short term, the simplest fix would probably be to add an extra field to the Operation
struct that indicates the loop level it was initialized at, that the reduction code can later use. Should be a simple fix.
First of all, great package! I was trying to implement a slight alteration to the matrix multiplication example from the
Readme.md
:where I only changed the original line
Cmn = zero(eltype(C))
toCmn = b[m]
. Basically I want this function to returnA*X .+ b
. Although this change seems trivial in my eyes, the implementation gives:It seems that the inner
for
-loop is ignored andCmn
is only set tob[m]
. If I slightly change the above function the code works again:I am not sure what is causing this issue, but I can imagine that a lot of people might accidentally run into this.
LoopVectorization v0.12.101