[SimplifyExpr] Simplify consecutive adds with constants#9671
Merged
comaniac merged 1 commit intoapache:mainfrom Dec 10, 2021
Merged
[SimplifyExpr] Simplify consecutive adds with constants#9671comaniac merged 1 commit intoapache:mainfrom
comaniac merged 1 commit intoapache:mainfrom
Conversation
5980617 to
a3de726
Compare
comaniac
approved these changes
Dec 9, 2021
Contributor
comaniac
left a comment
There was a problem hiding this comment.
LGTM. Just some coding style comments.
Comment on lines
595
to
597
| DFPattern add_op1_ = IsOp("add"); | ||
| DFPattern add_op2_ = IsOp("add"); | ||
| pattern_ = add_op2_({add_op1_({x_, const1_}), const2_}); |
Contributor
There was a problem hiding this comment.
- Only private class members need the underline suffix.
- You actually don't need two
add_ops because all ops are the same. - Might be better to add a comment saying pattern matching supports commutative property for addition so this pattern already covers all possible cases.
Suggested change
| DFPattern add_op1_ = IsOp("add"); | |
| DFPattern add_op2_ = IsOp("add"); | |
| pattern_ = add_op2_({add_op1_({x_, const1_}), const2_}); | |
| DFPattern add_op = IsOp("add"); | |
| pattern_ = add_op({add_op({x_, const1_}), const2_}); |
a3de726 to
2c529bc
Compare
Contributor
|
Thanks @crazydemo |
ylc
pushed a commit
to ylc/tvm
that referenced
this pull request
Jan 7, 2022
yangulei
pushed a commit
to yangulei/tvm
that referenced
this pull request
Jan 11, 2022
yangulei
pushed a commit
to yangulei/tvm
that referenced
this pull request
Jan 12, 2022
ylc
pushed a commit
to ylc/tvm
that referenced
this pull request
Jan 13, 2022
qsqqsqqsq-intellif
pushed a commit
to qsqqsqqsq-intellif/tvm
that referenced
this pull request
Apr 29, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
To make
FoldConstantable to fuse patternconv add add relu(comes fromconv bias_add bn relu) intoconv add relu.A
simplifyConsecuitiveAddpattern are added insimplify_exprpass.Related RFC
Test case is also added in "test_pass_simplify_expr.py"