cornell-zhang / hcl-dialect

HeteroCL-MLIR dialect for accelerator design
https://cornell-zhang.github.io/heterocl/index.html
Other
40 stars 17 forks source link

Future Updates to hcl Tutorials #160

Closed smc447 closed 1 year ago

smc447 commented 2 years ago

Tutorial 1 need to add .v to a code snippet:

def simple_compute(a, A):

    B = hcl.compute(A.shape, lambda x, y: A[x, y] + a, "B")

Tutorial 7: need to add outline function because nested loop error message: raise RuntimeError( RuntimeError: hcl.return_ statement cannot be in a nested region due to MLIR's limitation. Please rewrite your program and use .outline() to create a new function.

Tutorial 8: works if you take out the +2 in indexing for computing. Since this tutorial is about the backend, you can probably take out the +2 . part of code causing the error:

A = hcl.placeholder((10, 10), "A")
def kernel(A):
    return hcl.compute((8, 8), lambda y, x: A[y][x] + A[y+2][x+2], "B")

Without taking out the +2 in the indexing, the error you get is:

Traceback (most recent call last):
  File "/export/scratch/users/smc447/tutorial/tutorial_08_2_backend.py", line 21, in <module>
    s = hcl.create_schedule_from_scheme(s)
  File "/home/smc447/heterocl-mlir/python/heterocl/scheme.py", line 16, in create_schedule_from_scheme
    return create_schedule(scheme.inputs, func=None, name=name)
  File "/home/smc447/heterocl-mlir/python/heterocl/schedule.py", line 165, in create_schedule
    return customize(inputs, func, name)
  File "/home/smc447/heterocl-mlir/python/heterocl/schedule.py", line 155, in customize
    raise e
  File "/home/smc447/heterocl-mlir/python/heterocl/schedule.py", line 153, in customize
    return build_schedule(inputs, func, name)
  File "/home/smc447/heterocl-mlir/python/heterocl/schedule.py", line 96, in build_schedule
    tensor.build()
  File "/home/smc447/heterocl-mlir/python/heterocl/tensor.py", line 47, in build
    self.op.build()
  File "/home/smc447/heterocl-mlir/python/heterocl/tensor.py", line 231, in build
    result_expr = self.fcompute(*iter_var)
  File "/export/scratch/users/smc447/tutorial/tutorial_08_2_backend.py", line 18, in <lambda>
    return hcl.compute((8, 8), lambda y, x: A[y][x] + A[y+2][x+2], "B")
  File "/home/smc447/heterocl-mlir/python/heterocl/tensor.py", line 96, in __getitem__
    return self.op.__getitem__(indices)
  File "/home/smc447/hcl-dialect-prototype/build/tools/hcl/python_packages/hcl_core/hcl_mlir/build_ir.py", line 1106, in __getitem__
    return TensorSlice(
  File "/home/smc447/hcl-dialect-prototype/build/tools/hcl/python_packages/hcl_core/hcl_mlir/build_ir.py", line 972, in __init__
    raise HCLValueError("{} is not an integer type or index type".format(index))
hcl_mlir.exceptions.HCLValueError: [Value Error] <hcl_mlir.build_ir.AddOp object at 0x7f08a0999a00> is not an integer type or index type

Tutorial 9: SODA not a supported target, so tutorial unable to run

zzzDavid commented 1 year ago

Thanks Sofia! The above issues have been solved, now the tutorials pass the test and have been added to the CI