[MLIR] Add a constraint for the rewriting rule of add_matmult to fullgemm (#374)
* Add a constraint for the rewriting rule of matmul_add to fullgemm * Edit comments
This commit is contained in:
parent
701c7d7508
commit
0c36057404
|
@ -24,12 +24,15 @@ include "dialect/onnx/onnx.td"
|
||||||
/// dag benefitsAdded = (addBenefit 0)
|
/// dag benefitsAdded = (addBenefit 0)
|
||||||
/// >;
|
/// >;
|
||||||
|
|
||||||
|
def HasOneUse : Constraint<CPred<"$0->hasOneUse()">>;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Pattern-Match and Rewrite
|
// Pattern-Match and Rewrite
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// onnx.add(onnx.matmult(%X, %Y), %Z) = onnx.gemm(%X, %Y, %Z)
|
// onnx.add(onnx.matmul(%X, %Y), %Z) = onnx.full_gemm(%X, %Y, %Z)
|
||||||
def MulAddToGemmOptPattern : Pat<(ONNXAddOp(ONNXMatMulOp $m1, $m2), $m3),
|
def MulAddToGemmOptPattern : Pat<(ONNXAddOp (ONNXMatMulOp:$res $m1, $m2), $m3),
|
||||||
(ONNXFullGemmOp $m1, $m2, $m3)>;
|
(ONNXFullGemmOp $m1, $m2, $m3),
|
||||||
|
[(HasOneUse $res)]>;
|
||||||
|
|
||||||
#endif // ONNX_COMBINE
|
#endif // ONNX_COMBINE
|
||||||
|
|
Loading…
Reference in New Issue