cornell-zhang/heterocl

Error Messaging Enhancement

Closed this issue · 1 comments

Description

Users often face difficulties when debugging HeteroCL programs: the error message does not point to the line of error, leaving users guessing it from stack trace.

Example

In a scalar add example, users might be unsure whether to use .v.

import heterocl as hcl
def test():
    hcl.init()
    A = hcl.placeholder((1,), "A")=
    def algo(A):
        A = A.v + 1 # user forgets left .v
        return A
    s = hcl.create_schedule([A], algo)
    f = hcl.build(s, name="main")

The error stack trace:

Traceback (most recent call last):
  File "heterocl_debug_example.py", line 20, in <module>
    test()
  File "heterocl_debug_example.py", line 15, in test
    f = hcl.build(s, name="main")
  File "~/heterocl/python/heterocl/api.py", line 308, in build
    new_inputs.append(i.var)
  File "~/heterocl/python/heterocl/tvm/_ffi/_ctypes/node.py", line 60, in __getattr__
    "'%s' object has no attribute '%s'" % (str(type(self)), name))
AttributeError: '<class 'heterocl.tvm.expr.Add'>' object has no attribute 'var'

Most of time the stack trace only points to hcl.build. In a more complex project, user has to find out the cause by commenting out the code until the error disappears.

More examples will be added in the future.

As we have released a new version of HeteroCL that entirely moves the compilation stack to MLIR, issues related to the original HalideIR flow will be closed.