11// RUN: tf-opt --tf-to-tosa-pipeline --verify-each %s | FileCheck %s
2- // REQUIRES: tf_tosa
2+
33// RUN: tf-opt --tf-tfl-to-tosa-pipeline --verify-each %s | FileCheck %s
4- // REQUIRES: tf_tosa
4+
55
66// Operations for testing tf-to-tosa-pipeline
77// TODO: These tests are fairly minimal. Expand the checks to be more robust.
1212// CHECK-DAG: %[[VAR0:.*]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<16xf32>}>
1313// CHECK-DAG: %[[VAR1:.*]] = "tosa.const"() <{value = dense<[3, 0, 1, 2]> : tensor<4xi32>}>
1414// CHECK-DAG: %[[VAR2:.*]] = tosa.transpose %arg1, %[[VAR1]]
15- // CHECK: %[[VAR3:.*]] = tosa.conv2d %arg0, %[[VAR2]], %[[VAR0]] {dilation = array<i64: 1, 1>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>}
15+ // CHECK: %[[VAR3:.*]] = tosa.conv2d %arg0, %[[VAR2]], %[[VAR0]] {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>}
1616func.func @test_conv2d (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <2 x2 x8 x16 xf32 >) -> tensor <1 x32 x32 x16 xf32 > {
1717 %3 = " tf.Conv2D" (%arg0 , %arg1 ) {data_format = " NHWC" , dilations = [1 , 1 , 1 , 1 ], explicit_paddings = [], padding = " SAME" , strides = [1 , 1 , 1 , 1 ], use_cudnn_on_gpu = true } : (tensor <1 x32 x32 x8 xf32 >, tensor <2 x2 x8 x16 xf32 >) -> tensor <1 x32 x32 x16 xf32 >
1818 func.return %3 : tensor <1 x32 x32 x16 xf32 >
@@ -22,7 +22,7 @@ func.func @test_conv2d(%arg0: tensor<1x32x32x8xf32>, %arg1: tensor<2x2x8x16xf32>
2222
2323// CHECK-LABEL: test_depthwise_conv2d
2424// CHECK-DAG: %[[VAR0:.*]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<16xf32>}>
25- // CHECK: %[[VAR1:.*]] = tosa.depthwise_conv2d %arg0, %arg1, %0 {dilation = array<i64: 1, 1>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>}
25+ // CHECK: %[[VAR1:.*]] = tosa.depthwise_conv2d %arg0, %arg1, %0 {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>}
2626func.func @test_depthwise_conv2d (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <2 x2 x8 x2 xf32 >) -> tensor <1 x32 x32 x16 xf32 > {
2727 %5 = " tf.DepthwiseConv2dNative" (%arg0 , %arg1 ) {data_format = " NHWC" , dilations = [1 , 1 , 1 , 1 ], explicit_paddings = [], padding = " SAME" , strides = [1 , 1 , 1 , 1 ]} : (tensor <1 x32 x32 x8 xf32 >, tensor <2 x2 x8 x2 xf32 >) -> tensor <1 x32 x32 x16 xf32 >
2828 %6 = " tf.Identity" (%5 ) : (tensor <1 x32 x32 x16 xf32 >) -> tensor <1 x32 x32 x16 xf32 >
@@ -35,7 +35,7 @@ func.func @test_depthwise_conv2d(%arg0: tensor<1x32x32x8xf32>, %arg1: tensor<2x2
3535// CHECK-SAME: %[[ARG0:.*]]: tensor<1x32x32x8xf32>, %[[ARG1:.*]]: tensor<1x1x16x8xf32>
3636// CHECK: %[[CONST:.*]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<16xf32>}>
3737// CHECK: %[[RESHAPE:.*]] = tosa.reshape %[[ARG1]] {new_shape = array<i64: 16, 1, 1, 8>}
38- // CHECK: %[[TRANSPOSE:.*]] = tosa.transpose_conv2d %[[ARG0]], %[[RESHAPE]], %[[CONST]] {out_pad = array<i64: 0, 0, 0, 0>, out_shape = array<i64: 1, 32, 32, 16>, stride = array<i64: 1, 1>}
38+ // CHECK: %[[TRANSPOSE:.*]] = tosa.transpose_conv2d %[[ARG0]], %[[RESHAPE]], %[[CONST]] {acc_type = f32, out_pad = array<i64: 0, 0, 0, 0>, out_shape = array<i64: 1, 32, 32, 16>, stride = array<i64: 1, 1>}
3939// CHECK: return %[[TRANSPOSE]]
4040func.func @test_transpose_conv2d (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 x1 x16 x8 xf32 >) -> tensor <1 x32 x32 x16 xf32 > {
4141 %3 = " tf.Const" () {value = dense <[1 , 32 , 32 , 16 ]> : tensor <4 xi32 >} : () -> tensor <4 xi32 >
@@ -51,7 +51,7 @@ func.func @test_transpose_conv2d(%arg0: tensor<1x32x32x8xf32>, %arg1: tensor<1x1
5151// CHECK-DAG: %[[VAL_2:.*]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<4xf32>}>
5252// CHECK-DAG: %[[VAL_3:.*]] = "tosa.const"() <{value = dense<[4, 0, 1, 2, 3]> : tensor<5xi32>}>
5353// CHECK: %[[VAL_4:.*]] = tosa.transpose %[[VAL_1]], %[[VAL_3]]
54- // CHECK: %[[VAL_5:.*]] = tosa.conv3d %[[VAL_0]], %[[VAL_4]], %[[VAL_2]] {dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 1, 0, 1, 0, 1>, stride = array<i64: 1, 2, 2>}
54+ // CHECK: %[[VAL_5:.*]] = tosa.conv3d %[[VAL_0]], %[[VAL_4]], %[[VAL_2]] {acc_type = f32, dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 1, 0, 1, 0, 1>, stride = array<i64: 1, 2, 2>}
5555func.func @test_conv3d (%arg0: tensor <2 x4 x128 x128 x8 xf32 >, %arg1: tensor <2 x3 x3 x2 x4 xf32 >) -> tensor <2 x4 x64 x64 x4 xf32 > {
5656 %0 = " tf.Conv3D" (%arg0 , %arg1 ) {data_format = " NDHWC" , device = " " , dilations = [1 , 1 , 1 , 1 , 1 ], padding = " SAME" , strides = [1 , 1 , 2 , 2 , 1 ]} : (tensor <2 x4 x128 x128 x8 xf32 >, tensor <2 x3 x3 x2 x4 xf32 >) -> tensor <2 x4 x64 x64 x4 xf32 >
5757 return %0 : tensor <2 x4 x64 x64 x4 xf32 >
@@ -65,7 +65,7 @@ func.func @test_conv3d(%arg0: tensor<2x4x128x128x8xf32>, %arg1: tensor<2x3x3x2x4
6565// CHECK-SAME: %[[VAL_2:.*]]: tensor<10xf32>) -> tensor<3x32x16x16x10xf32>
6666// CHECK-DAG: %[[VAL_3:.*]] = "tosa.const"() <{value = dense<[4, 0, 1, 2, 3]> : tensor<5xi32>}>
6767// CHECK: %[[VAL_4:.*]] = tosa.transpose %[[VAL_1]], %[[VAL_3]]
68- // CHECK: %[[VAL_5:.*]] = tosa.conv3d %[[VAL_0]], %[[VAL_4]], %[[VAL_2]] {dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 1, 1, 1, 1, 1>, stride = array<i64: 1, 1, 1>}
68+ // CHECK: %[[VAL_5:.*]] = tosa.conv3d %[[VAL_0]], %[[VAL_4]], %[[VAL_2]] {acc_type = f32, dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 1, 1, 1, 1, 1>, stride = array<i64: 1, 1, 1>}
6969func.func @test_conv3d_bias (%arg0: tensor <3 x32 x16 x16 x5 xf32 >, %arg1: tensor <2 x3 x3 x5 x10 xf32 >, %bias: tensor <10 xf32 >) -> tensor <3 x32 x16 x16 x10 xf32 > {
7070 %0 = " tf.Conv3D" (%arg0 , %arg1 ) {data_format = " NDHWC" , device = " " , dilations = [1 , 1 , 1 , 1 , 1 ], padding = " SAME" , strides = [1 , 1 , 1 , 1 , 1 ]} : (tensor <3 x32 x16 x16 x5 xf32 >, tensor <2 x3 x3 x5 x10 xf32 >) -> tensor <3 x32 x16 x16 x10 xf32 >
7171 %1 = " tf.BiasAdd" (%0 , %bias ) {data_format = " NHWC" , device = " " } : (tensor <3 x32 x16 x16 x10 xf32 >, tensor <10 xf32 >) -> tensor <3 x32 x16 x16 x10 xf32 >
@@ -906,10 +906,12 @@ func.func @test_right_shift(%arg0: tensor<4x4xi32>, %arg1: tensor<1x1xi32>) -> t
906906
907907// CHECK-LABEL: @test_one_hot
908908// CHECK-SAME: %[[ARG0_0:.*]]: tensor<4x4xi32>, %[[ARG1_0:.*]]: tensor<f32>, %[[ARG2:.*]]: tensor<f32>
909+ // CHECK: %[[CST1:.*]] = tosa.const_shape {value = dense<[16, 1, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>
910+ // CHECK: %[[CST2:.*]] = tosa.const_shape {value = dense<[16, 2, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>
909911// CHECK: %[[RESHAPE_0:.*]] = tosa.reshape %[[ARG1_0]] {new_shape = array<i64: 1, 1, 1>}
910- // CHECK: %[[TILE:.*]] = tosa.tile %[[RESHAPE_0]] {multiples = array<i64: 16, 1, 1>}
912+ // CHECK: %[[TILE:.*]] = tosa.tile %[[RESHAPE_0]], %[[CST1]]
911913// CHECK: %[[RESHAPE_1:.*]] = tosa.reshape %[[ARG2]] {new_shape = array<i64: 1, 1, 1>}
912- // CHECK: %[[TILE_0:.*]] = tosa.tile %[[RESHAPE_1]] {multiples = array<i64: 16, 2, 1>}
914+ // CHECK: %[[TILE_0:.*]] = tosa.tile %[[RESHAPE_1]], %[[CST2]]
913915// CHECK: %[[RESHAPE_2:.*]] = tosa.reshape %[[ARG0_0]] {new_shape = array<i64: 16, 1>}
914916// CHECK: %[[SCATTER:.*]] = tosa.scatter %[[TILE_0]], %[[RESHAPE_2]], %[[TILE]]
915917// CHECK: %[[RESHAPE_3:.*]] = tosa.reshape %[[SCATTER]] {new_shape = array<i64: 4, 4, 2>}
0 commit comments