Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

array broadcast rules in PA #139

Open
ehsantn opened this issue Feb 5, 2017 · 1 comment
Open

array broadcast rules in PA #139

ehsantn opened this issue Feb 5, 2017 · 1 comment
Assignees

Comments

@ehsantn
Copy link
Contributor

ehsantn commented Feb 5, 2017

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]
@ninegua
Copy link
Contributor

ninegua commented Feb 8, 2017

This was partly discussed in #35

In short, we do not support Julia's semantics of broadcast, and personally I don't think we can. We should amend our documentation to reflect this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants