Schedule creation error with hcl.if_ when used with hcl.or_
Closed this issue · 3 comments
def test_if_LogicalOr():
hcl.init()
def kernel():
a = hcl.scalar(0, "a", dtype=hcl.UInt(8))
b = hcl.scalar(0, "a", dtype=hcl.UInt(8))
# this generates the following error:
# File "hcl-dialect-prototype/build/tools/hcl/python_packages/hcl_core/hcl_mlir/build_ir.py", line 2630, in make_if
# raise HCLValueError("`if` operation condition should be CmpOp")
# hcl_mlir.exceptions.HCLValueError: [Value Error] `if` operation condition should be CmpOp
with hcl.if_(hcl.or_(a.v == 0, b.v == 0)):
pass
# this generates the following error:
# File "hcl-dialect-prototype/build/tools/hcl/python_packages/hcl_core/hcl_mlir/build_ir.py", line 1726, in build
# raise APIError("Do not build logical_or op")
# hcl_mlir.exceptions.APIError: [API] Do not build logical_or op
with hcl.if_(hcl.or_(a.v == 0, b.v == 0) != 0):
pass
s = hcl.create_schedule([], kernel)
Very similar to #135 (which is about hcl.while_ and hcl.and_)
logical or hasn't been implemented yet.
Relevant discussion threads:
- Why logical or is difficult to implement: #89
- How to support and/or with short-circuit evaluation: #65
My plan is to first add hcl.and
and hcl.or
representing logical operations with short-circuit evaluation, and then use nested scf.if
to implement them in LLVM backend. We will decouple condition evaluation and if/while operations, see details at #65.
Status update on this issue:
The new frontend build SCF operations for and/or, so there is no problem with affine_set not being able to support or anymore, and the above test case works.
We have not yet added logic operation that supports short-circuit evaluation yet.
Test case added by cornell-zhang/heterocl@9f7212f
Closing this thread because the issue has been resolved. Short-circuit logic op will be discussed in thread #65