[mlir] stopgap for incorrect vector.contract lowering
authorAlex Zinenko <zinenko@google.com>
Mon, 17 Oct 2022 13:37:09 +0000 (13:37 +0000)
committerAlex Zinenko <zinenko@google.com>
Mon, 17 Oct 2022 14:49:34 +0000 (14:49 +0000)
`vector.contract` is being lowered to the default mul/add contraction
regardless if of the kind indicated. Stop the lowering completely in
this case until the correct one can be implemented.

Reviewed By: springerm, ThomasRaoux

Differential Revision: https://reviews.llvm.org/D136079

mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp

index 570b4b2..0bdaf7b 100644 (file)
@@ -1862,6 +1862,13 @@ ContractionOpLowering::matchAndRewrite(vector::ContractionOp op,
       op.getRhsType().getElementType() != getElementTypeOrSelf(op.getAccType()))
     return failure();
 
+  // TODO: the code below assumes the default contraction, make sure it supports
+  // other kinds before enabling this lowering.
+  if (op.getKind() != vector::CombiningKind::ADD) {
+    return rewriter.notifyMatchFailure(
+        op, "contractions other than 'add' not supported");
+  }
+
   // TODO: implement benefits, cost models.
   MLIRContext *ctx = op.getContext();
   ContractionOpToMatmulOpLowering pat1(vectorTransformOptions, ctx);