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 @@ -990,11 +990,16 @@ llvm::LogicalResult tosa::ReshapeOp::verify() {
990
990
return emitOpError () << " new shape does not match result rank" ;
991
991
992
992
for (auto [newShapeDim, outputShapeDim] :
993
- zip (getNewShape (), outputType.getShape ()))
993
+ zip (getNewShape (), outputType.getShape ())) {
994
994
if (newShapeDim != -1 && outputShapeDim != ShapedType::kDynamic &&
995
995
newShapeDim != outputShapeDim)
996
996
return emitOpError () << " new shape is inconsistent with result shape" ;
997
997
998
+ if (newShapeDim != ShapedType::kDynamic && newShapeDim < -1 )
999
+ return emitOpError () << " new shape has invalid tensor dimension size "
1000
+ << newShapeDim;
1001
+ }
1002
+
998
1003
if (inputType.hasStaticShape () && outputType.hasStaticShape ()) {
999
1004
int64_t inputElementsNum = inputType.getNumElements ();
1000
1005
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