@@ -31,22 +31,22 @@ func.func @depthwise_conv2d_as_mul(%arg0: tensor<4x10x10x2xf32>, %arg1: tensor<1
31
31
// CHECK-LABEL: @depthwise_conv2d_as_mul_q
32
32
func.func @depthwise_conv2d_as_mul_q (%arg0: tensor <4 x10 x10 x2 xi8 >, %arg1: tensor <1 x1 x2 x3 xi8 >, %arg2: tensor <6 xi32 >) -> tensor <4 x10 x10 x6 xi32 > {
33
33
// CHECK-DAG: %[[CONST0:.+]] = tosa.const_shape {value = dense<[4, 10, 10, 2, 1]> : tensor<5xindex>
34
- // CHECK-DAG: %[[iZp :.+]] = "tosa.const"() <{value = dense<7> : tensor<1x1x1x1x1xi32>}
35
- // CHECK-DAG: %[[wZp :.+]] = "tosa.const"() <{value = dense<11> : tensor<1x1x1x1xi32>}
34
+ // CHECK-DAG: %[[INPUT_ZP :.+]] = "tosa.const"() <{value = dense<7> : tensor<1x1x1x1x1xi32>}
35
+ // CHECK-DAG: %[[WEIGHT_ZP :.+]] = "tosa.const"() <{value = dense<11> : tensor<1x1x1x1xi32>}
36
36
// CHECK-DAG: %[[CONST3:.+]] = tosa.const_shape {value = dense<[1, 1, 1, 2, 3]> : tensor<5xindex>
37
37
// CHECK-DAG: %[[CONST4:.+]] = tosa.const_shape {value = dense<[4, 10, 10, 6]> : tensor<4xindex>
38
38
// CHECK-DAG: %[[CONST5:.+]] = tosa.const_shape {value = dense<[1, 1, 1, 6]> : tensor<4xindex>
39
39
// CHECK-DAG: %[[SHIFT:.*]] = "tosa.const"() <{value = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
40
- // CHECK: %[[rIn :.+]] = tosa.reshape %arg0, %[[CONST0]]
41
- // CHECK: %[[cIn :.+]] = tosa.cast %[[rIn ]] : (tensor<4x10x10x2x1xi8>) -> tensor<4x10x10x2x1xi32>
42
- // CHECK: %[[cWe :.+]] = tosa.cast %arg1 : (tensor<1x1x2x3xi8>) -> tensor<1x1x2x3xi32>
43
- // CHECK: %[[sIn :.+]] = tosa.sub %[[cIn ]], %[[iZp ]]
44
- // CHECK: %[[sWe :.+]] = tosa.sub %[[cWe ]], %[[wZp ]]
45
- // CHECK: %[[resWe :.+]] = tosa.reshape %[[sWe ]], %[[CONST3]]
46
- // CHECK: %[[mul :.+]] = tosa.mul %[[sIn ]], %[[resWe ]], %[[SHIFT]]
47
- // CHECK: %[[reO :.+]] = tosa.reshape %[[mul ]], %[[CONST4]]
48
- // CHECK: %[[reArg2 :.+]] = tosa.reshape %arg2, %[[CONST5]]
49
- // CHECK: %[[add :.+]] = tosa.add %[[reO ]], %[[reArg2 ]]
40
+ // CHECK: %[[RESHAPE_I :.+]] = tosa.reshape %arg0, %[[CONST0]]
41
+ // CHECK: %[[CAST_I :.+]] = tosa.cast %[[RESHAPE_I ]] : (tensor<4x10x10x2x1xi8>) -> tensor<4x10x10x2x1xi32>
42
+ // CHECK: %[[CAST_W :.+]] = tosa.cast %arg1 : (tensor<1x1x2x3xi8>) -> tensor<1x1x2x3xi32>
43
+ // CHECK: %[[SUB_I :.+]] = tosa.sub %[[CAST_I ]], %[[INPUT_ZP ]]
44
+ // CHECK: %[[SUB_W :.+]] = tosa.sub %[[CAST_W ]], %[[WEIGHT_ZP ]]
45
+ // CHECK: %[[RESHAPE_W :.+]] = tosa.reshape %[[SUB_W ]], %[[CONST3]]
46
+ // CHECK: %[[MUL :.+]] = tosa.mul %[[SUB_I ]], %[[RESHAPE_W ]], %[[SHIFT]]
47
+ // CHECK: %[[RESHAPE_O :.+]] = tosa.reshape %[[MUL ]], %[[CONST4]]
48
+ // CHECK: %[[RESHAPE_ARG2 :.+]] = tosa.reshape %arg2, %[[CONST5]]
49
+ // CHECK: %[[ADD :.+]] = tosa.add %[[RESHAPE_O ]], %[[RESHAPE_ARG2 ]]
50
50
%input_zp = " tosa.const" () {value = dense <7 > : tensor <1 xi8 >} : () -> tensor <1 xi8 >
51
51
%weight_zp = " tosa.const" () {value = dense <11 > : tensor <1 xi8 >} : () -> tensor <1 xi8 >
52
52
%0 = tosa.depthwise_conv2d %arg0 , %arg1 , %arg2 , %input_zp , %weight_zp {acc_type = i32 , pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >, dilation = array<i64 : 1 , 1 > } : (tensor <4 x10 x10 x2 xi8 >, tensor <1 x1 x2 x3 xi8 >, tensor <6 xi32 >, tensor <1 xi8 >, tensor <1 xi8 >) -> tensor <4 x10 x10 x6 xi32 >
@@ -58,19 +58,19 @@ func.func @depthwise_conv2d_as_mul_q(%arg0: tensor<4x10x10x2xi8>, %arg1: tensor<
58
58
// CHECK-LABEL: @depthwise_conv2d_as_mul_padded
59
59
func.func @depthwise_conv2d_as_mul_padded (%arg0: tensor <4 x10 x10 x2 xf32 >, %arg1: tensor <1 x1 x2 x3 xf32 >, %arg2: tensor <6 xf32 >) -> tensor <4 x12 x12 x6 xf32 > {
60
60
// CHECK-DAG: %[[CONST0:.+]] = tosa.const_shape {value = dense<[4, 10, 10, 2, 1]> : tensor<5xindex>}
61
- // CHECK-DAG: %[[pad :.+]] = tosa.const_shape {value = dense<[0, 0, 1, 1, 1, 1, 0, 0, 0, 0]> : tensor<10xindex>} : () -> !tosa.shape<10>
62
- // CHECK-DAG: %[[zero :.+]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}
61
+ // CHECK-DAG: %[[PAD :.+]] = tosa.const_shape {value = dense<[0, 0, 1, 1, 1, 1, 0, 0, 0, 0]> : tensor<10xindex>} : () -> !tosa.shape<10>
62
+ // CHECK-DAG: %[[ZERO :.+]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}
63
63
// CHECK-DAG: %[[CONST3:.+]] = tosa.const_shape {value = dense<[1, 1, 1, 2, 3]> : tensor<5xindex>}
64
64
// CHECK-DAG: %[[CONST4:.+]] = tosa.const_shape {value = dense<[4, 12, 12, 6]> : tensor<4xindex>}
65
65
// CHECK-DAG: %[[CONST5:.+]] = tosa.const_shape {value = dense<[1, 1, 1, 6]> : tensor<4xindex>}
66
66
// CHECK-DAG: %[[SHIFT:.*]] = "tosa.const"() <{value = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
67
- // CHECK: %[[reIn :.+]] = tosa.reshape %arg0, %[[CONST0]]
68
- // CHECK: %[[padded :.+]] = tosa.pad %[[reIn ]], %[[pad ]], %[[zero ]] : (tensor<4x10x10x2x1xf32>, !tosa.shape<10>, tensor<f32>) -> tensor<4x12x12x2x1xf32>
69
- // CHECK: %[[reArg1 :.+]] = tosa.reshape %arg1, %[[CONST3]]
70
- // CHECK: %[[mul :.+]] = tosa.mul %[[padded ]], %[[reArg1 ]], %[[SHIFT]]
71
- // CHECK: %[[reOut :.+]] = tosa.reshape %[[mul ]], %[[CONST4]]
72
- // CHECK: %[[reArg2 :.+]] = tosa.reshape %arg2, %[[CONST5]]
73
- // CHECK: %[[add :.+]] = tosa.add %[[reOut ]], %[[reArg2 ]]
67
+ // CHECK: %[[RESHAPE_I :.+]] = tosa.reshape %arg0, %[[CONST0]]
68
+ // CHECK: %[[PAD_I :.+]] = tosa.pad %[[RESHAPE_I ]], %[[PAD ]], %[[ZERO ]] : (tensor<4x10x10x2x1xf32>, !tosa.shape<10>, tensor<f32>) -> tensor<4x12x12x2x1xf32>
69
+ // CHECK: %[[RESHAPE_ARG1 :.+]] = tosa.reshape %arg1, %[[CONST3]]
70
+ // CHECK: %[[MUL :.+]] = tosa.mul %[[PAD_I ]], %[[RESHAPE_ARG1 ]], %[[SHIFT]]
71
+ // CHECK: %[[RESHAPE_O :.+]] = tosa.reshape %[[MUL ]], %[[CONST4]]
72
+ // CHECK: %[[RESHAPE_ARG2 :.+]] = tosa.reshape %arg2, %[[CONST5]]
73
+ // CHECK: %[[ADD :.+]] = tosa.add %[[RESHAPE_O ]], %[[RESHAPE_ARG2 ]]
74
74
%0 = tosa.depthwise_conv2d %arg0 , %arg1 , %arg2 {acc_type = f32 , pad = array<i64 : 1 , 1 , 1 , 1 >, stride = array<i64 : 1 , 1 >, dilation = array<i64 : 1 , 1 >} : (tensor <4 x10 x10 x2 xf32 >, tensor <1 x1 x2 x3 xf32 >, tensor <6 xf32 >) -> tensor <4 x12 x12 x6 xf32 >
75
75
return %0 : tensor <4 x12 x12 x6 xf32 >
76
76
}
0 commit comments