Implicit requirements on parameter types of AssertStmt?

Hi all, I found an interesting problem about AssertStmt in tir part.

When I try to build this module about AssertStmt, I got such an error:

import tvm
from tvm import tir

v = tir.Var("v", "int32")
assert_stmt = tir.AssertStmt(v, v, tir.Evaluate(tir.const(0)))
prim_func = tir.PrimFunc({v}, assert_stmt)
mod = tvm.lower(prim_func)
tvm.build(mod)

But if I replace the condition variable with a comparison, I can build this module successfully:

It seems that although the parameter type of condition declared in the document is PrimExpr, actually there are some implicit requirements on it? Or we just implement the assert statement wrong? I’m curious the reason since this behavior works well in other languages like Python :joy::

1 Like