Array equivalence analysis treats all arrays in element-wise expressions as having equivalent shape. However, dimensions with size 1 can be broadcast. The example below gives incorrect result instead of throwing an error.
One solution is to specialize to array size dimensions having 1; it will be part of the type in some sort semantically. We could also mention this limitation in documentation and live with it.
using ParallelAccelerator
ParallelAccelerator.ParallelIR.set_debug_level(3)
@acc function btest(A,B,C)
D1 = A.+B
D2 = B.+C
D1.+D2
end
A = ones(2,2)
B = ones(1,2)
C = ones(3,1)
println(btest(A,B,C))
[4.0 3.0; 4.0 1.0]
Array equivalence analysis treats all arrays in element-wise expressions as having equivalent shape. However, dimensions with size 1 can be broadcast. The example below gives incorrect result instead of throwing an error.
One solution is to specialize to array size dimensions having 1; it will be part of the type in some sort semantically. We could also mention this limitation in documentation and live with it.