@@ -160,3 +160,44 @@ func.func @test_pad_f16_constant_none(%arg0: tensor<256x1x1x5x1xf16>) -> tensor<
160160// CHECK: %[[VAR2:.*]] = tosa.pad %arg0, %[[VAR0]], %[[VAR1]] : (tensor<256x1x1x5x1xf16>, !tosa.shape<10>, tensor<f16>) -> tensor<256x1x1x5x2xf16>
161161// CHECK: return %[[VAR2]] : tensor<256x1x1x5x2xf16>
162162}
163+
164+ // -----
165+
166+ func.func @test_pad_f32_non_constant_padval (%arg0: tensor <20 x16 x44 x32 xf32 >, %arg1: tensor <f32 >) -> tensor <24 x22 x52 x42 xf32 > {
167+ %noval = " onnx.NoValue" () {value } : () -> none
168+ %0 = " onnx.Constant" () {value = dense <[0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]> : tensor <8 xi64 >} : () -> tensor <8 xi64 >
169+ %2 = " onnx.Pad" (%arg0 , %0 , %arg1 , %noval ) {mode = " constant" } : (tensor <20 x16 x44 x32 xf32 >, tensor <8 xi64 >, tensor <f32 >, none ) -> tensor <24 x22 x52 x42 xf32 >
170+ return %2 : tensor <24 x22 x52 x42 xf32 >
171+ // CHECK-LABEL: func.func @test_pad_f32_non_constant_padval
172+ // CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<20x16x44x32xf32>, [[PARAM_1_:%.+]]: tensor<f32>) -> tensor<24x22x52x42xf32> {
173+ // CHECK-DAG: [[VAR_0_:%.+]] = "tosa.const"() <{value = dense<[0, 4, 1, 5, 2, 6, 3, 7]> : tensor<8xi64>}> : () -> tensor<8xi64>
174+ // CHECK: [[VAR_1_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[PARAM_1_]] : (tensor<20x16x44x32xf32>, tensor<8xi64>, tensor<f32>) -> tensor<24x22x52x42xf32>
175+ // CHECK: return [[VAR_1_]] : tensor<24x22x52x42xf32>
176+ }
177+
178+ // -----
179+
180+ func.func @test_pad_i64_non_constant_padval (%arg0: tensor <20 x16 x44 x32 xi64 >, %arg1: tensor <i64 >) -> tensor <24 x22 x52 x42 xi64 > {
181+ %noval = " onnx.NoValue" () {value } : () -> none
182+ %0 = " onnx.Constant" () {value = dense <[0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]> : tensor <8 xi64 >} : () -> tensor <8 xi64 >
183+ %2 = " onnx.Pad" (%arg0 , %0 , %arg1 , %noval ) {mode = " constant" } : (tensor <20 x16 x44 x32 xi64 >, tensor <8 xi64 >, tensor <i64 >, none ) -> tensor <24 x22 x52 x42 xi64 >
184+ return %2 : tensor <24 x22 x52 x42 xi64 >
185+ // CHECK-LABEL: func.func @test_pad_i64_non_constant_padval
186+ // CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<20x16x44x32xi64>, [[PARAM_1_:%.+]]: tensor<i64>) -> tensor<24x22x52x42xi64> {
187+ // CHECK-DAG: [[VAR_0_:%.+]] = "tosa.const"() <{value = dense<[0, 4, 1, 5, 2, 6, 3, 7]> : tensor<8xi64>}> : () -> tensor<8xi64>
188+ // CHECK: [[VAR_1_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[PARAM_1_]] : (tensor<20x16x44x32xi64>, tensor<8xi64>, tensor<i64>) -> tensor<24x22x52x42xi64>
189+ // CHECK: return [[VAR_1_]] : tensor<24x22x52x42xi64>
190+ }
191+
192+ // -----
193+ func.func @test_pad_f16_non_constant_padval (%arg0: tensor <20 x16 x44 x32 xf16 >, %arg1: tensor <f16 >) -> tensor <24 x22 x52 x42 xf16 > {
194+ %noval = " onnx.NoValue" () {value } : () -> none
195+ %0 = " onnx.Constant" () {value = dense <[0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]> : tensor <8 xi64 >} : () -> tensor <8 xi64 >
196+ %2 = " onnx.Pad" (%arg0 , %0 , %arg1 , %noval ) {mode = " constant" } : (tensor <20 x16 x44 x32 xf16 >, tensor <8 xi64 >, tensor <f16 >, none ) -> tensor <24 x22 x52 x42 xf16 >
197+ return %2 : tensor <24 x22 x52 x42 xf16 >
198+ // CHECK-LABEL: func.func @test_pad_f16_non_constant_padval
199+ // CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<20x16x44x32xf16>, [[PARAM_1_:%.+]]: tensor<f16>) -> tensor<24x22x52x42xf16> {
200+ // CHECK-DAG: [[VAR_0_:%.+]] = "tosa.const"() <{value = dense<[0, 4, 1, 5, 2, 6, 3, 7]> : tensor<8xi64>}> : () -> tensor<8xi64>
201+ // CHECK: [[VAR_1_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[PARAM_1_]] : (tensor<20x16x44x32xf16>, tensor<8xi64>, tensor<f16>) -> tensor<24x22x52x42xf16>
202+ // CHECK: return [[VAR_1_]] : tensor<24x22x52x42xf16>
203+ }
0 commit comments