diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp --- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp @@ -1321,6 +1321,11 @@ if (!attr || attr.isSplat()) return {}; + // The case with multiple uses is not supported since it creates more + // constant data. + if (!op.source().getDefiningOp()->hasOneUse()) + return {}; + if (auto intElems = attr.dyn_cast()) { if (auto folded = foldExtractSliceAfterConstant