cornell-zhang / heterocl

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

[API][v0.3] Add Support for Copying From a Python List or Numpy Array #153

Closed seanlatias closed 4 years ago

seanlatias commented 4 years ago

With this PR, now users can create a HeteroCL tensor from a Python list or a Numpy array by using the existing hcl.copy API. An example is shown below.

arr = [[1, 2, 3], [4, 5, 6]]
A = hcl.copy(arr, "A", hcl.Int())
s = hcl.create_schedule([A])

The arr in the above example can also be a Numpy array. More examples can be seen under the tests folder.