[WIP] Type hinting for TIR scripts #426
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A prototype of #420 .
We can write a TIR gemm as:
and IDEs could provide auto completion and type hints.
Note that we provide an argument for
tvm.script.tir
decorator so that the parser would recognizeT
as the prefix for tir built-in's. If we do not specify this argument, the parser would assumetir.
as the default prefix.Some choices:
Iterable[IterVar]
instead ofFor
to be compatible with python semantics.ContextManager
w/ a__init__
function and a__enter__
function which returns iter vars.env_threads
are viewed as iter vars as well.However, I'm not sure if we have covered enough the coverage of keywords (e.g. should we expose
tir.ramp/realize
here as they were rarely used in user's original scripts).Also, I did not directly reuse the types defined under
tvm.tir
such asPrimExpr
/BufferRegion
/etc but simplify and redefine them.TODOs
T
.@MasterJH5574 @Hzfengsy @spectrometerHBH @jinhongyii @junrushao1994 @vinx13 I'm glad to hear your comments if you have time.