File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -967,11 +967,16 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
967
967
return emitOpError () << " new shape does not match result rank" ;
968
968
969
969
for (auto [newShapeDim, outputShapeDim] :
970
- zip (getNewShape (), outputType.getShape ()))
970
+ zip (getNewShape (), outputType.getShape ())) {
971
971
if (newShapeDim != -1 && outputShapeDim != ShapedType::kDynamic &&
972
972
newShapeDim != outputShapeDim)
973
973
return emitOpError () << " new shape is inconsistent with result shape" ;
974
974
975
+ if (newShapeDim < -1 )
976
+ return emitOpError () << " new shape has invalid tensor dimension size "
977
+ << newShapeDim;
978
+ }
979
+
975
980
if (inputType.hasStaticShape () && outputType.hasStaticShape ()) {
976
981
int64_t inputElementsNum = inputType.getNumElements ();
977
982
int64_t outputElementsNum = outputType.getNumElements ();
Original file line number Diff line number Diff line change @@ -291,6 +291,14 @@ func.func @test_reshape_invalid_placeholders(%arg0 : tensor<?xf32>) -> () {
291
291
292
292
// -----
293
293
294
+ func.func @test_reshape_invalid_tensor_dim (%arg0 : tensor <4 x?xf32 >) -> () {
295
+ // expected-error@+1 {{'tosa.reshape' op new shape has invalid tensor dimension size -2}}
296
+ %0 = " tosa.reshape" (%arg0 ) {new_shape = array<i64 : -2 , -1 >} : (tensor <4 x?xf32 >) -> tensor <?x4 xf32 >
297
+ return
298
+ }
299
+
300
+ // -----
301
+
294
302
func.func @test_reverse_axis_out_of_range (%arg0 : tensor <13 x21 x3 xf32 >) -> () {
295
303
// expected-error@+1 {{'tosa.reverse' op expect input tensor rank (3) to be larger than reverse axis (5)}}
296
304
%0 = tosa.reverse %arg0 {axis = 5 : i32 } : (tensor <13 x21 x3 xf32 >) -> tensor <?x?x?xi32 >
You can’t perform that action at this time.
0 commit comments