From ed4d12c2ce30e5a1c270e2b4a08e67851ff8b295 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 22 Feb 2021 18:41:56 +0100 Subject: [PATCH] [mlir][Shape] Fix a crash when folding nary broadcast ops operands[2] can be nullptr here. I'm not able to build a lit test for this because of the commutative reordering of operands. It's possible to trigger this with a createOrFold though. Differential Revision: https://reviews.llvm.org/D97206 --- mlir/lib/Dialect/Shape/IR/Shape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 6146239cd4f8..73506525b22c 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -358,7 +358,7 @@ OpFoldResult BroadcastOp::fold(ArrayRef operands) { return nullptr; // TODO: Support folding with more than 2 input shapes - if (operands.size() > 2 && !operands[2].isa()) + if (shapes().size() > 2) return nullptr; auto rhsShape = llvm::to_vector<6>(