Conversation
|
|
||
| // Simple pad test | ||
| TEST_F(ResizeTest, FusionResizePad1) { | ||
| TEST_F(ResizeTest, Pad1) { |
There was a problem hiding this comment.
Simplified the test names as no need to have Fusion anymore.
|
!build --diff |
| if (bop->getBinaryOpType() == BinaryOpType::Sub) { | ||
| sub_rhs = bop->rhs(); | ||
| } else if (bop->getBinaryOpType() == BinaryOpType::Add) { | ||
| // Note that SimplifyingIrBuilder may turn (a - b) to (a + (- b)) |
There was a problem hiding this comment.
This seems to be the crux of it, and it's why the previous pattern was not firing. Thanks for figuring this out!
In the future, perhaps we could perform this simplification in SimplifyingIrBuilder itself. To do so, we would need to "flatten" associative/commutative ops like add and mul, then perform cancellation before unflattening. Then anywhere we use SimplifyingIrBuilder::addExpr to construct a + (b + (c + (-a))) we could return b + c. That kind of transform is already done by simplifyExpr but that is only run automatically in certain cases like index expressions.
There was a problem hiding this comment.
See #2020 for the SimplifyingIrBuilder approach.
I noticed the extent of a slice output IterDomain is not simplified as intended. Currently we do pattern matching of
a - b, but we actually geta + (-b)due toSimplifyingIrBuilder. This is a quick fix to make sure the latter pattern is also detected. For example:Before:
i0 + ( ( fmax(0, ( fmin(i0, 1) )) ) + ( -i0 ) )After:
fmax(0, ( fmin(i0, 1) ))