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

[discuss] Better hinting and auto completion for TIR script #420

Closed
yzh119 opened this issue Jul 26, 2021 · 3 comments
Closed

[discuss] Better hinting and auto completion for TIR script #420

yzh119 opened this issue Jul 26, 2021 · 3 comments

Comments

@yzh119
Copy link
Collaborator

yzh119 commented Jul 26, 2021

Current TIR script is a sub-language embedded in python frontend, user cannot use type hinting and auto completion tools because the code is not parsed by python.

We can create a .pyi stub for these keywords which only annotates type and leave the implementations empty (actually we don't need them). The stub could also help us generate language reference for user to grasp the syntax and semantics of TIR scripts.

For example, if I write a __init__.pyi under tvm.tir (from simplicity, it only cover a few keywords):

from typing import Tuple, Union, List
from .schedule import LoopRV, BlockRV
from ..ir import PrimExpr

class serial:
    def __init__(self, start: PrimExpr, end: PrimExpr) -> None: ...
    
    def __enter__(self) -> LoopRV: ...

class grid:
    def __init__(self, *args: PrimExpr) -> None: ...

    def __enter__(self) -> LoopRV: ...

class block:
    def __init__(self, *args: PrimExpr, name: str = '') -> None: ...

    def __enter__(self) -> List[LoopRV]: ...

it could help type hinting and auto completion when user write their TIR scripts.

However, there might be some conflict between python functions under tvm.tir and tir script keywords. @junrushao1994 's suggestion in to create another namespace (e.g. tvm.tir.T), I wonder do you have any elegant proposal for this?

@MasterJH5574
Copy link
Collaborator

However, there might be some conflict between python functions under tvm.tir and tir script keywords.

I'm not clear that how the conflict looks like? Could you give an example 😳?

@yzh119
Copy link
Collaborator Author

yzh119 commented Jul 26, 2021

For example, functions defined under tir.op always have an argument span, which is not required in script mode.

@junrushao
Copy link
Member

Moved to #471

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

No branches or pull requests

3 participants