[Mlir-commits] [mlir] 62bed56 - [mlir][tensor] Remove assertion in ExpandShapeOp::build (#91361)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue May 7 12:07:10 PDT 2024


Author: Benoit Jacob
Date: 2024-05-07T15:07:06-04:00
New Revision: 62bed56efdde1bed5dcebec5ceb375ffce223691

URL: https://github.com/llvm/llvm-project/commit/62bed56efdde1bed5dcebec5ceb375ffce223691
DIFF: https://github.com/llvm/llvm-project/commit/62bed56efdde1bed5dcebec5ceb375ffce223691.diff

LOG: [mlir][tensor] Remove assertion in ExpandShapeOp::build (#91361)

Unblocking downstream integrate where an expected-to-fail test was
expecting this to be a runtime verifier error, not a compiler crash:
https://github.com/llvm/torch-mlir/pull/3279.

Added: 
    

Modified: 
    mlir/lib/Dialect/Tensor/IR/TensorOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index 4c65045084dc5..7a13f7a7d1355 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -1676,10 +1676,12 @@ void ExpandShapeOp::build(OpBuilder &builder, OperationState &result,
   auto tensorResultTy = cast<RankedTensorType>(resultType);
   FailureOr<SmallVector<OpFoldResult>> outputShape = inferOutputShape(
       builder, result.location, tensorResultTy, reassociation, inputShape);
-  // Failure of this assertion usually indicates presence of multiple
-  // dynamic dimensions in the same reassociation group.
-  assert(succeeded(outputShape) && "unable to infer output shape");
-  build(builder, result, tensorResultTy, src, reassociation, *outputShape);
+  SmallVector<OpFoldResult> outputShapeOrEmpty;
+  if (succeeded(outputShape)) {
+    outputShapeOrEmpty = *outputShape;
+  }
+  build(builder, result, tensorResultTy, src, reassociation,
+        outputShapeOrEmpty);
 }
 
 SmallVector<AffineMap, 4> CollapseShapeOp::getReassociationMaps() {


        


More information about the Mlir-commits mailing list