cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
322 stars 92 forks source link

[API] Raise exception when `hcl.assert` fails #414

Closed seanlatias closed 3 years ago

seanlatias commented 3 years ago

Fixed issue: #413

Detailed description: Now when hcl.assert failed, an exception will be raised. Users can turn off the exception by setting hcl.init(raise_assert_exception=False). An example program to catch the assertion fail looks like this

def kernel(...):
    ...
    hcl.assert_(xxx)

s = hcl.create_schedule()
f = hcl.build(s)

try:
    f(args)
except hcl.debug.AssertError:
    # handle the exception

Link to the tests: Add one test under test_api_assert.py.