[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<BroadcastOp> though.

Differential Revision: https://reviews.llvm.org/D97206
This commit is contained in:
Benjamin Kramer 2021-02-22 18:41:56 +01:00
parent 55dff8b2e4
commit ed4d12c2ce

View File

@ -358,7 +358,7 @@ OpFoldResult BroadcastOp::fold(ArrayRef<Attribute> operands) {
return nullptr;
// TODO: Support folding with more than 2 input shapes
if (operands.size() > 2 && !operands[2].isa<StringAttr>())
if (shapes().size() > 2)
return nullptr;
auto rhsShape = llvm::to_vector<6>(