AssertStmt specification

I’m looking at AssertStmt here:

https://docs.tvm.ai/api/python/dev.html#tvm.stmt.AssertStmt

The documentation doesn’t say very specifically what this op does (maybe there exists a different more in-depth doc source?).

Will the program be terminated if the condition is false?
Assuming the program is terminated, is this a guaranteed side-effect that will happen at the indicated time in the program, or is that more relaxed?
What happens with the error message, is it just returned, or is it presented to the user; where does it go?

I suppose the condition is intended to be guaranteed true only within the body of the AssertStmt, however I don’t quite understand that. Suppose I do (pseudocode):

if (…) {
AssertStmt(x is even, “x wasn’t even”, Foo())
Bar()
}

Then x is guaranteed to be even within Foo(), but isn’t it also guaranteed to be true at Bar(), given that the AssertStmt dominates Bar()? And if so, why is there a nested part to an AssertStmt? Or is the concern that the condition can become false if it contains mutable state loaded from memory? (I was thinking this was all immutable, but maybe not)

The assert is mainly used to give additional information about the conditions of the arguments. At the moment we do not reorder them and thus there is no clear document about the strictness of the side effect. Because they only sits function boundaries, it has not yet becomes a perf problem.

They are translated to CHECK that will throw error message into runtime as the checks are all on the host side.

The body nesting is mainly to make writing of such analysis code easier(as we do not have to maintain it for every stmt that introduces a new scope). So in your case while Bar still can take benefit of the condition, we will most likely wrap Bar inside body.