Closed zzzDavid closed 1 year ago
Behavior still isn't quite the same as in the main branch. If the do loop looked like:
def do(i,j,k):
t = z1[0][0] # a slice
t[0] = 53
then I get the same error. The reason for doing this is that we could pass the variable t to other functions (a 1-D tensorslice).
Reopening this issue
hmmm I couldn't repeat this issue, I tried this:
def test_tensor_slice():
hcl.init()
def kernel():
z1 = hcl.compute((2,3,4), lambda x,y,z: 0, dtype=hcl.Int(32))
def do(i,j,k):
t = z1[0][0]
t[0] = 53
hcl.mutate(z1.shape, do)
return z1
s = hcl.create_schedule([], kernel)
hcl_res = hcl.asarray(np.zeros((2,3,4), dtype=np.int32))
f = hcl.build(s)
f(hcl_res)
np_res = hcl_res.asnumpy()
golden = np.zeros((2,3,4), dtype=np.int32)
golden[0][0][0] = 53
assert np.array_equal(golden, np_res)
print("test_tensor_slice passed")
test_tensor_slice()
And I got the test passed output:
Using mlir as IR
Done HCL-MLIR initialization
test_tensor_slice passed
@jcasas00 are you using the latest HeteroCL HCL-MLIR branch?
Turns out it's issue with __getitem__
API on tensor slice. Fixed by 3d1f4298c074ee65f7547dc73c2dc856a810ea91, I will close this issue later after I add more tests
The following tests are added by commit cornell-zhang/heterocl@c7d72eed9821cd13bd6318e31c94d2e26f8043b0:
mlir/test_dsl_basic.py::test_tensor_slice_mutate PASSED
mlir/test_dsl_basic.py::test_get_bit_expr_mutate PASSED
mlir/test_dsl_basic.py::test_set_bit_expr_mutate PASSED
mlir/test_dsl_basic.py::test_set_bit_tensor_mutate PASSED
mlir/test_dsl_basic.py::test_get_slice_expr_mutate PASSED
mlir/test_dsl_basic.py::test_get_slice_tensor_mutate PASSED
mlir/test_dsl_basic.py::test_get_slice_tensor_reverse_mutate PASSED
mlir/test_dsl_basic.py::test_set_slice_expr_mutate PASSED
mlir/test_dsl_basic.py::test_set_slice_tensor_mutate PASSED
mlir/test_dsl_basic.py::test_set_slice_tensor_reverse_mutate PASSED
mlir/test_dsl_basic.py::test_slice_op_mutate PASSED
The following code reports error: