We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4468d58 commit af420ffCopy full SHA for af420ff
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -979,7 +979,10 @@ struct FoldEmptyTensorWithDimOp : public OpRewritePattern<DimOp> {
979
auto emptyTensorOp = dimOp.getSource().getDefiningOp<EmptyOp>();
980
if (!emptyTensorOp || !maybeConstantIndex)
981
return failure();
982
- if (!emptyTensorOp.getType().isDynamicDim(*maybeConstantIndex))
+ auto emptyTensorType = emptyTensorOp.getType();
983
+ if (*maybeConstantIndex < 0 ||
984
+ *maybeConstantIndex >= emptyTensorType.getRank() ||
985
+ !emptyTensorType.isDynamicDim(*maybeConstantIndex))
986
987
rewriter.replaceOp(dimOp,
988
emptyTensorOp.getDynamicSize(*maybeConstantIndex));
0 commit comments