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

[TensorIR][UX] Type annotation-based runtime type checking #9559

Merged
merged 3 commits into from
Nov 23, 2021
Merged

[TensorIR][UX] Type annotation-based runtime type checking #9559

merged 3 commits into from
Nov 23, 2021

Conversation

junrushao
Copy link
Member

Addressed the UX issue raised in #9551.

To address the first issue (cryptic error message on packed function boundary), this PR introduced a decorator @type_checked to do runtime type checking and generate more user-friendly error messages. In our example:

image

The second issue is mainly wording. This PR rephrasing the error message to:

ValueError: The loop no long exists in the IRModule

However, I cannot find any environment variable to disable stacktrace printing. It was there months ago but no longer exists...Weird...

The notebook: https://gist.github.com/junrushao1994/cd0a33dc966da3b3f1abfa50a14e6d2c

CC: @tqchen

@junrushao
Copy link
Member Author

Looks like we need at least python 3.7 to run the decorator…

@tqchen
Copy link
Member

tqchen commented Nov 23, 2021

on the c++ stacktrace side, perhaps the main thing is to update the trace normalizer to simplify and skip some of the less informative traces(e.g. unpackcall_dispatcher) but keep the rest of the useful traces

@junrushao
Copy link
Member Author

on the c++ stacktrace side, perhaps the main thing is to update the trace normalizer to simplify and skip some of the less informative traces(e.g. unpackcall_dispatcher) but keep the rest of the useful traces

Alternatively, there are other metaprogramming tricks to completely avoid recursion and could potentially generate significantly better error message.

@junrushao
Copy link
Member Author

Update with a py36 compatible implementation

@junrushao
Copy link
Member Author

The error message is improved to:

TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_307968/1279557970.py in <module>
      5 i = sch.get_loops(block_c)
      6 # Tile the loop nesting.
----> 7 i_0, i_1, i_2 = sch.split(i, factors=[None, 4, 4])
      8 print(sch.mod.script())

~/Projects/tvm-dev/python/tvm/tir/schedule/_type_checker.py in wrap(*args, **kwargs)
    147                 )
    148                 if error_msg is not None:
--> 149                     raise TypeError(error_msg)
    150         return func(*args, **kwargs)
    151 

TypeError: In "Schedule.split", "loop" has wrong type. Expected "LoopRV", but gets: "list"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UX] Improve TensorIR jupyter misuse error message improvement suggestions
3 participants