cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
326 stars 92 forks source link

[API] Fix hcl.return_ within compute APIs #116

Closed seanlatias closed 5 years ago

seanlatias commented 5 years ago

Originally we do not support return statements inside compute APIs with multiple dimensions. The reason is that the indices of the tensors will be cast automatically, which results in incorrect behaviors in LLVM/CPU execution. Now the indices are unchanged. Following is a runnable example.

A = hcl.placeholder(10, 10, 10)
def compute(val):
    with hcl.if_(val > 0):
        hcl.return_(val)
    with hcl.else_():
        hcl.return_(0)
B = hcl.compute(A.shape, lambda *args: compute(A[args]))

This is also added as a test case.

seanlatias commented 5 years ago

In this PR we also limit the Numpy version for Python 2.7 support. We should stop supporting Python 2.7 soon.