[Mlir-commits] [mlir] 712123e - [MLIR][Tosa] TosaToTensor: create valid reshapes

Matthias Gehre llvmlistbot at llvm.org
Sun Jul 9 23:33:42 PDT 2023


Author: Matthias Gehre
Date: 2023-07-10T08:33:36+02:00
New Revision: 712123e04d45d0847bcd1aefb104162a13a16c6c

URL: https://github.com/llvm/llvm-project/commit/712123e04d45d0847bcd1aefb104162a13a16c6c
DIFF: https://github.com/llvm/llvm-project/commit/712123e04d45d0847bcd1aefb104162a13a16c6c.diff

LOG: [MLIR][Tosa] TosaToTensor: create valid reshapes

The pattern would create reshape ops without a newShape attr.
This fails the verifier (which can be seen in the debug output;
but curiously doesn't abort compilation),
and can cause crashes in other code that expect to see valid
reshape ops, like ReshapeOp::fold.

Differential Revision: https://reviews.llvm.org/D154651

Added: 
    

Modified: 
    mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
index 62988813b45736..1a9f48e311749a 100644
--- a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
+++ b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
@@ -229,9 +229,10 @@ class ReshapeConverterCollapseExpand
         reshape.getLoc(),
         RankedTensorType::get(intermediateShape,
                               reshape.getType().getElementType()),
-        adaptor.getInput1());
-    Value expand =
-        rewriter.create<tosa::ReshapeOp>(reshape.getLoc(), resultTy, collapse);
+        adaptor.getInput1(), rewriter.getDenseI64ArrayAttr(intermediateShape));
+    Value expand = rewriter.create<tosa::ReshapeOp>(
+        reshape.getLoc(), resultTy, collapse,
+        rewriter.getDenseI64ArrayAttr(resultTy.getShape()));
     rewriter.replaceOp(reshape, expand);
 
     return success();


        


More information about the Mlir-commits mailing list