[Mlir-commits] [mlir] [mlir][tensor] Fold `tensor.reshape` for dynamic reshape (PR #88961)
Rob Suderman
llvmlistbot at llvm.org
Wed Apr 17 11:15:52 PDT 2024
================
@@ -1580,6 +1580,48 @@ OpFoldResult ReshapeOp::fold(FoldAdaptor adaptor) {
llvm::dyn_cast_if_present<DenseElementsAttr>(adaptor.getSource()),
getResult().getType()))
return reshapedSource;
+
+ auto source = getSource();
+ auto sourceTy = dyn_cast<RankedTensorType>(source.getType());
+ auto resultTy = dyn_cast<RankedTensorType>(getType());
+
+ if (!sourceTy || !resultTy || sourceTy != resultTy)
+ return {};
+
+ if (auto fromElements = getShape().getDefiningOp<tensor::FromElementsOp>()) {
+ auto elements = fromElements.getElements();
+ bool dynamicNoop =
----------------
rsuderman wrote:
Also updated / simplified the loops contents.
https://github.com/llvm/llvm-project/pull/88961
More information about the Mlir-commits
mailing list