|
1 | 1 | // RUN: lce-tf-opt %s -tfl-prepare-lce=target=arm -verify-diagnostics | FileCheck %s --check-prefixes CHECK,CHECK-ARM
|
2 | 2 | // RUN: lce-tf-opt %s -tfl-prepare-lce=target=xcore -verify-diagnostics | FileCheck %s --check-prefixes CHECK,CHECK-XCORE
|
3 | 3 |
|
4 |
| -// CHECK-LABEL: @fuse_bsign |
5 |
| -func @fuse_bsign(%arg0: tensor<8x16xf32>) -> tensor<8x16xf32> { |
| 4 | +// CHECK-LABEL: @fuse_bsign_tf_where |
| 5 | +func @fuse_bsign_tf_where(%arg0: tensor<8x16xi1>) -> tensor<8x16xf32> { |
| 6 | + %cst_l = constant dense<1.0> : tensor<8x16xf32> |
| 7 | + %cst_r = constant dense<-1.0> : tensor<8x16xf32> |
| 8 | + %0 = "tf.SelectV2"(%arg0, %cst_l, %cst_r) : (tensor<8x16xi1>, tensor<8x16xf32>, tensor<8x16xf32>) -> tensor<8x16xf32> |
| 9 | + return %0 : tensor<8x16xf32> |
| 10 | + |
| 11 | + // CHECK-NEXT: %0 = "lq.Quantize"(%arg0) : (tensor<8x16xi1>) -> tensor<8x1xi32> |
| 12 | + // CHECK-NEXT: %1 = "lq.Dequantize"(%0) : (tensor<8x1xi32>) -> tensor<8x16xf32> |
| 13 | + // CHECK-NEXT: return %1 |
| 14 | +} |
| 15 | + |
| 16 | +// CHECK-LABEL: @fuse_bsign_tf_where_inverted |
| 17 | +func @fuse_bsign_tf_where_inverted(%arg0: tensor<8x16xi1>) -> tensor<8x16xf32> { |
| 18 | + %cst_l = constant dense<-1.0> : tensor<8x16xf32> |
| 19 | + %cst_r = constant dense<1.0> : tensor<8x16xf32> |
| 20 | + %0 = "tf.SelectV2"(%arg0, %cst_l, %cst_r) : (tensor<8x16xi1>, tensor<8x16xf32>, tensor<8x16xf32>) -> tensor<8x16xf32> |
| 21 | + return %0 : tensor<8x16xf32> |
| 22 | + |
| 23 | + // CHECK-NEXT: %0 = "tf.LogicalNot"(%arg0) : (tensor<8x16xi1>) -> tensor<8x16xi1> |
| 24 | + // CHECK-NEXT: %1 = "lq.Quantize"(%0) : (tensor<8x16xi1>) -> tensor<8x1xi32> |
| 25 | + // CHECK-NEXT: %2 = "lq.Dequantize"(%1) : (tensor<8x1xi32>) -> tensor<8x16xf32> |
| 26 | + // CHECK-NEXT: return %2 |
| 27 | +} |
| 28 | + |
| 29 | +// CHECK-LABEL: @fuse_bsign_tf_where_broadcast_cond |
| 30 | +func @fuse_bsign_tf_where_broadcast_cond(%arg0: tensor<8x1xi1>) -> tensor<8x16xf32> { |
| 31 | + %cst_l = constant dense<1.0> : tensor<8x16xf32> |
| 32 | + %cst_r = constant dense<-1.0> : tensor<8x16xf32> |
| 33 | + %0 = "tf.SelectV2"(%arg0, %cst_l, %cst_r) : (tensor<8x1xi1>, tensor<8x16xf32>, tensor<8x16xf32>) -> tensor<8x16xf32> |
| 34 | + return %0 : tensor<8x16xf32> |
| 35 | + |
| 36 | + // CHECK-NEXT: %cst = constant dense<[8, 1]> : tensor<2xi64> |
| 37 | + // CHECK-NEXT: %0 = "tf.BroadcastTo"(%arg0, %cst) : (tensor<8x1xi1>, tensor<2xi64>) -> tensor<8x16xi1> |
| 38 | + // CHECK-NEXT: %1 = "lq.Quantize"(%0) : (tensor<8x16xi1>) -> tensor<8x1xi32> |
| 39 | + // CHECK-NEXT: %2 = "lq.Dequantize"(%1) : (tensor<8x1xi32>) -> tensor<8x16xf32> |
| 40 | + // CHECK-NEXT: return %2 |
| 41 | +} |
| 42 | + |
| 43 | +// CHECK-LABEL: @fuse_bsign_tf_where_broadcast_lhs_rhs |
| 44 | +func @fuse_bsign_tf_where_broadcast_lhs_rhs(%arg0: tensor<8x16xi1>) -> tensor<8x16xf32> { |
| 45 | + %cst_l = constant dense<1.0> : tensor<f32> |
| 46 | + %cst_r = constant dense<-1.0> : tensor<8x1xf32> |
| 47 | + %0 = "tf.SelectV2"(%arg0, %cst_l, %cst_r) : (tensor<8x16xi1>, tensor<f32>, tensor<8x1xf32>) -> tensor<8x16xf32> |
| 48 | + return %0 : tensor<8x16xf32> |
| 49 | + |
| 50 | + // CHECK-NEXT: %0 = "lq.Quantize"(%arg0) : (tensor<8x16xi1>) -> tensor<8x1xi32> |
| 51 | + // CHECK-NEXT: %1 = "lq.Dequantize"(%0) : (tensor<8x1xi32>) -> tensor<8x16xf32> |
| 52 | + // CHECK-NEXT: return %1 |
| 53 | +} |
| 54 | + |
| 55 | +// CHECK-LABEL: @fuse_bsign_tf_where_select_v1_op |
| 56 | +func @fuse_bsign_tf_where_select_v1_op(%arg0: tensor<8x16xi1>) -> tensor<8x16xf32> { |
| 57 | + %cst_l = constant dense<1.0> : tensor<8x16xf32> |
| 58 | + %cst_r = constant dense<-1.0> : tensor<8x16xf32> |
| 59 | + %0 = "tf.Select"(%arg0, %cst_l, %cst_r) : (tensor<8x16xi1>, tensor<8x16xf32>, tensor<8x16xf32>) -> tensor<8x16xf32> |
| 60 | + return %0 : tensor<8x16xf32> |
| 61 | + |
| 62 | + // CHECK-NEXT: %0 = "lq.Quantize"(%arg0) : (tensor<8x16xi1>) -> tensor<8x1xi32> |
| 63 | + // CHECK-NEXT: %1 = "lq.Dequantize"(%0) : (tensor<8x1xi32>) -> tensor<8x16xf32> |
| 64 | + // CHECK-NEXT: return %1 |
| 65 | +} |
| 66 | + |
| 67 | +// CHECK-LABEL: @fuse_bsign_legacy_tf_sign |
| 68 | +func @fuse_bsign_legacy_tf_sign(%arg0: tensor<8x16xf32>) -> tensor<8x16xf32> { |
6 | 69 | %0 = "tf.Sign"(%arg0) : (tensor<8x16xf32>) -> tensor<8x16xf32>
|
7 | 70 | %cst = constant dense<0.1> : tensor<f32>
|
8 | 71 | %2 = "tf.AddV2"(%0, %cst) : (tensor<8x16xf32>, tensor<f32>) -> tensor<8x16xf32>
|
|
0 commit comments