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

[REFACTOR][TIR] Introduce PrimFuncPass. #5139

Merged
merged 3 commits into from
Mar 24, 2020
Merged

[REFACTOR][TIR] Introduce PrimFuncPass. #5139

merged 3 commits into from
Mar 24, 2020

Conversation

tqchen
Copy link
Member

@tqchen tqchen commented Mar 24, 2020

  • Introduce PrimFuncPass
  • Convert one pass to the unified Pass API.

As part of the unified IR refactor. We will convert all TIR passes into tir.transform and tir.analysis namespace. The passes under tir.transform shares the same Pass infra as relay. Which takes a IRModule(with PrimFuncs) and return a updated IRModule

In order to keep things backward compatible, we will keep the old API around until most of the passes has been converted. Then we will do a bulk remove of the legacy API

- Introduce PrimFuncPass
- Convert one pass to the unified Pass API.
@tqchen
Copy link
Member Author

tqchen commented Mar 24, 2020


@tvm._ffi.register_object("tir.PrimFuncPass")
class PrimFuncPass(Pass):
"""A pass that works on each tvm.relay.Function in a module. A function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tvm.tir.PrimFunc


Parameters
----------
pass_func : Optional[Callable[(Function, Module, PassContext) -> Function]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function->PrimFunc

Module->IRModule

name of the optimization function will be used as the pass name.

required : Optional[List[str]]
The list of passes that the module pass is dependent on.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function pass

* \brief Run a function pass on given pass context.
*
* \param mod The module that an optimization pass is applied on.
* \param mod The context that an optimization pass executes on.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mod -> pass_ctx

assert f.body.value.dtype == "handle"
assert f.body.body.value.dtype == "handle"

# temp adapter t convert loweredFunc to IRModule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t -> to?

@tqchen tqchen merged commit 0a0e58b into apache:master Mar 24, 2020
@tqchen
Copy link
Member Author

tqchen commented Mar 24, 2020

Thanks @zhiics @siju-samue哈

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Apr 16, 2020
* [REFACTOR][TIR] Introduce PrimFuncPass.

- Introduce PrimFuncPass
- Convert one pass to the unified Pass API.

* Address comments

* Fix comments
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Apr 17, 2020
* [REFACTOR][TIR] Introduce PrimFuncPass.

- Introduce PrimFuncPass
- Convert one pass to the unified Pass API.

* Address comments

* Fix comments
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.

3 participants