Skip to content

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

Merged
tqchen merged 3 commits into
apache:mainfrom
junrushao:misc/2021-11-22/tir-error-msg
Nov 23, 2021
Merged

[TensorIR][UX] Type annotation-based runtime type checking#9559
tqchen merged 3 commits into
apache:mainfrom
junrushao:misc/2021-11-22/tir-error-msg

Conversation

@junrushao

Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

@tqchen

tqchen commented Nov 23, 2021

Copy link
Copy Markdown
Member

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

Comment thread src/tir/schedule/concrete_schedule.h Outdated
@junrushao

Copy link
Copy Markdown
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
Copy Markdown
Member Author

Update with a py36 compatible implementation

@junrushao

Copy link
Copy Markdown
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