File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
include/mlir/Dialect/Tosa/IR Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -1959,7 +1959,7 @@ def Tosa_ReshapeOp : Tosa_InferTensorTypeOp<"reshape"> {
19591959 );
19601960
19611961 let results = (outs
1962- Tosa_RankedTensor :$output
1962+ Tosa_Tensor :$output
19631963 );
19641964
19651965 list<Availability> availability = [
Original file line number Diff line number Diff line change @@ -2064,14 +2064,21 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
20642064 return failure ();
20652065 }
20662066 TensorType inputType = getInput1 ().getType ();
2067- RankedTensorType outputType = getType ();
20682067
20692068 SmallVector<int64_t > shapeValues;
20702069 if (!tosa::getConstShapeValues (getShape ().getDefiningOp (), shapeValues)) {
20712070 // skip following checks if shape is not constant
20722071 return mlir::success ();
20732072 }
20742073
2074+ int missingDims = llvm::count (shapeValues, -1 );
2075+ if (missingDims > 1 )
2076+ return emitOpError () << " expected at most one target dimension to be -1" ;
2077+
2078+ const auto outputType = dyn_cast<RankedTensorType>(getType ());
2079+ if (!outputType)
2080+ return success ();
2081+
20752082 if ((int64_t )shapeValues.size () != outputType.getRank ())
20762083 return emitOpError () << " new shape does not match result rank" ;
20772084
@@ -2108,10 +2115,6 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
21082115 }
21092116 }
21102117
2111- int missingDims = llvm::count (shapeValues, -1 );
2112- if (missingDims > 1 )
2113- return emitOpError () << " expected at most one target dimension to be -1" ;
2114-
21152118 return mlir::success ();
21162119}
21172120
Original file line number Diff line number Diff line change @@ -643,6 +643,14 @@ func.func @test_reshape(%arg0: tensor<13x21x3xf32>) -> tensor<1x819xf32> {
643643 return %0 : tensor <1 x819 xf32 >
644644}
645645
646+ // -----
647+ // CHECK-LABEL: reshape_unranked_output
648+ func.func @test_reshape_unranked_output (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <*xf32 > {
649+ %1 = tosa.const_shape {values = dense <[21 , 13 , 3 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
650+ %0 = tosa.reshape %arg0 , %1 : (tensor <13 x21 x3 xf32 >, !tosa.shape <3 >) -> tensor <*xf32 >
651+ return %0 : tensor <*xf32 >
652+ }
653+
646654// -----
647655// CHECK-LABEL: reverse
648656func.func @test_reverse (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <13 x21 x3 xf32 > {
You can’t perform that action at this time.
0 commit comments