@@ -498,35 +498,38 @@ func.func @slice_dyn(%arg0: tensor<?xf32>) -> (tensor<?xf32>) {
498498// CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
499499func.func @pad_float (%arg0 : tensor <1 x2 xf32 >) -> (tensor <4 x9 xf32 >) {
500500 %0 = tosa.const_shape {value = dense <[1 , 2 , 3 , 4 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
501+ %pad_const = " tosa.const" () {value = dense <3.14 > : tensor <1 xf32 >} : () -> tensor <1 xf32 >
501502 // CHECK-DAG: [[INDEX1:%.+]] = arith.constant 1 : index
502503 // CHECK-DAG: [[INDEX2:%.+]] = arith.constant 2 : index
503504 // CHECK-DAG: [[INDEX3:%.+]] = arith.constant 3 : index
504505 // CHECK-DAG: [[INDEX4:%.+]] = arith.constant 4 : index
505- // CHECK-DAG: [[CST:%.+]] = arith.constant 0.000000e +00 : f32
506+ // CHECK-DAG: [[CST:%.+]] = arith.constant 3.140000e +00 : f32
506507 // CHECK: tensor.pad %[[ARG0]] low{{\[}}[[INDEX1]], [[INDEX3]]] high{{\[}}[[INDEX2]], [[INDEX4]]] {
507508 // CHECK: tensor.yield [[CST]]
508509 // CHECK: } : tensor<1x2xf32> to tensor<4x9xf32>
509- %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <1 x2 xf32 >, !tosa.shape <4 >) -> (tensor <4 x9 xf32 >)
510+ %1 = " tosa.pad" (%arg0 , %0 , %pad_const ) : (tensor <1 x2 xf32 >, !tosa.shape <4 >, tensor < 1 x f32 >) -> (tensor <4 x9 xf32 >)
510511 return %1 : tensor <4 x9 xf32 >
511512}
512513// -----
513514
514515func.func @pad_int (%arg0 : tensor <1 x2 xi32 >) -> (tensor <4 x9 xi32 >) {
515516 %0 = tosa.const_shape {value = dense <[1 , 2 , 3 , 4 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
516- // CHECK: [[CST:%.+]] = arith.constant 0 : i32
517+ %pad_const = " tosa.const" () {value = dense <3 > : tensor <1 xi32 >} : () -> tensor <1 xi32 >
518+ // CHECK: [[CST:%.+]] = arith.constant 3 : i32
517519 // CHECK: tensor.pad
518520 // CHECK: tensor.yield [[CST]]
519- %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <1 x2 xi32 >, !tosa.shape <4 >) -> (tensor <4 x9 xi32 >)
521+ %1 = " tosa.pad" (%arg0 , %0 , %pad_const ) : (tensor <1 x2 xi32 >, !tosa.shape <4 >, tensor < 1 x i32 >) -> (tensor <4 x9 xi32 >)
520522 return %1 : tensor <4 x9 xi32 >
521523}
522524// -----
523525
524526func.func @pad_quant (%arg0 : tensor <1 x2 xi32 >) -> (tensor <4 x9 xi32 >) {
525527 %0 = tosa.const_shape {value = dense <[1 , 2 , 3 , 4 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
526- // CHECK: [[CST:%.+]] = arith.constant 42 : i32
528+ %pad_const = " tosa.const" () {value = dense <0 > : tensor <1 xi32 >} : () -> tensor <1 xi32 >
529+ // CHECK: [[CST:%.+]] = arith.constant 0 : i32
527530 // CHECK: tensor.pad
528531 // CHECK: tensor.yield [[CST]]
529- %1 = " tosa.pad" (%arg0 , %0 ) {input_zp = 42 : i32 } : (tensor <1 x2 xi32 >, !tosa.shape <4 >) -> (tensor <4 x9 xi32 >)
532+ %1 = " tosa.pad" (%arg0 , %0 , %pad_const ) {input_zp = 42 : i32 } : (tensor <1 x2 xi32 >, !tosa.shape <4 >, tensor < 1 x i32 >) -> (tensor <4 x9 xi32 >)
530533 return %1 : tensor <4 x9 xi32 >
531534}
532535
@@ -551,30 +554,32 @@ func.func @pad_float_explicit(%arg0 : tensor<1x2xf32>) -> (tensor<4x9xf32>) {
551554
552555func.func @pad_dyn_input (%arg0 : tensor <?x2 xf32 >) -> (tensor <?x9 xf32 >) {
553556 %0 = tosa.const_shape {value = dense <[1 , 2 , 3 , 4 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
557+ %pad_const = " tosa.const" () {value = dense <3.14 > : tensor <1 xf32 >} : () -> tensor <1 xf32 >
554558 // CHECK-DAG: [[INDEX1:%.+]] = arith.constant 1 : index
555559 // CHECK-DAG: [[INDEX2:%.+]] = arith.constant 2 : index
556560 // CHECK-DAG: [[INDEX3:%.+]] = arith.constant 3 : index
557561 // CHECK-DAG: [[INDEX4:%.+]] = arith.constant 4 : index
558- // CHECK-DAG: [[CST:%.+]] = arith.constant 0.000000e +00 : f32
562+ // CHECK-DAG: [[CST:%.+]] = arith.constant 3.140000e +00 : f32
559563 // CHECK: tensor.pad %[[ARG0]] low{{\[}}[[INDEX1]], [[INDEX3]]] high{{\[}}[[INDEX2]], [[INDEX4]]] {
560564 // CHECK: tensor.yield [[CST]]
561565 // CHECK: } : tensor<?x2xf32> to tensor<?x9xf32>
562- %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <?x2 xf32 >, !tosa.shape <4 >) -> (tensor <?x9 xf32 >)
566+ %1 = " tosa.pad" (%arg0 , %0 , %pad_const ) : (tensor <?x2 xf32 >, !tosa.shape <4 >, tensor < 1 x f32 >) -> (tensor <?x9 xf32 >)
563567 return %1 : tensor <?x9 xf32 >
564568}
565569// -----
566570
567571func.func @pad_dyn_padding (%arg0 : tensor <1 x2 xf32 >) -> (tensor <?x9 xf32 >) {
568572 %0 = tosa.const_shape {value = dense <[-1 , 2 , 3 , 4 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
573+ %pad_const = " tosa.const" () {value = dense <3.14 > : tensor <1 xf32 >} : () -> tensor <1 xf32 >
569574 // CHECK-DAG: [[INDEX1:%.+]] = arith.constant -1 : index
570575 // CHECK-DAG: [[INDEX2:%.+]] = arith.constant 2 : index
571576 // CHECK-DAG: [[INDEX3:%.+]] = arith.constant 3 : index
572577 // CHECK-DAG: [[INDEX4:%.+]] = arith.constant 4 : index
573- // CHECK-DAG: [[CST:%.+]] = arith.constant 0.000000e +00 : f32
578+ // CHECK-DAG: [[CST:%.+]] = arith.constant 3.140000e +00 : f32
574579 // CHECK: tensor.pad %[[ARG0]] low{{\[}}[[INDEX1]], [[INDEX3]]] high{{\[}}[[INDEX2]], [[INDEX4]]] {
575580 // CHECK: tensor.yield [[CST]]
576581 // CHECK: } : tensor<1x2xf32> to tensor<?x9xf32>
577- %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <1 x2 xf32 >, !tosa.shape <4 >) -> (tensor <?x9 xf32 >)
582+ %1 = " tosa.pad" (%arg0 , %0 , %pad_const ) : (tensor <1 x2 xf32 >, !tosa.shape <4 >, tensor < 1 x f32 >) -> (tensor <?x9 xf32 >)
578583 return %1 : tensor <?x9 xf32 >
579584}
580585
0 commit comments