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"> {
1959
1959
);
1960
1960
1961
1961
let results = (outs
1962
- Tosa_RankedTensor :$output
1962
+ Tosa_Tensor :$output
1963
1963
);
1964
1964
1965
1965
list<Availability> availability = [
Original file line number Diff line number Diff line change @@ -2064,14 +2064,21 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
2064
2064
return failure ();
2065
2065
}
2066
2066
TensorType inputType = getInput1 ().getType ();
2067
- RankedTensorType outputType = getType ();
2068
2067
2069
2068
SmallVector<int64_t > shapeValues;
2070
2069
if (!tosa::getConstShapeValues (getShape ().getDefiningOp (), shapeValues)) {
2071
2070
// skip following checks if shape is not constant
2072
2071
return mlir::success ();
2073
2072
}
2074
2073
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
+
2075
2082
if ((int64_t )shapeValues.size () != outputType.getRank ())
2076
2083
return emitOpError () << " new shape does not match result rank" ;
2077
2084
@@ -2108,10 +2115,6 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
2108
2115
}
2109
2116
}
2110
2117
2111
- int missingDims = llvm::count (shapeValues, -1 );
2112
- if (missingDims > 1 )
2113
- return emitOpError () << " expected at most one target dimension to be -1" ;
2114
-
2115
2118
return mlir::success ();
2116
2119
}
2117
2120
Original file line number Diff line number Diff line change @@ -643,6 +643,14 @@ func.func @test_reshape(%arg0: tensor<13x21x3xf32>) -> tensor<1x819xf32> {
643
643
return %0 : tensor <1 x819 xf32 >
644
644
}
645
645
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
+
646
654
// -----
647
655
// CHECK-LABEL: reverse
648
656
func.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