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

hcl.asarray doesn't work with 64-bit "python" integers #402

Open jcasas00 opened 3 years ago

jcasas00 commented 3 years ago

Code:

    inp = [[1, 1085102592571150095], [13, 14106333703424951235]]
    out = hcl.asarray(inp, dtype=hcl.UInt(64))
    print(f"out={out}")

Output:

out=[[4607182418800017408 4876868561191968286]
 [4623507967449235456 4893293453950613624]]

From briefly trying to debug this, the issue seems to be:

W/A is to do something like: hcl.asarray (np.array (inp, dtype=np.ulonglong), dtype=hcl.UInt(64)).

Should fix hcl.asarray, especially since the dtype is specified. As is, it is basically silently passing garbage data.