[Mlir-commits] [mlir] 89d900b - [mlir] Add error message on shape.broadcast verification failure

Tres Popp llvmlistbot at llvm.org
Mon Feb 15 01:59:03 PST 2021


Author: Tres Popp
Date: 2021-02-15T10:58:53+01:00
New Revision: 89d900b2a1c11582a0a4396921282aa8f365d901

URL: https://github.com/llvm/llvm-project/commit/89d900b2a1c11582a0a4396921282aa8f365d901
DIFF: https://github.com/llvm/llvm-project/commit/89d900b2a1c11582a0a4396921282aa8f365d901.diff

LOG: [mlir] Add error message on shape.broadcast verification failure

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
    mlir/lib/Dialect/Shape/IR/Shape.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index f917f2e78da9..20b0706be367 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -89,10 +89,7 @@ def Shape_BroadcastOp : Shape_Op<"broadcast", [Commutative]> {
   ];
 
   let hasFolder = 1;
-  let verifier = [{
-    return success(succeeded(::verifyShapeOrExtentTensorOp(*this)) &&
-                   getNumOperands() >= 2);
-  }];
+  let verifier = [{ return ::verify(*this); }];
 }
 
 def Shape_ConstShapeOp : Shape_Op<"const_shape", [ConstantLike, NoSideEffect]> {

diff  --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index 9657f9566ea6..8c75bdc9aa16 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -383,6 +383,14 @@ OpFoldResult BroadcastOp::fold(ArrayRef<Attribute> operands) {
   return builder.getIndexTensorAttr(resultShape);
 }
 
+static LogicalResult verify(BroadcastOp op) {
+  // Ensure that AssumingAllOp contains at least one operand
+  if (op.getNumOperands() < 2)
+    return op.emitOpError("required at least 2 input shapes");
+
+  return verifyShapeOrExtentTensorOp(op);
+}
+
 //===----------------------------------------------------------------------===//
 // ConcatOp
 //===----------------------------------------------------------------------===//


        


More information about the Mlir-commits mailing list