Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule creation error with hcl.if_ when used with hcl.or_ #138

Closed
jcasas00 opened this issue Aug 31, 2022 · 3 comments
Closed

Schedule creation error with hcl.if_ when used with hcl.or_ #138

jcasas00 opened this issue Aug 31, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jcasas00
Copy link
Collaborator

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_)

@zzzDavid zzzDavid self-assigned this Sep 3, 2022
@zzzDavid zzzDavid added the bug Something isn't working label Sep 3, 2022
@zzzDavid
Copy link
Collaborator

zzzDavid commented Sep 8, 2022

logical or hasn't been implemented yet.

Relevant discussion threads:

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.

@zzzDavid
Copy link
Collaborator

zzzDavid commented Feb 1, 2023

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.

@zzzDavid
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants