Skip to content

Commit 48deca0

Browse files
committed
Properly check optional value
1 parent 0975552 commit 48deca0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,15 @@ FailureOr<LowerPackResult> linalg::lowerPack(RewriterBase &rewriter,
371371
ValueRange{});
372372
Value shapeTensor = shapeInitTensor;
373373
for (const auto &[i, size] : llvm::enumerate(sizes)) {
374-
Value dim = (expandDestType.isDynamicDim(i))
375-
? cast<Value>(size)
376-
: rewriter
377-
.create<arith::ConstantIndexOp>(
378-
loc, getConstantIntValue(size).value())
379-
.getResult();
374+
auto maybeConstInt = getConstantIntValue(size);
375+
assert(maybeConstInt.has_value() ||
376+
expandDestType.isDynamicDim(i) && "expected dynamic dim");
377+
Value dim =
378+
(maybeConstInt.has_value())
379+
? rewriter
380+
.create<arith::ConstantIndexOp>(loc, maybeConstInt.value())
381+
.getResult()
382+
: cast<Value>(size);
380383
shapeTensor = rewriter.create<tensor::InsertOp>(
381384
loc, dim, shapeTensor,
382385
SmallVector<Value>(

0 commit comments

Comments
 (0)