|
| 1 | +// RUN: mlir-opt %s -split-input-file -verify-diagnostics --tosa-validate="level=none profile=pro_int,pro_fp extension=int16,int4,bf16,fp8e4m3,fp8e5m2,fft,variable,controlflow,dynamic strict-op-spec-alignment" |
| 2 | + |
| 3 | +// ----- |
| 4 | + |
| 5 | +// CHECK-LABEL: test_resize_large_image_size |
| 6 | +func.func @test_resize_large_image_size(%arg0: tensor<1x16384x16384x8xf32>) -> tensor<1x32767x32767x8xf32> { |
| 7 | + %scale = tosa.const_shape { values = dense<[2, 1, 2, 1]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 8 | + %offset = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 9 | + %border = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 10 | + // expected-error@+1 {{'tosa.resize' op expect input/output height/width dims to be < 16384, got [OH, OW, IH, IW] = 32767, 32767, 16384, 16384}} |
| 11 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x16384x16384x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x32767x32767x8xf32> |
| 12 | + return %1 : tensor<1x32767x32767x8xf32> |
| 13 | +} |
| 14 | + |
| 15 | +// ----- |
| 16 | + |
| 17 | +// CHECK-LABEL: test_resize_invalid_scale_numerator |
| 18 | +func.func @test_resize_invalid_scale_numerator(%arg0: tensor<1x9x9x8xf32>) -> tensor<?x?x?x?xf32> { |
| 19 | + %scale = tosa.const_shape { values = dense<[2049, 8, 1, 2]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 20 | + %offset = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 21 | + %border = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 22 | + // expected-error@+1 {{'tosa.resize' op expect all scale numerator values to be <= (1 << 11), got scale_y_n=2049, scale_x_n=1}} |
| 23 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x9x9x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<?x?x?x?xf32> |
| 24 | + return %1 : tensor<?x?x?x?xf32> |
| 25 | +} |
| 26 | + |
| 27 | +// ----- |
| 28 | + |
| 29 | +// CHECK-LABEL: test_resize_invalid_downscale |
| 30 | +func.func @test_resize_invalid_downscale(%arg0: tensor<1x37x37x8xf32>) -> tensor<?x?x?x?xf32> { |
| 31 | + %scale = tosa.const_shape { values = dense<[1, 18, 1, 18]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 32 | + %offset = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 33 | + %border = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 34 | + // expected-error@+1 {{'tosa.resize' op expect a downscale ratio larger than 1/16, got y=1/18, x=1/18}} |
| 35 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x37x37x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<?x?x?x?xf32> |
| 36 | + return %1 : tensor<?x?x?x?xf32> |
| 37 | +} |
| 38 | + |
| 39 | +// ----- |
| 40 | + |
| 41 | +// CHECK-LABEL: test_resize_invalid_offset_y |
| 42 | +func.func @test_resize_invalid_offset_y(%arg0: tensor<1x8x8x8xf32>) -> tensor<?x?x?x?xf32> { |
| 43 | + %scale = tosa.const_shape { values = dense<[1, 1, 1, 1]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 44 | + %offset = tosa.const_shape { values = dense<[17, 0]> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 45 | + %border = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 46 | + // expected-error@+1 {{'tosa.resize' op expect offsetY / scaleYNumerator to be in range [-1, 16), got 17/1}} |
| 47 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x8x8x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<?x?x?x?xf32> |
| 48 | + return %1 : tensor<?x?x?x?xf32> |
| 49 | +} |
| 50 | + |
| 51 | +// ----- |
| 52 | + |
| 53 | +// CHECK-LABEL: test_resize_invalid_offset_x |
| 54 | +func.func @test_resize_invalid_offset_x(%arg0: tensor<1x8x8x8xf32>) -> tensor<?x?x?x?xf32> { |
| 55 | + %scale = tosa.const_shape { values = dense<[1, 1, 1, 1]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 56 | + %offset = tosa.const_shape { values = dense<[0, -2]> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 57 | + %border = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 58 | + // expected-error@+1 {{'tosa.resize' op expect offsetX / scaleXNumerator to be in range [-1, 16), got -2/1}} |
| 59 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x8x8x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<?x?x?x?xf32> |
| 60 | + return %1 : tensor<?x?x?x?xf32> |
| 61 | +} |
| 62 | + |
| 63 | +// ----- |
| 64 | + |
| 65 | +// CHECK-LABEL: test_resize_invalid_border_y |
| 66 | +func.func @test_resize_invalid_boarder_y(%arg0: tensor<1x8x8x8xf32>) -> tensor<?x?x?x?xf32> { |
| 67 | + %scale = tosa.const_shape { values = dense<[1, 1, 1, 1]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 68 | + %offset = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 69 | + %border = tosa.const_shape { values = dense<[-17, 0]> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 70 | + // expected-error@+1 {{'tosa.resize' op expect borderY / scaleYNumerator to be in range [-16, 1), got -17/1}} |
| 71 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x8x8x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<?x?x?x?xf32> |
| 72 | + return %1 : tensor<?x?x?x?xf32> |
| 73 | +} |
| 74 | + |
| 75 | +// ----- |
| 76 | + |
| 77 | +// CHECK-LABEL: test_resize_invalid_border_x |
| 78 | +func.func @test_resize_invalid_boarder_x(%arg0: tensor<1x8x8x8xf32>) -> tensor<?x?x?x?xf32> { |
| 79 | + %scale = tosa.const_shape { values = dense<[1, 1, 1, 1]> : tensor<4xindex> } : () -> !tosa.shape<4> |
| 80 | + %offset = tosa.const_shape { values = dense<0> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 81 | + %border = tosa.const_shape { values = dense<[0, 2]> : tensor<2xindex> } : () -> !tosa.shape<2> |
| 82 | + // expected-error@+1 {{'tosa.resize' op expect borderX / scaleXNumerator to be in range [-16, 1), got 2/1}} |
| 83 | + %1 = tosa.resize %arg0, %scale, %offset, %border { mode = "BILINEAR" } : (tensor<1x8x8x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<?x?x?x?xf32> |
| 84 | + return %1 : tensor<?x?x?x?xf32> |
| 85 | +} |
0 commit comments