[Mlir-commits] [mlir] Fixes in 'tosa.reshape' lowering and folder (PR #85798)

Suraj Sudhir llvmlistbot at llvm.org
Mon Mar 25 14:54:17 PDT 2024


================
@@ -795,7 +795,10 @@ OpFoldResult ReshapeOp::fold(FoldAdaptor adaptor) {
   if (!inputTy || !outputTy)
     return {};
 
-  if (inputTy == outputTy)
+  // Fold when the input and output types are the same. This is only safe when
+  // there is at most 1 dynamic dimension. For 2 or more dynamic dimensions,
+  // there may still be a productive reshape.
+  if (inputTy == outputTy && inputTy.getNumDynamicDims() < 2)
----------------
sjarus wrote:

As mentioned in the earlier comment, this restriction will be relaxed. This would probably necessitate dynamic cases to be predicated on something like tensor.dim for later resolution. 

However, for the purposes of this PR this code looks fine. 

https://github.com/llvm/llvm-project/pull/85798


More information about the Mlir-commits mailing list