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][BOYC] Non recursive partitioning #5493

Merged
merged 5 commits into from
May 1, 2020

Conversation

zhiics
Copy link
Member

@zhiics zhiics commented Apr 30, 2020

This PR refactors the partitioning pass by using non-recursive mutator. It also removes the unnecessary mutators as we only need to look at begin/end annotations which are definitely wrapped in call nodes. In addition, a metadata struct is used to maintain the intermediate data needed for partitioning.

@zhiics
Copy link
Member Author

zhiics commented Apr 30, 2020

@mbrookhart please take a look for the mixed mutator pattern. BTW, we will still need to refactor the infertype pass as it is the most frequently used pass.

@comaniac @masahi @mbaret @manupa-arm @trevor-m please take a look.

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

We were trying rewriter but it is not applicable to this pass due to https://github.com/apache/incubator-tvm/pull/5493/files#diff-8d2cdf6314f73e4b32892679ad4dc44aR280, which traverses other nodes out of order. As a result, the current solution seems the most suitable.

Copy link
Contributor

@mbrookhart mbrookhart left a comment

Choose a reason for hiding this comment

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

Use of the iterative traversals looks great. Since you originally authored the class, I'll believe you about the necessary mutators.

Why so much auto-formatting noise? As a larger conversation, we might want to build a style checker into CI that enforces a particular auto-format implementaiton...

@comaniac
Copy link
Contributor

Ah I think that's because I manually ran clang-format for the file. We should definitely build style checker in CI.

@masahi masahi self-assigned this May 1, 2020
bool found_start_{false};
bool found_end_{false};
/*! \brief Map from each region output expr node to its output index and TupleGetItem node. */
std::unordered_map<Expr, std::pair<int, TupleGetItem>, ObjectHash, ObjectEqual> out_expr_indices;
Copy link
Member

@masahi masahi May 1, 2020

Choose a reason for hiding this comment

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

Since both arguments of TupleGetItem (func_call and the index) are in this struct, this TupleGetItem seems redundant to me. Also see my comment at L282.

Copy link
Member

Choose a reason for hiding this comment

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

If this TupleGetItem is intended to be cached, please come up with a better name than out_expr_indices, since it is not just indices.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to region_func_out and only cache the function output expressions (Call or TupleGetItem).

@comaniac
Copy link
Contributor

comaniac commented May 1, 2020

@masahi thanks for valuable suggestions. We've refactored CreateFunction to create all TupleGetItem nodes so that GetFunctionOutput can be safely removed and the metadata could be more concise. PTAL.

@masahi masahi merged commit 9c1e74c into apache:master May 1, 2020
@masahi
Copy link
Member

masahi commented May 1, 2020

Thanks @zhiics @comaniac @mbrookhart @manupa-arm

@zhiics zhiics deleted the non-recursive-partition branch May 1, 2020 22:04
Laurawly pushed a commit to Laurawly/tvm-1 that referenced this pull request May 9, 2020
* non recursive partitioning

* refactor maps

* rebase upstream

* refactor shared output

* address comments

Co-authored-by: Cody Yu <comaniac0422@gmail.com>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 9, 2020
* non recursive partitioning

* refactor maps

* rebase upstream

* refactor shared output

* address comments

Co-authored-by: Cody Yu <comaniac0422@gmail.com>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 18, 2020
* non recursive partitioning

* refactor maps

* rebase upstream

* refactor shared output

* address comments

Co-authored-by: Cody Yu <comaniac0422@gmail.com>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jun 18, 2020
* non recursive partitioning

* refactor maps

* rebase upstream

* refactor shared output

* address comments

Co-authored-by: Cody Yu <comaniac0422@gmail.com>
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.

5 participants