cornell-zhang/hcl-dialect

[Frontend] Support return expression for `hcl.return_`

Closed this issue · 1 comments

Related tests:

  • mlir/test_dsl_def.py::test_module_multi_calls
    Error message:
Traceback (most recent call last):
  File "mlir/test_dsl_def.py", line 272, in <module>
    test_module_multi_calls()
  File "mlir/test_dsl_def.py", line 253, in test_module_multi_calls
    s = hcl.create_schedule([A, B], algorithm)
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/schedule.py", line 153, in create_schedule
    raise e
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/schedule.py", line 151, in create_schedule
    return build_schedule(inputs, func, name)
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/schedule.py", line 67, in build_schedule
    ret = func(*inputs)
  File "mlir/test_dsl_def.py", line 248, in algorithm
    return hcl.compute(A.shape, lambda x: mul(A, B, x))
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/operation.py", line 212, in compute
    ret_tensor = Tensor(shape, dtype, name=name,
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/tensor.py", line 39, in __init__
    self.build()
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/tensor.py", line 47, in build
    self.op.build()
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/tensor.py", line 227, in build
    result_expr = self.fcompute(*iter_var)
  File "mlir/test_dsl_def.py", line 248, in <lambda>
    return hcl.compute(A.shape, lambda x: mul(A, B, x))
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/dsl.py", line 327, in wrapped_func
    fmodule(*inputs)
  File "mlir/test_dsl_def.py", line 246, in mul
    hcl.return_(temp[0])
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/dsl.py", line 398, in return_
    Schedule._CurrentStage[-1].op.iter_var,
AttributeError: 'Stage' object has no attribute 'iter_var'

The error is thrown building expression hcl.return_(temp[0])

  • mlir/test_dsl_def.py::test_module_ret_dtype
    Error message:
error: 'builtin.func' op entry block must have 3 arguments to match function signature
loc("-":6:3): error: 'builtin.func' op entry block must have 3 arguments to match function signature
Traceback (most recent call last):
  File "mlir/test_dsl_def.py", line 305, in <module>
    test_module_ret_dtype()
  File "mlir/test_dsl_def.py", line 287, in test_module_ret_dtype
    f = hcl.build(s)
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/build_module.py", line 72, in build
    raise e
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/build_module.py", line 70, in build
    return build_llvm(schedule, target, stmt)
  File "/work/shared/users/phd/nz264/mlir/heterocl/python/heterocl/mlir/build_module.py", line 315, in build_llvm
    module = Module.parse(str(schedule.device_module), ctx)
ValueError: Unable to parse module assembly (see diagnostics)

This issue is probably related to the outlined function signature

The revamped frontend solved this issue cornell-zhang/heterocl#473, the above test case passed. Closing the thread.