Skip to content

Commit

Permalink
move parallel factor pattern to canonicalization pass
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Mar 11, 2024
1 parent acd0eb1 commit ee290e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions include/Dialect/TensorExt/IR/TensorExtCanonicalization.td
Expand Up @@ -82,4 +82,18 @@ def RotatePlusExtractToIndexedExtract : Pat<
(MakeSingleResultVariadic (Arith_AddIOp $shift, $index, DefOverflow)))
>;

// Rotating two tensors by the same amount can be converted to a single
// post-rotation. This can result in eliminating either the rotation (because
// it can be combined with a later rotation) or the arith op itself, if it is
// is identical to an existing arith op applied before the rotation.
foreach ArithOp = [Arith_AddIOp, Arith_SubIOp, Arith_MulIOp] in {
def FactorParallelRotationsThroughOp_#ArithOp : Pat<
(ArithOp
(TensorExt_RotateOp $t1, $i),
(TensorExt_RotateOp $t2, $i),
$ovf),
(TensorExt_RotateOp (ArithOp $t1, $t2, $ovf), $i)
>;
}

#endif // INCLUDE_DIALECT_TENSOREXT_IR_TENSOREXTCANONICALIZATION_TD_
14 changes: 0 additions & 14 deletions include/Dialect/TensorExt/Transforms/TensorExtRotationAlignment.td
Expand Up @@ -80,18 +80,4 @@ foreach InnerOp = [Arith_AddIOp, Arith_SubIOp, Arith_MulIOp] in {
}
}

// Rotating two tensors by the same amount can be converted to a single
// post-rotation. This can result in eliminating either the rotation (because
// it can be combined with a later rotation) or the arith op itself, if it is
// is identical to an existing arith op applied before the rotation.
foreach ArithOp = [Arith_AddIOp, Arith_SubIOp, Arith_MulIOp] in {
def FactorParallelRotationsThroughOp_#ArithOp : Pat<
(ArithOp
(TensorExt_RotateOp $t1, $i),
(TensorExt_RotateOp $t2, $i),
$ovf),
(TensorExt_RotateOp (ArithOp $t1, $t2, $ovf), $i)
>;
}

#endif // INCLUDE_DIALECT_TENSOREXT_IR_TENSOREXTPATTERNS_TD_

0 comments on commit ee290e9

Please sign in to comment.