luclima commited on
Commit
23d7891
·
verified ·
1 Parent(s): aabb13f

Upload folder using huggingface_hub (part 49)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graph/convert_tensor.mlir +31 -0
  2. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/BUILD +24 -0
  3. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/aliasing_arg_attr.mlir +16 -0
  4. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/case.mlir +38 -0
  5. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/convert_tensor.mlir +32 -0
  6. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/derived_shape_attr.mlir +28 -0
  7. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/derived_size_attr.mlir +19 -0
  8. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/device-arg-retval-attr.mlir +54 -0
  9. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/export_main_to_flib.mlir +20 -0
  10. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/fetch_feed_names.mlir +31 -0
  11. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/func_attr.mlir +43 -0
  12. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/func_list_attr.mlir +67 -0
  13. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-control-ret.mlir +26 -0
  14. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-order.mlir +85 -0
  15. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-resource-args-handle-info.mlir +42 -0
  16. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-resource-args.mlir +61 -0
  17. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/functional-if-ops.mlir +65 -0
  18. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/functional-while-ops.mlir +89 -0
  19. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/graph-as-function.mlir +79 -0
  20. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/infer_derived_attribute.mlir +26 -0
  21. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/invalid_input.mlir +96 -0
  22. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/legalized_name.mlir +22 -0
  23. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/missing-main.mlir +11 -0
  24. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/noop.mlir +16 -0
  25. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/optional_symbol_ref.mlir +20 -0
  26. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/output-shapes-attr.mlir +98 -0
  27. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/parse_example.mlir +61 -0
  28. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/parse_example_v2.mlir +83 -0
  29. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/preserve-entry-func-names.mlir +28 -0
  30. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/ref-type-attr.mlir +20 -0
  31. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/ref-while-loop.mlir +26 -0
  32. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/shape_list_attr.mlir +35 -0
  33. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/simple.mlir +29 -0
  34. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/stringescape.mlir +18 -0
  35. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/switchn.mlir +59 -0
  36. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf-gradient-attr.mlir +47 -0
  37. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf-legacy-call.mlir +36 -0
  38. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf_add.mlir +41 -0
  39. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf_identity_n.mlir +25 -0
  40. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf_tpu_embedding_ops.mlir +62 -0
  41. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/type_attr.mlir +41 -0
  42. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/type_list_attr.mlir +21 -0
  43. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/unique_name.mlir +20 -0
  44. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/unique_output_name.mlir +28 -0
  45. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/while-loop.mlir +27 -0
  46. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlprogram.mlir +136 -0
  47. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/move_tpu_compile_to_front.mlir +47 -0
  48. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/name_anonymous_iterators.mlir +36 -0
  49. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/optimize-arg-operand-constraint.mlir +13 -0
  50. western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/optimize.mlir +54 -0
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graph/convert_tensor.mlir ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graph %s -o - | FileCheck %s
2
+
3
+ func.func @main() -> (tensor<1x2xf16>, tensor<2xf16>) {
4
+ %graph:2 = tf_executor.graph {
5
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_HALF", value = dense<1.0> : tensor<1x2xf16>} : () -> tensor<1x2xf16> loc("const1")
6
+ // CHECK: node {
7
+ // CHECK-NEXT: name: "const1"
8
+ // CHECK-NEXT: op: "Const"
9
+ // CHECK: dtype: DT_HALF
10
+ // CHECK: half_val: 15360
11
+ %1:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_HALF", value = dense<[1.0, 2.0]> : tensor<2xf16>} : () -> tensor<2xf16> loc("const2")
12
+ // CHECK: name: "const2"
13
+ // CHECK-NEXT: op: "Const"
14
+ // CHECK: dtype: DT_HALF
15
+ // CHECK: half_val: 15360
16
+ // CHECK-NEXT: half_val: 16384
17
+ %2:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = bf16, value = dense<[4.900000e+01, 8.200000e+02]> : tensor<2xbf16>} : () -> tensor<bf16> loc("const3")
18
+ // CHECK: name: "const3"
19
+ // CHECK-NEXT: op: "Const"
20
+ // CHECK: dtype: DT_BFLOAT16
21
+ // CHECK: half_val: 16964
22
+ // CHECK: half_val: 17485
23
+ %3:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = bf16, value = dense<0.000000e+00> : tensor<bf16>} : () -> tensor<bf16> loc("const4")
24
+ // CHECK: name: "const4"
25
+ // CHECK-NEXT: op: "Const"
26
+ // CHECK: dtype: DT_BFLOAT16
27
+ // CHECK-NOT: half_val: 0
28
+ tf_executor.fetch %0#0, %1#0 : tensor<1x2xf16>, tensor<2xf16>
29
+ }
30
+ func.return %graph#0, %graph#1 : tensor<1x2xf16>, tensor<2xf16>
31
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/BUILD ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ load("//tensorflow:tensorflow.default.bzl", "filegroup")
2
+ load("//tensorflow/compiler/mlir:glob_lit_test.bzl", "glob_lit_tests")
3
+
4
+ # copybara:uncomment package(default_applicable_licenses = ["//tensorflow:license"])
5
+
6
+ licenses(["notice"])
7
+
8
+ glob_lit_tests(
9
+ name = "all_tests",
10
+ data = [":test_utilities"],
11
+ driver = "@llvm-project//mlir:run_lit.sh",
12
+ test_file_exts = ["mlir"],
13
+ )
14
+
15
+ # Bundle together all of the test utilities that are used by tests.
16
+ filegroup(
17
+ name = "test_utilities",
18
+ testonly = True,
19
+ data = [
20
+ "//tensorflow/compiler/mlir:tf-mlir-translate",
21
+ "@llvm-project//llvm:FileCheck",
22
+ "@llvm-project//llvm:not",
23
+ ],
24
+ )
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/aliasing_arg_attr.mlir ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -tf-graph-as-function -o - | FileCheck %s
2
+
3
+ // Verify tf.aliasing_output attributes on args are dropped during export.
4
+
5
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 0 : i32, producer = 121 : i32}} {
6
+ func.func @main(%arg0: tensor<*xf32> {tf.aliasing_output = 0 : i64}, %arg1: tensor<2x4x6x8xi32>) -> (tensor<*xf32>, tensor<2x4x6x8xi32> {tf.device = "/CPU:1"})
7
+ attributes {tf.entry_function = {inputs = "args_0,args_1", outputs = "rets_0,rets_1"}} {
8
+ %0:2 = tf_executor.graph {
9
+ %1:3 = tf_executor.island wraps "tf.IdentityN"(%arg0, %arg1) {T = ["tfdtype$DT_FLOAT", "tfdtype$DT_INT32"], device = "", name = "identity"} : (tensor<*xf32>, tensor<2x4x6x8xi32>) -> (tensor<*xf32>, tensor<2x4x6x8xi32>)
10
+ tf_executor.fetch %1#0, %1#1 : tensor<*xf32>, tensor<2x4x6x8xi32>
11
+ }
12
+ func.return %0#0, %0#1 : tensor<*xf32>, tensor<2x4x6x8xi32>
13
+ }
14
+ }
15
+
16
+ // CHECK-NOT: aliasing_output
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/case.mlir ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 486 : i32}} {
4
+ func.func @main() {
5
+ tf_executor.graph {
6
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", value = dense<1> : tensor<i32>} : () -> tensor<i32>
7
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<0> : tensor<i32>} : () -> tensor<i32>
8
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Case"(%outputs_0, %outputs) {Tin = [i32], Tout = [i32], _lower_using_switch_merge = true, _read_only_resource_inputs = [], branches = [@indexed_case_branch0_40, @indexed_case_branch1_50], device = "", is_stateless = true, output_shapes = [#tf_type.shape<>]} : (tensor<i32>, tensor<i32>) -> tensor<*xi32> loc("stateless_case")
9
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.Identity"(%outputs_2) {device = ""} : (tensor<*xi32>) -> tensor<*xi32>
10
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.Case"(%outputs_0, %outputs) {Tin = [i32], Tout = [i32], _lower_using_switch_merge = true, _read_only_resource_inputs = [], branches = [@indexed_case_branch0_40, @indexed_case_branch1_50], device = "", is_stateless = false, output_shapes = [#tf_type.shape<>]} : (tensor<i32>, tensor<i32>) -> tensor<*xi32> loc("regular_case")
11
+ tf_executor.fetch
12
+ }
13
+ func.return
14
+ }
15
+
16
+ func.func private @indexed_case_branch0_40(%arg0: tensor<i32>) -> tensor<*xi32> {
17
+ %0 = tf_executor.graph {
18
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", value = dense<1> : tensor<i32>} : () -> tensor<i32>
19
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.AddV2"(%arg0, %outputs) {device = ""} : (tensor<i32>, tensor<i32>) -> tensor<*xi32>
20
+ tf_executor.fetch %outputs_0 : tensor<*xi32>
21
+ }
22
+ func.return %0 : tensor<*xi32>
23
+ }
24
+
25
+ func.func private @indexed_case_branch1_50(%arg0: tensor<i32>) -> tensor<*xi32> {
26
+ %0 = tf_executor.graph {
27
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", value = dense<2> : tensor<i32>} : () -> tensor<i32>
28
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.AddV2"(%arg0, %outputs) {device = ""} : (tensor<i32>, tensor<i32>) -> tensor<*xi32>
29
+ tf_executor.fetch %outputs_0 : tensor<*xi32>
30
+ }
31
+ func.return %0 : tensor<*xi32>
32
+ }
33
+ }
34
+
35
+ // CHECK: name: "stateless_case"
36
+ // CHECK-NEXT: "StatelessCase"
37
+ // CHECK: name: "regular_case"
38
+ // CHECK-NEXT: "Case"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/convert_tensor.mlir ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() -> (tensor<1x2xf16>, tensor<2xf16>) {
4
+ %graph:2 = tf_executor.graph {
5
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_HALF", value = dense<1.0> : tensor<1x2xf16>} : () -> tensor<1x2xf16> loc("const1")
6
+ %1:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_HALF", value = dense<[1.0, 2.0]> : tensor<2xf16>} : () -> tensor<2xf16> loc("const2")
7
+ %2:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = bf16, value = dense<[4.900000e+01, 8.200000e+02]> : tensor<2xbf16>} : () -> tensor<bf16> loc("const3")
8
+ %3:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = bf16, value = dense<0.000000e+00> : tensor<bf16>} : () -> tensor<bf16> loc("const4")
9
+ tf_executor.fetch %0#0, %1#0 : tensor<1x2xf16>, tensor<2xf16>
10
+ }
11
+ func.return %graph#0, %graph#1 : tensor<1x2xf16>, tensor<2xf16>
12
+ }
13
+
14
+ // CHECK: node {
15
+ // CHECK-NEXT: name: "const1"
16
+ // CHECK-NEXT: op: "Const"
17
+ // CHECK: dtype: DT_HALF
18
+ // CHECK: half_val: 15360
19
+ // CHECK: name: "const2"
20
+ // CHECK-NEXT: op: "Const"
21
+ // CHECK: dtype: DT_HALF
22
+ // CHECK: half_val: 15360
23
+ // CHECK: half_val: 16384
24
+ // CHECK: name: "const3"
25
+ // CHECK-NEXT: op: "Const"
26
+ // CHECK: dtype: DT_BFLOAT16
27
+ // CHECK: half_val: 16964
28
+ // CHECK: half_val: 17485
29
+ // CHECK: name: "const4"
30
+ // CHECK-NEXT: op: "Const"
31
+ // CHECK: dtype: DT_BFLOAT16
32
+ // CHECK-NOT: half_val: 0
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/derived_shape_attr.mlir ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ // Check that attributes that define derived shapes are exported.
4
+
5
+ // CHECK: op: "PlaceholderWithDefault"
6
+ // CHECK: shape
7
+ // CHECK: unknown_rank: true
8
+ // CHECK: name: "static"
9
+ // CHECK: op: "PlaceholderWithDefault"
10
+ // CHECK: shape {
11
+ // CHECK-NEXT: }
12
+ // CHECK: name: "static_10"
13
+ // CHECK: op: "PlaceholderWithDefault"
14
+ // CHECK: shape
15
+ // CHECK: dim
16
+ // CHECK: size: 10
17
+
18
+ func.func @main() {
19
+ tf_executor.graph {
20
+ %0:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<10xi32>} : () -> tensor<10xi32>
21
+ %1:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<i32>} : () -> tensor<i32>
22
+ %2:2 = tf_executor.island wraps "tf.PlaceholderWithDefault"(%1#0) {type = i32} : (tensor<i32>) -> tensor<*xi32> loc("unranked")
23
+ %3:2 = tf_executor.island wraps "tf.PlaceholderWithDefault"(%1#0) {type = i32} : (tensor<i32>) -> tensor<i32> loc("static")
24
+ %4:2 = tf_executor.island wraps "tf.PlaceholderWithDefault"(%0#0) {type = i32} : (tensor<10xi32>) -> tensor<10xi32> loc("static_10")
25
+ tf_executor.fetch
26
+ }
27
+ func.return
28
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/derived_size_attr.mlir ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ // CHECK: op: "Split"
4
+ // CHECK: attr {
5
+ // CHECK: key: "num_split"
6
+ // CHECK: value {
7
+ // CHECK: i: 2
8
+ // CHECK: }
9
+ // CHECK: }
10
+
11
+ func.func @main() {
12
+ tf_executor.graph {
13
+ %dim:2 = tf_executor.island wraps "tf.Const"() {dtype = "tftype$DT_INT32", value = dense<0> : tensor<i32>} : () -> tensor<i32>
14
+ %input:2 = tf_executor.island wraps "tf.Const"() {dtype = "tftype$DT_INT32", value = dense<1.0> : tensor<4x6xf32>} : () -> tensor<4x6xf32>
15
+ %split:3 = tf_executor.island wraps "tf.Split"(%dim#0, %input#0) : (tensor<i32>, tensor<4x6xf32>) -> (tensor<2x6xf32>, tensor<2x6xf32>)
16
+ tf_executor.fetch
17
+ }
18
+ func.return
19
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/device-arg-retval-attr.mlir ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -tf-graph-as-function -o - | FileCheck %s
2
+
3
+ // Verify arg/ret attributes are exported as device assignment for arg/retval
4
+ // nodes.
5
+
6
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 0 : i32, producer = 121 : i32}} {
7
+ func.func @main(%arg0: tensor<*xf32> {tf.device = "/CPU:0"}, %arg1: tensor<2x4x6x8xi32>) -> (tensor<*xf32>, tensor<2x4x6x8xi32> {tf.device = "/CPU:1"})
8
+ attributes {tf.entry_function = {inputs = "args_0,args_1", outputs = "rets_0,rets_1"}} {
9
+ %0:2 = tf_executor.graph {
10
+ %1:3 = tf_executor.island wraps "tf.IdentityN"(%arg0, %arg1) {T = ["tfdtype$DT_FLOAT", "tfdtype$DT_INT32"], device = "", name = "identity"} : (tensor<*xf32>, tensor<2x4x6x8xi32>) -> (tensor<*xf32>, tensor<2x4x6x8xi32>)
11
+ tf_executor.fetch %1#0, %1#1 : tensor<*xf32>, tensor<2x4x6x8xi32>
12
+ }
13
+ func.return %0#0, %0#1 : tensor<*xf32>, tensor<2x4x6x8xi32>
14
+ }
15
+ }
16
+
17
+ // CHECK: node {
18
+ // CHECK-NEXT: name: "args_0"
19
+ // CHECK-NEXT: op: "_Arg"
20
+ // CHECK: device: "/CPU:0"
21
+ // CHECK: attr {
22
+ // CHECK: key: "index"
23
+ // CHECK-NEXT: value {
24
+ // CHECK-NEXT: i: 0
25
+ //
26
+ // CHECK: node {
27
+ // CHECK-NEXT: name: "args_1"
28
+ // CHECK-NEXT: op: "_Arg"
29
+ // CHECK-NOT: device
30
+ // CHECK: attr {
31
+ // CHECK: key: "index"
32
+ // CHECK-NEXT: value {
33
+ // CHECK-NEXT: i: 1
34
+ //
35
+ // CHECK: node {
36
+ // CHECK: op: "IdentityN"
37
+ //
38
+ // CHECK: node {
39
+ // CHECK-NEXT: name: "rets_0"
40
+ // CHECK-NEXT: op: "_Retval"
41
+ // CHECK-NOT: device
42
+ // CHECK: attr {
43
+ // CHECK: key: "index"
44
+ // CHECK-NEXT: value {
45
+ // CHECK-NEXT: i: 0
46
+ //
47
+ // CHECK: node {
48
+ // CHECK-NEXT: name: "rets_1"
49
+ // CHECK-NEXT: op: "_Retval"
50
+ // CHECK: device: "/CPU:1"
51
+ // CHECK: attr {
52
+ // CHECK: key: "index"
53
+ // CHECK-NEXT: value {
54
+ // CHECK-NEXT: i: 1
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/export_main_to_flib.mlir ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef -tf-export-entry-func-to-flib %s -o - 2>&1 | FileCheck %s
2
+
3
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 458 : i32}} {
4
+ func.func @main() attributes {tf.entry_function = {inputs = "", outputs = ""}} {
5
+ tf_executor.graph {
6
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "TPU:0", name = "const", dtype = "tfdtype$DT_INT32", value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32>
7
+ tf_executor.fetch
8
+ }
9
+ func.return
10
+ }
11
+ }
12
+
13
+ // CHECK-NOT: node
14
+
15
+ // CHECK: library
16
+ // CHECK-NEXT: function
17
+ // CHECK-NEXT: signature
18
+ // CHECK-NEXT: name: "main"
19
+ // CHECK: node_def
20
+ // CHECK: op: "Const"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/fetch_feed_names.mlir ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s | tf-mlir-translate -graphdef-to-mlir
2
+
3
+ // Test graphdef export is producing valid GraphDef. The test imports the
4
+ // generated GraphDef to make sure the export is valid.
5
+
6
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 890 : i32}} {
7
+ func.func @main(%arg0: tensor<100x28x28x3xf32> {}) -> (tensor<*xf32> {}) attributes {tf.entry_function = {control_outputs = "", inputs = "a:0", outputs = "conv2d_2/BiasAdd:0"}} {
8
+ %0 = tf_executor.graph {
9
+ %outputs, %control = tf_executor.island wraps "tf.StatefulPartitionedCall"(%arg0) {_collective_manager_ids = [], _read_only_resource_inputs = [1, 2], config = "", config_proto = "\0A\07\0A\03CPU\10\01\0A\07\0A\03GPU\10\002\02J\008\01\82\01\00", device = "", executor_type = "", f = @__inference_call_440} : (tensor<100x28x28x3xf32>) -> tensor<*xf32>
10
+ %outputs_0, %control_1 = tf_executor.island(%control) wraps "tf.Const"() {value = dense<0.000000e+00> : tensor<16xf32>} : () -> tensor<16xf32>
11
+ %outputs_2, %control_3 = tf_executor.island(%control_1) wraps "tf.Const"() {value = dense<0.000000e+00> : tensor<5x5x32x16xf32>} : () -> tensor<5x5x32x16xf32>
12
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.Conv2D"(%outputs, %outputs_2) {data_format = "NHWC", device = "", dilations = [1, 1, 1, 1], explicit_paddings = [], padding = "VALID", strides = [1, 1, 1, 1], use_cudnn_on_gpu = true} : (tensor<*xf32>, tensor<5x5x32x16xf32>) -> tensor<*xf32>
13
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.BiasAdd"(%outputs_4, %outputs_0) {data_format = "NHWC", device = ""} : (tensor<*xf32>, tensor<16xf32>) -> tensor<*xf32>
14
+ tf_executor.fetch %outputs_6 : tensor<*xf32>
15
+ }
16
+ func.return %0 : tensor<*xf32>
17
+ }
18
+ func.func private @__inference_call_440(%arg0: tensor<?x28x28x3xf32> {tf._user_specified_name = "inputs"}) -> tensor<*xf32> attributes {tf._input_shapes = [#tf_type.shape<?x28x28x3>], tf.signature.is_stateful} {
19
+ %0 = tf_executor.graph {
20
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {value = dense<0.000000e+00> : tensor<32xf32>} : () -> tensor<32xf32>
21
+ %outputs_0, %control_1 = tf_executor.island(%control) wraps "tf.Const"() {value = dense<0.000000e+00> : tensor<5x5x3x32xf32>} : () -> tensor<5x5x3x32xf32>
22
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Conv2D"(%arg0, %outputs_0) {data_format = "NHWC", device = "", dilations = [1, 1, 1, 1], explicit_paddings = [], padding = "VALID", strides = [1, 1, 1, 1], use_cudnn_on_gpu = true} : (tensor<?x28x28x3xf32>, tensor<5x5x3x32xf32>) -> tensor<*xf32>
23
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.BiasAdd"(%outputs_2, %outputs) {data_format = "NHWC", device = ""} : (tensor<*xf32>, tensor<32xf32>) -> tensor<*xf32>
24
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.Identity"(%outputs_4) {device = ""} : (tensor<*xf32>) -> tensor<*xf32>
25
+ tf_executor.fetch %outputs_6 : tensor<*xf32>
26
+ }
27
+ func.return %0 : tensor<*xf32>
28
+ }
29
+ }
30
+
31
+
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/func_attr.mlir ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -tf-export-original-func-name | tf-mlir-translate -graphdef-to-mlir | tf-mlir-translate -mlir-to-graphdef -tf-export-original-func-name | FileCheck %s
2
+
3
+ // Tests #tf_type.func attributes are exported as AttrValue.NameAttrList attributes
4
+ // with its attr field populated with nested attributes.
5
+
6
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 458 : i32}} {
7
+ func.func @main() {
8
+ tf_executor.graph {
9
+ %control = tf_executor.island wraps "tf.NoOp"() {_f = #tf_type.func<@callee, {attr2 = true, attr3 = 8.0 : f32}>} : () -> ()
10
+ %control_1 = tf_executor.island(%control) wraps "tf.LegacyCall"() {f = @callee} : () -> ()
11
+ tf_executor.fetch
12
+ }
13
+ func.return
14
+ }
15
+ func.func @callee() attributes {tf._original_func_name = "original_callee"} {
16
+ tf_executor.graph {
17
+ tf_executor.fetch
18
+ }
19
+ func.return
20
+ }
21
+ }
22
+
23
+ // CHECK: op: "NoOp"
24
+ // CHECK-NEXT: attr
25
+ // CHECK-NEXT: key: "_f"
26
+ // CHECK-NEXT: value
27
+ // CHECK-NEXT: func
28
+ // CHECK-NEXT: name: "original_callee"
29
+ // CHECK-NEXT: attr
30
+ // CHECK-NEXT: key: "attr2"
31
+ // CHECK-NEXT: value
32
+ // CHECK-NEXT: b: true
33
+ // CHECK: attr
34
+ // CHECK-NEXT: key: "attr3"
35
+ // CHECK-NEXT: value
36
+ // CHECK-NEXT: f: 8
37
+
38
+ // CHECK: op: "original_callee"
39
+
40
+ // CHECK: library
41
+ // CHECK-NEXT: function
42
+ // CHECK-NEXT: signature
43
+ // CHECK-NEXT: name: "original_callee"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/func_list_attr.mlir ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ // CHECK: node {
6
+ // CHECK-NEXT: name: "predicate"
7
+ // CHECK-NEXT: op: "Const"
8
+ // CHECK-NEXT: attr {
9
+ // CHECK: key: "dtype"
10
+ // CHECK-NEXT: value {
11
+ // CHECK-NEXT: type: DT_INT32
12
+ // CHECK-NEXT: }
13
+ // CHECK-NEXT: }
14
+ // CHECK-NEXT: attr {
15
+ // CHECK-NEXT: key: "value"
16
+ // CHECK-NEXT: value {
17
+ // CHECK-NEXT: tensor {
18
+ // CHECK-NEXT: dtype: DT_INT32
19
+ // CHECK-NEXT: tensor_shape {
20
+ // CHECK-NEXT: }
21
+ // CHECK-NEXT: }
22
+ // CHECK-NEXT: }
23
+ // CHECK-NEXT: }
24
+ // CHECK: }
25
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<i32>} : () -> tensor<i32> loc("predicate")
26
+
27
+ // CHECK: node {
28
+ // CHECK-NEXT: name: "Case"
29
+ // CHECK-NEXT: op: "Case"
30
+ // CHECK-NEXT: input: "predicate"
31
+ // CHECK: attr {
32
+ // CHECK: key: "branches"
33
+ // CHECK-NEXT: value {
34
+ // CHECK-NEXT: list {
35
+ // CHECK-NEXT: func {
36
+ // CHECK-NEXT: name: "foo"
37
+ // CHECK-NEXT: }
38
+ // CHECK-NEXT: func {
39
+ // CHECK-NEXT: name: "bar"
40
+ // CHECK-NEXT: }
41
+ // CHECK-NEXT: }
42
+ // CHECK-NEXT: }
43
+ // CHECK-NEXT: }
44
+ // CHECK: }
45
+ %1:2 = tf_executor.island wraps "tf.Case"(%0#0) {Tin = [], Tout = ["tfdtype$DT_FLOAT"], branches = [@foo, @bar], device = "", output_shapes = [], is_stateless = false} : (tensor<i32>) -> tensor<*xf32> loc("Case")
46
+ tf_executor.fetch
47
+ }
48
+ func.return
49
+ }
50
+
51
+ // CHECK-DAG: name: "foo"
52
+ func.func @foo() -> tensor<10xf32> {
53
+ %0 = tf_executor.graph {
54
+ %1:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_FLOAT", value = dense<1.000000e+00> : tensor<10xf32>} : () -> tensor<10xf32> loc("const_1")
55
+ tf_executor.fetch %1#0 : tensor<10xf32>
56
+ }
57
+ func.return %0 : tensor<10xf32>
58
+ }
59
+
60
+ // CHECK-DAG: name: "bar"
61
+ func.func @bar() -> tensor<10xf32> {
62
+ %0 = tf_executor.graph {
63
+ %1:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_FLOAT", value = dense<2.000000e+00> : tensor<10xf32>} : () -> tensor<10xf32> loc("const_2")
64
+ tf_executor.fetch %1#0 : tensor<10xf32>
65
+ }
66
+ func.return %0 : tensor<10xf32>
67
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-control-ret.mlir ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 29 : i32}} {
4
+ func.func @main() {
5
+ tf_executor.graph {
6
+ %0 = tf_executor.island wraps "tf.PartitionedCall"() {Tin = [], Tout = [], config = "", config_proto = "", device = "", executor_type = "", f = @foo, name = "Call_foo"} : () -> ()
7
+ tf_executor.fetch
8
+ }
9
+ func.return
10
+ }
11
+ func.func @foo() {
12
+ tf_executor.graph {
13
+ %0:2 = tf_executor.island {
14
+ %1 = "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<5> : tensor<i32>} : () -> tensor<i32> loc("control_const")
15
+ tf_executor.yield %1 : tensor<i32>
16
+ }
17
+ // CHECK: control_output: "control_const"
18
+ // CHECK: control_ret {
19
+ // CHECK-NEXT: key: "control_const"
20
+ // CHECK-NEXT: value: "control_const"
21
+ // CHECK-NEXT: }
22
+ tf_executor.fetch %0#1 : !tf_executor.control
23
+ }
24
+ func.return
25
+ }
26
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-order.mlir ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+
4
+ func.func @main() {
5
+ tf_executor.graph {
6
+ // CHECK: node {
7
+ // CHECK-NEXT: name: "tf.PartitionedCall"
8
+ // CHECK-NEXT: op: "PartitionedCall"
9
+ // CHECK: func {
10
+ // CHECK: name: "foo"
11
+ // CHECK: }
12
+ // CHECK: }
13
+ %0 = tf_executor.island wraps "tf.PartitionedCall"() {Tin = [], Tout = [], config = "", config_proto = "", device = "", executor_type = "", f = @foo, name = "Call_foo"} : () -> ()
14
+ tf_executor.fetch
15
+ }
16
+ func.return
17
+ }
18
+
19
+ // CHECK: library {
20
+ // CHECK: function {
21
+ // CHECK-NEXT: signature {
22
+ // CHECK-NEXT: name: "bar"
23
+ // CHECK-NEXT: }
24
+ // CHECK: node_def {
25
+ // CHECK-NEXT: name: "tf.Const"
26
+ // CHECK-NEXT: op: "Const"
27
+ // CHECK-NEXT: attr {
28
+ // CHECK: key: "dtype"
29
+ // CHECK-NEXT: value {
30
+ // CHECK-NEXT: type: DT_INT32
31
+ // CHECK-NEXT: }
32
+ // CHECK-NEXT: }
33
+ // CHECK-NEXT: attr {
34
+ // CHECK-NEXT: key: "value"
35
+ // CHECK-NEXT: value {
36
+ // CHECK-NEXT: tensor {
37
+ // CHECK-NEXT: dtype: DT_INT32
38
+ // CHECK-NEXT: tensor_shape {
39
+ // CHECK-NEXT: }
40
+ // CHECK-NEXT: int_val: 1
41
+ // CHECK-NEXT: }
42
+ // CHECK-NEXT: }
43
+ // CHECK-NEXT: }
44
+ // CHECK: }
45
+ // CHECK: node_def {
46
+ // CHECK-NEXT: name: "tf.Empty"
47
+ // CHECK-NEXT: op: "Empty"
48
+ // CHECK-NEXT: input: "tf.Const:output:0"
49
+ // CHECK-NEXT: attr {
50
+ // CHECK: key: "dtype"
51
+ // CHECK-NEXT: value {
52
+ // CHECK-NEXT: type: DT_FLOAT
53
+ // CHECK-NEXT: }
54
+ // CHECK-NEXT: }
55
+ // CHECK: }
56
+ // CHECK-NEXT: }
57
+ func.func @bar() {
58
+ tf_executor.graph {
59
+ %0:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", name = "tf.Const", value = dense<1> : tensor<i32>} : () -> tensor<i32>
60
+ %1:2 = tf_executor.island wraps "tf.Empty"(%0#0) {dtype = "tfdtype$DT_FLOAT", name = "tf.Empty"} : (tensor<i32>) -> tensor<*xf32>
61
+ tf_executor.fetch
62
+ }
63
+ func.return
64
+ }
65
+
66
+ // CHECK: function {
67
+ // CHECK-NEXT: signature {
68
+ // CHECK-NEXT: name: "foo"
69
+ // CHECK-NEXT: }
70
+ // CHECK-NEXT: node_def {
71
+ // CHECK-NEXT: name: "tf.PartitionedCall"
72
+ // CHECK-NEXT: op: "PartitionedCall"
73
+ // CHECK: func {
74
+ // CHECK: name: "bar"
75
+ // CHECK: }
76
+ // CHECK: }
77
+ // CHECK-NEXT: }
78
+ // CHECK: }
79
+ func.func @foo() {
80
+ tf_executor.graph {
81
+ %0 = tf_executor.island wraps "tf.PartitionedCall"() {Tin = [], Tout = [], config = "", config_proto = "", device = "", executor_type = "", f = @bar, name = "Call_bar"} : () -> ()
82
+ tf_executor.fetch
83
+ }
84
+ func.return
85
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-resource-args-handle-info.mlir ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<*x!tf_type.resource<tensor<8x1xf32>>>) -> tensor<8x1xf32> {
4
+ %0 = tf_executor.graph {
5
+ %outputs, %control = tf_executor.island wraps "tf.ReadVariableOp"(%arg0) : (tensor<*x!tf_type.resource<tensor<8x1xf32>>>) -> tensor<8x1xf32>
6
+ tf_executor.fetch %outputs : tensor<8x1xf32>
7
+ }
8
+ func.return %0 : tensor<8x1xf32>
9
+ }
10
+
11
+ // Check that we generate _handle_dtypes and _handle_shapes for the resource
12
+ // argument.
13
+
14
+ // CHECK: op: "_Arg"
15
+
16
+ // CHECK: key: "_handle_dtypes"
17
+ // CHECK-NEXT: value {
18
+ // CHECK-NEXT: list {
19
+ // CHECK-NEXT: type: DT_FLOAT
20
+ // CHECK-NEXT: }
21
+ // CHECK-NEXT: }
22
+ // CHECK-NEXT: }
23
+
24
+ // CHECK: key: "_handle_shapes"
25
+ // CHECK-NEXT: value {
26
+ // CHECK-NEXT: list {
27
+ // CHECK-NEXT: shape {
28
+ // CHECK-NEXT: dim {
29
+ // CHECK-NEXT: size: 8
30
+ // CHECK-NEXT: }
31
+ // CHECK-NEXT: dim {
32
+ // CHECK-NEXT: size: 1
33
+ // CHECK-NEXT: }
34
+ // CHECK-NEXT: }
35
+ // CHECK-NEXT: }
36
+
37
+ // CHECK: key: "index"
38
+ // CHECK-NEXT: value {
39
+ // CHECK-NEXT: i: 0
40
+ // CHECK-NEXT: }
41
+ // CHECK-NEXT: }
42
+
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/function-resource-args.mlir ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() -> tensor<*x!tf_type.resource> attributes {tf.entry_function = {inputs = "", outputs = "func_call"}} {
4
+ %0 = tf_executor.graph {
5
+ %outputs, %control = tf_executor.island wraps "tf.VarHandleOp"() {container = "a", device = "/CPU:0", dtype = i64, shape = "tfshape$", shared_name = "x"} : () -> tensor<!tf_type.resource<tensor<i64>>> loc("x")
6
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.LegacyCall"(%outputs, %outputs) {_disable_call_shape_inference = true, f = @test_func_name0} : (tensor<!tf_type.resource<tensor<i64>>>, tensor<!tf_type.resource<tensor<i64>>>) -> tensor<*x!tf_type.resource> loc("called")
7
+ tf_executor.fetch %outputs_0 : tensor<*x!tf_type.resource>
8
+ }
9
+ func.return %0 : tensor<*x!tf_type.resource>
10
+ }
11
+ func.func @test_func_name0(%arg0: tensor<*x!tf_type.resource> {tf._resource_arg_unique_id = 0 : i64}, %arg1: tensor<*x!tf_type.resource> {tf._resource_arg_unique_id = 0 : i64}) -> tensor<*x!tf_type.resource> attributes {tf._disable_call_shape_inference = true} {
12
+ %0 = tf_executor.graph {
13
+ tf_executor.fetch %arg0 : tensor<*x!tf_type.resource>
14
+ }
15
+ func.return %0 : tensor<*x!tf_type.resource>
16
+ }
17
+
18
+ // Check that the `tf._resource_arg_unique_id` argument attributes of
19
+ // test_func_name0 are propagated to the function's arg_attr and
20
+ // resource_arg_unique_id.
21
+
22
+ // CHECK: name: "x"
23
+ // CHECK: op: "VarHandleOp"
24
+
25
+ // CHECK: name: "func_call"
26
+ // CHECK: input: "called"
27
+
28
+ // CHECK: library
29
+ // CHECK: function
30
+ // CHECK: signature
31
+ // CHECK: input_arg
32
+ // CHECK: type: DT_RESOURCE
33
+ // CHECK: input_arg
34
+ // CHECK: type: DT_RESOURCE
35
+ // CHECK: output_arg
36
+ // CHECK: type: DT_RESOURCE
37
+ // CHECK: ret
38
+
39
+ // Check _resource_arg_unique_id for each argument. Since they alias each other,
40
+ // both values are 0.
41
+ // CHECK: arg_attr
42
+ // CHECK-NEXT: key: 0
43
+ // CHECK-NEXT: value
44
+ // CHECK: key: "_resource_arg_unique_id"
45
+ // CHECK-NEXT: value
46
+ // CHECK-NEXT: i: 0
47
+ // CHECK: arg_attr
48
+ // CHECK-NEXT: key: 1
49
+ // CHECK-NEXT: value
50
+ // CHECK: key: "_resource_arg_unique_id"
51
+ // CHECK-NEXT: value
52
+ // CHECK-NEXT: i: 0
53
+
54
+ // Check resource_arg_unique_id for each argument. Since they alias each other,
55
+ // both values are 0.
56
+ // CHECK: resource_arg_unique_id
57
+ // CHECK-NEXT: key: 0
58
+ // CHECK-NEXT: value: 0
59
+ // CHECK: resource_arg_unique_id
60
+ // CHECK-NEXT: key: 1
61
+ // CHECK-NEXT: value: 0
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/functional-if-ops.mlir ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<4xf32>, %arg3: tensor<4xf32>) -> (tensor<4xf32>, tensor<4xf32>) {
4
+ %0:2 = tf_executor.graph {
5
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Less"(%arg0, %arg1) : (tensor<f32>, tensor<f32>) -> tensor<i1>
6
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.If"(%outputs_2, %arg2, %arg3) {else_branch = @cond_false, is_stateless = false, then_branch = @cond_true} : (tensor<i1>, tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32> loc("StatefulIf")
7
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.If"(%outputs_2, %arg2, %arg3) {else_branch = @cond_false, is_stateless = true, then_branch = @cond_true} : (tensor<i1>, tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32> loc("StatelessIf")
8
+ tf_executor.fetch %outputs_4, %outputs_6 : tensor<4xf32>, tensor<4xf32>
9
+ }
10
+ func.return %0#0, %0#1 : tensor<4xf32>, tensor<4xf32>
11
+ }
12
+
13
+ func.func @cond_true(%arg0: tensor<*xf32>, %arg1: tensor<*xf32>) -> tensor<*xf32> {
14
+ %0 = tf_executor.graph {
15
+ %outputs, %control = tf_executor.island wraps "tf.Add"(%arg0, %arg1) : (tensor<*xf32>, tensor<*xf32>) -> tensor<*xf32>
16
+ tf_executor.fetch %outputs : tensor<*xf32>
17
+ }
18
+ func.return %0 : tensor<*xf32>
19
+ }
20
+
21
+ func.func @cond_false(%arg0: tensor<*xf32>, %arg1: tensor<*xf32>) -> tensor<*xf32> {
22
+ %0 = tf_executor.graph {
23
+ %outputs, %control = tf_executor.island wraps "tf.Mul"(%arg0, %arg1) : (tensor<*xf32>, tensor<*xf32>) -> tensor<*xf32>
24
+ tf_executor.fetch %outputs : tensor<*xf32>
25
+ }
26
+ func.return %0 : tensor<*xf32>
27
+ }
28
+
29
+ // Verify that If op is mapped to TensorFlow StatelessIf op if the is_stateless
30
+ // attribute is present and otherwise it is mapped to TensorFlow If op. In both
31
+ // cases, the additional attribute should be dropped.
32
+
33
+ // CHECK: name: "StatefulIf"
34
+ // CHECK-NOT: name:
35
+ // CHECK: op: "If"
36
+ // CHECK-NOT: is_stateless
37
+ // CHECK: attr {
38
+ // CHECK: key: "output_shapes"
39
+ // CHECK: value {
40
+ // CHECK: list {
41
+ // CHECK: shape {
42
+ // CHECK: dim {
43
+ // CHECK: size: 4
44
+ // CHECK: }
45
+ // CHECK: }
46
+ // CHECK: }
47
+ // CHECK: }
48
+ // CHECK: }
49
+
50
+ // CHECK: name: "StatelessIf"
51
+ // CHECK-NOT: name:
52
+ // CHECK: op: "StatelessIf"
53
+ // CHECK-NOT: is_stateless
54
+ // CHECK: attr {
55
+ // CHECK: key: "output_shapes"
56
+ // CHECK: value {
57
+ // CHECK: list {
58
+ // CHECK: shape {
59
+ // CHECK: dim {
60
+ // CHECK: size: 4
61
+ // CHECK: }
62
+ // CHECK: }
63
+ // CHECK: }
64
+ // CHECK: }
65
+ // CHECK: }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/functional-while-ops.mlir ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<i32>, %arg1: tensor<5xf32>) -> (tensor<5xf32>, tensor<5xf32>, tensor<5xf32>) {
4
+ %0:3 = tf_executor.graph {
5
+ %outputs_2:2, %control_3 = tf_executor.island wraps "tf.While"(%arg0, %arg1) {body = @body, cond = @cond, is_stateless = false} : (tensor<i32>, tensor<5xf32>) -> (tensor<i32>, tensor<5xf32>) loc("StatefulWhile")
6
+ %outputs_4:2, %control_5 = tf_executor.island wraps "tf.While"(%arg0, %arg1) {body = @body, cond = @cond, is_stateless = true} : (tensor<i32>, tensor<5xf32>) -> (tensor<i32>, tensor<5xf32>) loc("StatelessWhile")
7
+ %outputs_6:2, %control_7 = tf_executor.island wraps "tf.While"(%arg0, %arg1) {body = @body, cond = @cond, is_stateless = false, shape_invariant} : (tensor<i32>, tensor<5xf32>) -> (tensor<i32>, tensor<5xf32>) loc("WhileWithOutputShapes")
8
+ tf_executor.fetch %outputs_2#1, %outputs_4#1, %outputs_6#1 : tensor<5xf32>, tensor<5xf32>, tensor<5xf32>
9
+ }
10
+ func.return %0#0, %0#1, %0#2 : tensor<5xf32>, tensor<5xf32>, tensor<5xf32>
11
+ }
12
+
13
+ func.func @cond(%arg0: tensor<*xi32>, %arg1: tensor<*xf32>) -> tensor<i1> {
14
+ %0 = tf_executor.graph {
15
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {value = dense<0> : tensor<i32>} : () -> tensor<i32>
16
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Greater"(%arg0, %outputs) : (tensor<*xi32>, tensor<i32>) -> tensor<i1>
17
+ tf_executor.fetch %outputs_0 : tensor<i1>
18
+ }
19
+ func.return %0 : tensor<i1>
20
+ }
21
+
22
+ func.func @body(%arg0: tensor<*xi32>, %arg1: tensor<*xf32>) -> (tensor<*xi32>, tensor<*xf32>) {
23
+ %0:2 = tf_executor.graph {
24
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {value = dense<1> : tensor<i32>} : () -> tensor<i32>
25
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Sub"(%arg0, %outputs) : (tensor<*xi32>, tensor<i32>) -> tensor<*xi32>
26
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Add"(%arg1, %arg1) : (tensor<*xf32>, tensor<*xf32>) -> tensor<*xf32>
27
+ tf_executor.fetch %outputs_0, %outputs_2 : tensor<*xi32>, tensor<*xf32>
28
+ }
29
+ func.return %0#0, %0#1 : tensor<*xi32>, tensor<*xf32>
30
+ }
31
+
32
+ // Verify that While op is mapped to TensorFlow StatelessWhile op if the
33
+ // is_stateless attribute is present and otherwise it is mapped to TensorFlow
34
+ // While op. In both cases, the additional attribute should be dropped.
35
+
36
+ // CHECK: name: "StatefulWhile"
37
+ // CHECK-NOT: name:
38
+ // CHECK: op: "While"
39
+ // CHECK-NOT: is_stateless
40
+ // CHECK-NOT: shape_invariant
41
+ // CHECK: attr {
42
+ // CHECK: key: "output_shapes"
43
+ // CHECK: value {
44
+ // CHECK: list {
45
+ // CHECK: shape {
46
+ // CHECK: dim {
47
+ // CHECK: size: 5
48
+ // CHECK: }
49
+ // CHECK: }
50
+ // CHECK: }
51
+ // CHECK: }
52
+ // CHECK: }
53
+
54
+
55
+ // CHECK: name: "StatelessWhile"
56
+ // CHECK-NOT: name:
57
+ // CHECK: op: "StatelessWhile"
58
+ // CHECK-NOT: is_stateless
59
+ // CHECK-NOT: shape_invariant
60
+ // CHECK: attr {
61
+ // CHECK: key: "output_shapes"
62
+ // CHECK: value {
63
+ // CHECK: list {
64
+ // CHECK: shape {
65
+ // CHECK: dim {
66
+ // CHECK: size: 5
67
+ // CHECK: }
68
+ // CHECK: }
69
+ // CHECK: }
70
+ // CHECK: }
71
+ // CHECK: }
72
+
73
+ // CHECK: name: "WhileWithOutputShapes"
74
+ // CHECK-NOT: name:
75
+ // CHECK: op: "While"
76
+ // CHECK-NOT: is_stateless
77
+ // CHECK-NOT: shape_invariant
78
+ // CHECK: attr {
79
+ // CHECK: key: "output_shapes"
80
+ // CHECK: value {
81
+ // CHECK: list {
82
+ // CHECK: shape {
83
+ // CHECK: dim {
84
+ // CHECK: size: 5
85
+ // CHECK: }
86
+ // CHECK: }
87
+ // CHECK: }
88
+ // CHECK: }
89
+ // CHECK: }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/graph-as-function.mlir ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -tf-graph-as-function -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<*x!tf_type.resource>, %arg1: tensor<*x!tf_type.resource<tensor<3x3x1x32xf32>>>, %arg2: tensor<*xf32>, %arg3: tensor<2x4x6x8xi32>) -> (tensor<f32>, tensor<f32>)
4
+ attributes {tf.entry_function = {inputs = "args_0,args_1,args_2,args_3", outputs = "rets_0_RetVal,rets_1_RetVal"}} {
5
+ %graph:2 = tf_executor.graph {
6
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_FLOAT", value = dense<0.000000e+00> : tensor<f32>} : () -> tensor<f32> loc("const")
7
+ %1:2 = tf_executor.island wraps "tf.Identity"(%0#0) {T = "tfdtype$DT_FLOAT", device = ""} : (tensor<f32>) -> tensor<f32> loc("identity")
8
+ %2:2 = tf_executor.island wraps "tf.StatefulPartitionedCall"(%0#0, %arg1) {Tin = ["tfdtype$DT_FLOAT", "tfdtype$DT_RESOURCE"], Tout = ["tfdtype$DT_FLOAT"], _gradient_op_type = "PartitionedCall-1205", config = "", config_proto = "\0A\07\0A\03GPU\10\00\0A\07\0A\03CPU\10\012\02J\008\01", device = "", executor_type = "", f = @function0} : (tensor<f32>, tensor<*x!tf_type.resource<tensor<3x3x1x32xf32>>>) -> tensor<f32> loc("statefulpartitionedcall")
9
+ tf_executor.fetch %1#0, %2#0 : tensor<f32>, tensor<f32>
10
+ }
11
+ func.return %graph#0, %graph#1 : tensor<f32>, tensor<f32>
12
+ }
13
+
14
+ func.func @function0(%arg0: tensor<*xf32>, %arg1: tensor<*x!tf_type.resource>) -> tensor<*xf32>
15
+ attributes {tf.signature.is_stateful} {
16
+ %graph = tf_executor.graph {
17
+ %0:2 = tf_executor.island wraps "tf.Identity"(%arg0) {T = "tfdtype$DT_FLOAT", device = ""} : (tensor<*xf32>) -> tensor<*xf32> loc("Identity@function0")
18
+ tf_executor.fetch %0#0 : tensor<*xf32>
19
+ }
20
+ func.return %graph : tensor<*xf32>
21
+ }
22
+
23
+ // CHECK: node {
24
+ // CHECK-NEXT: name: "args_0"
25
+ // CHECK-NEXT: op: "_Arg"
26
+ // CHECK: i: 0
27
+ // CHECK: node {
28
+ // CHECK-NEXT: name: "args_1"
29
+ // CHECK-NEXT: op: "_Arg"
30
+ // CHECK: i: 1
31
+ // CHECK: node {
32
+ // CHECK-NEXT: name: "args_2"
33
+ // CHECK-NEXT: op: "_Arg"
34
+ // CHECK: i: 2
35
+ // CHECK: node {
36
+ // CHECK-NEXT: name: "args_3"
37
+ // CHECK-NEXT: op: "_Arg"
38
+ // CHECK: i: 3
39
+ // CHECK: node {
40
+ // CHECK-NEXT: name: "const"
41
+ // CHECK-NEXT: op: "Const"
42
+ // CHECK: node {
43
+ // CHECK-NEXT: name: "identity"
44
+ // CHECK-NEXT: op: "Identity"
45
+ // CHECK-NEXT: input: "const"
46
+ // CHECK: node {
47
+ // CHECK-NEXT: name: "statefulpartitionedcall"
48
+ // CHECK-NEXT: op: "StatefulPartitionedCall"
49
+ // CHECK-NEXT: input: "const"
50
+ // CHECK-NEXT: input: "args_1"
51
+ // CHECK: key: "f"
52
+ // CHECK-NEXT: value {
53
+ // CHECK-NEXT: func {
54
+ // CHECK-NEXT: name: "function0"
55
+ // CHECK: node {
56
+ // CHECK-NEXT: name: "rets_0_RetVal"
57
+ // CHECK-NEXT: op: "_Retval"
58
+ // CHECK-NEXT: input: "identity"
59
+ // CHECK: node {
60
+ // CHECK-NEXT: name: "rets_1_RetVal"
61
+ // CHECK-NEXT: op: "_Retval"
62
+ // CHECK-NEXT: input: "statefulpartitionedcall"
63
+ // CHECK: library {
64
+ // CHECK-NEXT: function {
65
+ // CHECK-NEXT: signature {
66
+ // CHECK-NEXT: name: "function0"
67
+ // CHECK-NEXT: input_arg {
68
+ // CHECK-NEXT: name: "function0"
69
+ // CHECK: input_arg {
70
+ // CHECK-NEXT: name: "function01"
71
+ // CHECK: output_arg {
72
+ // CHECK-NEXT: name: "function02"
73
+ // CHECK: node_def {
74
+ // CHECK-NEXT: name: "[[NAME:[^"]*]]"
75
+ // CHECK-NEXT: op: "Identity"
76
+ // CHECK-NEXT: input: "function0"
77
+ // CHECK: ret {
78
+ // CHECK-NEXT: key: "function02"
79
+ // CHECK-NEXT: value: "[[NAME]]:output:0"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/infer_derived_attribute.mlir ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ // The operation does not have any attributes, but TensorFlow OpDef expects
5
+ // a `dtype` to be added on the NodeDef. We verify that we correctly use the
6
+ // DerivedAttr to populate the NodeDef.
7
+ // CHECK: key: "dtype"
8
+ // CHECK-NEXT: value {
9
+ // CHECK-NEXT: type: DT_FLOAT
10
+ // CHECK: float_val: 2
11
+ // CHECK: key: "dtype"
12
+ // CHECK-NEXT: value {
13
+ // CHECK-NEXT: type: DT_FLOAT
14
+ // CHECK: float_val: 3
15
+ // CHECK: key: "dtype"
16
+ // CHECK-NEXT: value {
17
+ // CHECK-NEXT: type: DT_DOUBLE
18
+ // CHECK: double_val: 4
19
+ tf_executor.graph {
20
+ %0:2 = tf_executor.island wraps "tf.Const"() {value = dense<2.000000e+00> : tensor<f32>} : () -> tensor<f32>
21
+ %1:2 = tf_executor.island(%0#1) wraps "tf.Const"() {value = dense<3.000000e+00> : tensor<f32>} : () -> tensor<f32>
22
+ %2:2 = tf_executor.island(%1#1) wraps "tf.Const"() {value = dense<4.000000e+00> : tensor<f64>} : () -> tensor<f64>
23
+ tf_executor.fetch
24
+ }
25
+ func.return
26
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/invalid_input.mlir ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: not tf-mlir-translate -split-input-file -mlir-to-graphdef %s -o - 2>&1 | FileCheck %s
2
+
3
+ // Tests function with multiple blocks.
4
+
5
+ func.func @main() {
6
+ ^bb:
7
+ cf.br ^bb1
8
+ ^bb1:
9
+ func.return
10
+ }
11
+
12
+ // CHECK: functions must be of a single Graph with single op Islands: only single block functions are supported
13
+
14
+ // -----
15
+
16
+ // Tests invalid functions for exporting to Graph/GraphDef.
17
+
18
+ func.func @main() {
19
+ func.return
20
+ }
21
+
22
+ // CHECK: functions must be of a single Graph with single op Islands: first op in function is not a tf_executor.graph
23
+
24
+ // -----
25
+
26
+ func.func @main() {
27
+ tf_executor.graph {
28
+ tf_executor.fetch
29
+ }
30
+ tf_executor.graph {
31
+ tf_executor.fetch
32
+ }
33
+ func.return
34
+ }
35
+
36
+ // CHECK: functions must be of a single Graph with single op Islands: function does not only contain a single tf_executor.graph
37
+
38
+ // -----
39
+
40
+ func.func @main() {
41
+ tf_executor.graph {
42
+ %0 = tf_executor.island {
43
+ tf_executor.yield
44
+ }
45
+ tf_executor.fetch
46
+ }
47
+ func.return
48
+ }
49
+
50
+ // CHECK: functions must be of a single Graph with single op Islands: tf_executor.island must perfectly wrap a single op
51
+
52
+ // -----
53
+
54
+ func.func @main() {
55
+ tf_executor.graph {
56
+ %0 = tf_executor.island {
57
+ %1 = "tf.Const"() {value = dense<1> : tensor<i32>} : () -> tensor<i32>
58
+ %2 = "tf.Const"() {value = dense<2> : tensor<i32>} : () -> tensor<i32>
59
+ tf_executor.yield
60
+ }
61
+ tf_executor.fetch
62
+ }
63
+ func.return
64
+ }
65
+
66
+ // CHECK: functions must be of a single Graph with single op Islands: tf_executor.island must perfectly wrap a single op
67
+
68
+ // -----
69
+
70
+ func.func @main() {
71
+ tf_executor.graph {
72
+ %0 = tf_executor.island {
73
+ %1 = "tf.Const"() {value = dense<1> : tensor<i32>} : () -> tensor<i32>
74
+ tf_executor.yield
75
+ }
76
+ tf_executor.fetch
77
+ }
78
+ func.return
79
+ }
80
+
81
+ // CHECK: functions must be of a single Graph with single op Islands: tf_executor.island must perfectly wrap a single op
82
+
83
+ // -----
84
+
85
+ func.func @main(%arg0: tensor<i32>, %arg1: tensor<i32>) {
86
+ tf_executor.graph {
87
+ %0:3 = tf_executor.island {
88
+ %1:2 = "tf.IdentityN"(%arg0, %arg1) : (tensor<i32>, tensor<i32>) -> (tensor<i32>, tensor<i32>)
89
+ tf_executor.yield %1#1, %1#0 : tensor<i32>, tensor<i32>
90
+ }
91
+ tf_executor.fetch
92
+ }
93
+ func.return
94
+ }
95
+
96
+ // CHECK: functions must be of a single Graph with single op Islands: tf_executor.island must perfectly wrap a single op
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/legalized_name.mlir ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ // CHECK: name: ".foo"
6
+ %0:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<i32>} : () -> (tensor<i32>) loc("^foo")
7
+ // CHECK: name: "fo.o"
8
+ %1:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<1> : tensor<i32>} : () -> (tensor<i32>) loc("fo{o")
9
+ // CHECK: name: "foo"
10
+ %2:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<2> : tensor<i32>} : () -> (tensor<i32>) loc("foo@1")
11
+ // CHECK: name: "ba.r"
12
+ %3:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<2> : tensor<i32>} : () -> (tensor<i32>) loc("ba r")
13
+ // CHECK: name: "2"
14
+ %4:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<3> : tensor<i32>} : () -> (tensor<i32>) loc("2")
15
+ // CHECK: name: "_3"
16
+ %5:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<3> : tensor<i32>} : () -> (tensor<i32>) loc("_3")
17
+ // CHECK: name: "foo_"
18
+ %6:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<3> : tensor<i32>} : () -> (tensor<i32>) loc("foo_")
19
+ tf_executor.fetch
20
+ }
21
+ func.return
22
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/missing-main.mlir ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: not tf-mlir-translate -mlir-to-graphdef %s -o - 2>&1 | FileCheck %s
2
+
3
+ // CHECK: entry function `main` must be present
4
+
5
+ func.func @const() {
6
+ tf_executor.graph {
7
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "TPU:0", name = "const", dtype = "tfdtype$DT_INT32", value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32>
8
+ tf_executor.fetch
9
+ }
10
+ func.return
11
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/noop.mlir ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ tf_executor.island wraps "tf.NoOp"() {} : () -> () loc("noop")
6
+ tf_executor.fetch
7
+ }
8
+ func.return
9
+ }
10
+
11
+ // CHECK: node {
12
+ // CHECK-NEXT: name: "noop"
13
+ // CHECK-NEXT: op: "NoOp"
14
+ // CHECK-NEXT: experimental_debug_info {
15
+ // CHECK-NEXT: }
16
+ // CHECK-NEXT: }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/optional_symbol_ref.mlir ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s | tf-mlir-translate -graphdef-to-mlir | tf-mlir-translate -mlir-to-graphdef | FileCheck %s
2
+
3
+ // Verifies that optional symbol ref attributes that aren't optional in TensorFlow are handled by setting the value to an empty string.
4
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 458 : i32}} {
5
+ func.func @main() {
6
+ tf_executor.graph {
7
+ %control = tf_executor.island wraps "tf.XlaHostCompute"() {_xla_original_oc_node_name = "Add", _xla_token_input_nodes = ["_xla_token_arg_node"], ancestors = [], cost_estimate_ns = 1024 : i64, key = "host_compute_channel_1_retvals", send_key = "", recv_key = "", shapes = [], tpu_core = 0 : i64} : () -> ()
8
+ tf_executor.fetch
9
+ }
10
+ func.return
11
+ }
12
+ }
13
+
14
+ // CHECK: op: "XlaHostCompute"
15
+
16
+ // CHECK: attr {
17
+ // CHECK: key: "shape_inference_graph"
18
+ // CHECK: value {
19
+ // CHECK: func {
20
+ // CHECK-NEXT }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/output-shapes-attr.mlir ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<10xi32>) -> tensor<10xi32>
4
+ attributes {tf.entry_function = {inputs = "input0", outputs = "output0"}} {
5
+ %graph = tf_executor.graph {
6
+ tf_executor.fetch %arg0 : tensor<10xi32>
7
+ }
8
+ func.return %graph : tensor<10xi32>
9
+ }
10
+
11
+ // CHECK: node {
12
+ // CHECK-NEXT: name: "input0"
13
+ // CHECK-NEXT: op: "_Arg"
14
+ // CHECK: key: "T"
15
+ // CHECK-NEXT: value {
16
+ // CHECK-NEXT: type: DT_INT32
17
+ // CHECK-NEXT: }
18
+ // CHECK: key: "_output_shapes"
19
+ // CHECK-NEXT: value {
20
+ // CHECK-NEXT: list {
21
+ // CHECK-NEXT: shape {
22
+ // CHECK-NEXT: dim {
23
+ // CHECK-NEXT: size: 10
24
+ // CHECK: name: "output0"
25
+ // CHECK-NEXT: op: "_Retval"
26
+ // CHECK-NEXT: input: "input0"
27
+ // CHECK-NEXT: attr {
28
+ // CHECK-NEXT: key: "T"
29
+ // CHECK-NEXT: value {
30
+ // CHECK-NEXT: type: DT_INT32
31
+ // CHECK-NEXT: }
32
+ // CHECK-NEXT: }
33
+ // CHECK-NEXT: attr {
34
+ // CHECK-NEXT: key: "index"
35
+ // CHECK-NEXT: value {
36
+ // CHECK-NEXT: i: 0
37
+ // CHECK-NEXT: }
38
+ // CHECK-NEXT: }
39
+
40
+ func.func private @simple_callee(%arg0: tensor<2xi32>) -> tensor<2xi32> {
41
+ %graph = tf_executor.graph {
42
+ tf_executor.fetch %arg0 : tensor<2xi32>
43
+ }
44
+ func.return %graph#0 : tensor<2xi32>
45
+ }
46
+
47
+ // Test with a TPUPartitionedCallOp that is not inlined.
48
+ func.func @dont_inline_tpu_partitioned_call(%arg0: tensor<2xi32> {tf._user_specified_name = "inputs_0"}, %arg1: tensor<2xi32> {tf._user_specified_name = "inputs_1"}) -> tensor<2xi32> {
49
+ %graph = tf_executor.graph {
50
+ %result:2 = tf_executor.island wraps "tf.TPUPartitionedCall"(%arg0, %arg1) {config = "", config_proto = "", executor_type = "", f = @simple_callee} : (tensor<2xi32>, tensor<2xi32>) -> tensor<2xi32>
51
+ tf_executor.fetch %result#0 : tensor<2xi32>
52
+ }
53
+ func.return %graph : tensor<2xi32>
54
+ }
55
+
56
+ // CHECK: library {
57
+ // CHECK-NEXT: function {
58
+ // CHECK-NEXT: signature {
59
+ // CHECK-NEXT: name: "simple_callee"
60
+ // CHECK: function {
61
+ // CHECK-NEXT: signature {
62
+ // CHECK-NEXT: name: "dont_inline_tpu_partitioned_call"
63
+ // CHECK-NEXT: input_arg {
64
+ // CHECK-NEXT: name: "dont_inline_tpu_partitioned_call"
65
+ // CHECK-NEXT: type: DT_INT32
66
+ // CHECK-NEXT: }
67
+ // CHECK-NEXT: input_arg {
68
+ // CHECK-NEXT: name: "dont_inline_tpu_partitioned_call1"
69
+ // CHECK-NEXT: type: DT_INT32
70
+ // CHECK-NEXT: }
71
+ // CHECK: arg_attr {
72
+ // CHECK-NEXT: key: 0
73
+ // CHECK-NEXT: value {
74
+ // CHECK-NEXT: attr {
75
+ // CHECK-NEXT: key: "_output_shapes"
76
+ // CHECK-NEXT: value {
77
+ // CHECK-NEXT: list {
78
+ // CHECK-NEXT: shape {
79
+ // CHECK-NEXT: dim {
80
+ // CHECK-NEXT: size: 2
81
+ // CHECK: attr {
82
+ // CHECK-NEXT: key: "_user_specified_name"
83
+ // CHECK-NEXT: value {
84
+ // CHECK-NEXT: s: "inputs_0"
85
+ // CHECK: arg_attr {
86
+ // CHECK-NEXT: key: 1
87
+ // CHECK-NEXT: value {
88
+ // CHECK-NEXT: attr {
89
+ // CHECK-NEXT: key: "_output_shapes"
90
+ // CHECK-NEXT: value {
91
+ // CHECK-NEXT: list {
92
+ // CHECK-NEXT: shape {
93
+ // CHECK-NEXT: dim {
94
+ // CHECK-NEXT: size: 2
95
+ // CHECK: attr {
96
+ // CHECK-NEXT: key: "_user_specified_name"
97
+ // CHECK-NEXT: value {
98
+ // CHECK-NEXT: s: "inputs_1"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/parse_example.mlir ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ // CHECK: name: "tf.ParseExample"
4
+ // CHECK-NEXT: op: "ParseExample"
5
+ // CHECK-NEXT: input: "tf.Const{{_.*_3}}"
6
+ // CHECK-NEXT: input: "tf.Const"
7
+ // CHECK-NEXT: input: "tf.Const{{_.*_1}}"
8
+ // CHECK-NEXT: input: "tf.Const{{_.*_2}}"
9
+ // CHECK-NEXT: attr {
10
+ // CHECK-NEXT: key: "Ndense"
11
+ // CHECK-NEXT: value {
12
+ // CHECK-NEXT: i: 1
13
+ // CHECK-NEXT: }
14
+ // CHECK-NEXT: }
15
+ // CHECK-NEXT: attr {
16
+ // CHECK-NEXT: key: "Nsparse"
17
+ // CHECK-NEXT: value {
18
+ // CHECK-NEXT: i: 0
19
+ // CHECK-NEXT: }
20
+ // CHECK-NEXT: }
21
+ // CHECK-NEXT: attr {
22
+ // CHECK-NEXT: key: "Tdense"
23
+ // CHECK-NEXT: value {
24
+ // CHECK-NEXT: list {
25
+ // CHECK-NEXT: type: DT_INT64
26
+ // CHECK-NEXT: }
27
+ // CHECK-NEXT: }
28
+ // CHECK-NEXT: }
29
+ // CHECK-NEXT: attr {
30
+ // CHECK: key: "dense_shapes"
31
+ // CHECK-NEXT: value {
32
+ // CHECK-NEXT: list {
33
+ // CHECK-NEXT: shape {
34
+ // CHECK-NEXT: dim {
35
+ // CHECK-NEXT: size: 1
36
+ // CHECK-NEXT: }
37
+ // CHECK-NEXT: }
38
+ // CHECK-NEXT: }
39
+ // CHECK-NEXT: }
40
+ // CHECK-NEXT: }
41
+ // CHECK-NEXT: attr {
42
+ // CHECK-NEXT: key: "sparse_types"
43
+ // CHECK-NEXT: value {
44
+ // CHECK-NEXT: list {
45
+ // CHECK-NEXT: }
46
+ // CHECK-NEXT: }
47
+ // CHECK-NEXT: }
48
+
49
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 0 : i32, producer = 413 : i32}} {
50
+ func.func @main() -> tensor<*xi64> attributes {tf.entry_function = {control_outputs = "", inputs = "", outputs = "result"}} {
51
+ %0 = tf_executor.graph {
52
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", value = dense<"value"> : tensor<1x!tf_type.string>} : () -> tensor<1x!tf_type.string>
53
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<"value"> : tensor<!tf_type.string>} : () -> tensor<!tf_type.string>
54
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<-1> : tensor<i64>} : () -> tensor<i64>
55
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<""> : tensor<1x!tf_type.string>} : () -> tensor<1x!tf_type.string>
56
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.ParseExample"(%outputs_4, %outputs, %outputs_0, %outputs_2) {dense_shapes = [#tf_type.shape<1>], device = "", operandSegmentSizes = array<i32: 1, 1, 0, 1, 1>, resultSegmentSizes = array<i32: 0, 0, 0, 1>} : (tensor<1x!tf_type.string>, tensor<1x!tf_type.string>, tensor<!tf_type.string>, tensor<i64>) -> tensor<*xi64>
57
+ tf_executor.fetch %outputs_6 : tensor<*xi64>
58
+ }
59
+ func.return %0 : tensor<*xi64>
60
+ }
61
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/parse_example_v2.mlir ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 0 : i32, producer = 175 : i32}} {
4
+ func.func @main(%arg0: tensor<32x!tf_type.string>) -> (tensor<?x2xi64>) attributes {tf.entry_function = {inputs = "input0", outputs = "ParseExample/ParseExampleV2"}} {
5
+
6
+ %0 = tf_executor.graph {
7
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", dtype = f32, value = dense<[]> : tensor<0xf32>} : () -> tensor<0xf32>
8
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Const"() {device = "", dtype = f32, value = dense<[]> : tensor<0xf32>} : () -> tensor<0xf32>
9
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Const"() {device = "", dtype = !tf_type.string, value = dense<""> : tensor<2x!tf_type.string>} : () -> tensor<2x!tf_type.string>
10
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.Const"() {device = "", dtype = !tf_type.string, value = dense<""> : tensor<0x!tf_type.string>} : () -> tensor<0x!tf_type.string>
11
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.Const"() {device = "", dtype = !tf_type.string, value = dense<""> : tensor<0x!tf_type.string>} : () -> tensor<0x!tf_type.string>
12
+ %outputs_8, %control_9 = tf_executor.island wraps "tf.Const"() {device = "", dtype = !tf_type.string, value = dense<""> : tensor<2x!tf_type.string>} : () -> tensor<2x!tf_type.string>
13
+
14
+ %outputs_10:8, %control_11 = tf_executor.island wraps "tf.ParseExampleV2"(%arg0, %outputs_4, %outputs_8, %outputs_2, %outputs_6, %outputs, %outputs_0) {Tdense = ["tfdtype$DT_FLOAT", "tfdtype$DT_FLOAT"], dense_shapes = [#tf_type.shape<>, #tf_type.shape<>], device = "", num_sparse = 2 : i64, ragged_split_types = [], ragged_value_types = [], resultSegmentSizes = array<i32: 2, 2, 2, 2, 0, 0>, sparse_types = ["tfdtype$DT_STRING", "tfdtype$DT_INT64"]} : (tensor<32x!tf_type.string>, tensor<0x!tf_type.string>, tensor<2x!tf_type.string>, tensor<2x!tf_type.string>, tensor<0x!tf_type.string>, tensor<0xf32>, tensor<0xf32>) -> (tensor<?x2xi64>, tensor<?x2xi64>, tensor<?x!tf_type.string>, tensor<?xi64>, tensor<2xi64>, tensor<2xi64>, tensor<32xf32>, tensor<32xf32>) loc("ParseExample")
15
+ // CHECK: name: "ParseExample"
16
+ // CHECK-NEXT: op: "ParseExampleV2"
17
+ // CHECK-NEXT: input: "input0"
18
+ // CHECK-NEXT: input: "tf.Const{{_.*_3}}"
19
+ // CHECK-NEXT: input: "tf.Const{{_.*_5}}"
20
+ // CHECK-NEXT: input: "tf.Const{{_.*_2}}"
21
+ // CHECK-NEXT: input: "tf.Const{{_.*_4}}"
22
+ // CHECK-NEXT: input: "tf.Const"
23
+ // CHECK-NEXT: input: "tf.Const{{_.*_1}}"
24
+ // CHECK-NEXT: attr {
25
+ // CHECK-NEXT: key: "Tdense"
26
+ // CHECK-NEXT: value {
27
+ // CHECK-NEXT: list {
28
+ // CHECK-NEXT: type: DT_FLOAT
29
+ // CHECK-NEXT: type: DT_FLOAT
30
+ // CHECK-NEXT: }
31
+ // CHECK-NEXT: }
32
+ // CHECK-NEXT: }
33
+ // CHECK-NEXT: attr {
34
+ // CHECK: key: "dense_shapes"
35
+ // CHECK-NEXT: value {
36
+ // CHECK-NEXT: list {
37
+ // CHECK-NEXT: shape {
38
+ // CHECK-NEXT: }
39
+ // CHECK-NEXT: shape {
40
+ // CHECK-NEXT: }
41
+ // CHECK-NEXT: }
42
+ // CHECK-NEXT: }
43
+ // CHECK-NEXT: }
44
+ // CHECK-NEXT: attr {
45
+ // CHECK-NEXT: key: "num_sparse"
46
+ // CHECK-NEXT: value {
47
+ // CHECK-NEXT: i: 2
48
+ // CHECK-NEXT: }
49
+ // CHECK-NEXT: }
50
+ // CHECK-NEXT: attr {
51
+ // CHECK-NEXT: key: "ragged_split_types"
52
+ // CHECK-NEXT: value {
53
+ // CHECK-NEXT: list {
54
+ // CHECK-NEXT: }
55
+ // CHECK-NEXT: }
56
+ // CHECK-NEXT: }
57
+ // CHECK-NEXT: attr {
58
+ // CHECK-NEXT: key: "ragged_value_types"
59
+ // CHECK-NEXT: value {
60
+ // CHECK-NEXT: list {
61
+ // CHECK-NEXT: }
62
+ // CHECK-NEXT: }
63
+ // CHECK-NEXT: }
64
+ // CHECK-NEXT: attr {
65
+ // CHECK-NEXT: key: "sparse_types"
66
+ // CHECK-NEXT: value {
67
+ // CHECK-NEXT: list {
68
+ // CHECK-NEXT: type: DT_STRING
69
+ // CHECK-NEXT: type: DT_INT64
70
+ // CHECK-NEXT: }
71
+ // CHECK-NEXT: }
72
+ // CHECK-NEXT: }
73
+
74
+ tf_executor.fetch %outputs_10#0 : tensor<?x2xi64>
75
+ }
76
+ func.return %0#0 : tensor<?x2xi64>
77
+ // CHECK: name: "ParseExample/ParseExampleV2"
78
+ // CHECK-NEXT: op: "_Retval"
79
+ // CHECK-NEXT: input: "ParseExample"
80
+
81
+ }
82
+ }
83
+
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/preserve-entry-func-names.mlir ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<10xi32>, %arg1: tensor<10xi32>) -> tensor<10xi32>
4
+ attributes {tf.entry_function = {inputs = "foo,bar", outputs = "Add"}} {
5
+ %graph = tf_executor.graph {
6
+ // This node would be renamed to bar1 [note: if imported from TF graphdef this would not be possible]
7
+ %2:2 = tf_executor.island wraps "tf.Identity"(%arg1) {device = "", dtype = "tfdtype$DT_INT32"} : (tensor<10xi32>) -> tensor<10xi32> loc ("bar")
8
+ // The following node would be renamed to bar2
9
+ %3:2 = tf_executor.island wraps "tf.Identity"(%2) {device = "", dtype = "tfdtype$DT_INT32"} : (tensor<10xi32>) -> tensor<10xi32> loc ("bar")
10
+ %4:2 = tf_executor.island wraps "tf.Add"(%arg0, %3) {T = "tfdtype$DT_INT32", device = ""} : (tensor<10xi32>, tensor<10xi32>) -> tensor<10xi32> loc("Add")
11
+ tf_executor.fetch %4#0 : tensor<10xi32>
12
+ }
13
+ func.return %graph : tensor<10xi32>
14
+ }
15
+
16
+ // CHECK: name: "foo"
17
+ // CHECK-NEXT: op: "_Arg"
18
+ // CHECK: name: "bar"
19
+ // CHECK-NEXT: op: "_Arg"
20
+ // CHECK: name: "[[BAR_ID_0:.*]]"
21
+ // CHECK-NEXT: op: "Identity"
22
+ // CHECK-NEXT: input: "bar"
23
+ // CHECK: name: "[[BAR_ID_1:.*]]"
24
+ // CHECK-NEXT: op: "Identity"
25
+ // CHECK-NEXT: input: "[[BAR_ID_0]]"
26
+ // CHECK: name: "Add"
27
+ // CHECK-NEXT: op: "_Retval"
28
+ // CHECK-NEXT: input: "Add{{_.*_1}}"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/ref-type-attr.mlir ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ // Verify that attribute T is not set as ref type.
4
+ // CHECK-LABEL: name: "Ref_Variable"
5
+ // CHECK-LABEL: name: "foo"
6
+ // CHECK: attr {
7
+ // CHECK-NEXT: key: "T"
8
+ // CHECK-NEXT: value {
9
+ // CHECK-NEXT: type: DT_INT32{{$}}
10
+ // CHECK-NEXT: }
11
+ // CHECK-NEXT: }
12
+
13
+ func.func @main() {
14
+ tf_executor.graph {
15
+ %0:2 = tf_executor.island wraps "tf.VariableV2"() {dtype = "tfdtype$DT_INT32", value = dense<2> : tensor<i32>, shape = #tf_type.shape<2>, container = "", shared_name = ""} : () -> tensor<!tf_type.int32ref> loc("Ref_Variable")
16
+ %1:2 = tf_executor.island wraps "tf.Identity"(%0#0) : (tensor<!tf_type.int32ref>) -> tensor<*x!tf_type.int32ref> loc("foo")
17
+ tf_executor.fetch
18
+ }
19
+ func.return
20
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/ref-while-loop.mlir ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ // Verify the ops generated when Ref type is used in a while loop.
4
+ func.func @main() {
5
+ // CHECK: op: "RefEnter"
6
+ // CHECK: op: "RefMerge"
7
+ // CHECK: op: "RefSwitch"
8
+ // CHECK: op: "RefExit"
9
+ // CHECK: op: "RefNextIteration"
10
+ tf_executor.graph {
11
+ %0:3 = tf_executor.NextIteration.Source : tensor<*x!tf_type.int32ref> {device = "", T = "tfdtype$DT_INT32"} loc("while/NextIteration")
12
+ %1:2 = tf_executor.island wraps "tf.VariableV2"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<i32>, shape = #tf_type.shape<0>, container = "", shared_name = ""} : () -> tensor<!tf_type.int32ref> loc("Ref_Variable")
13
+ %2:2 = tf_executor.Enter %1#0 frame "while/while_context" parallel_iterations 10 : (tensor<!tf_type.int32ref>) -> (tensor<*x!tf_type.int32ref>, !tf_executor.control) {device = "", T = "tfdtype$DT_INT32"} loc("while/Enter")
14
+ %3:3 = tf_executor.Merge %2#0, %0#0 : tensor<*x!tf_type.int32ref> {device = "", N = 2, T = "tfdtype$DT_INT32"} loc("while/Merge")
15
+ %4:2 = tf_executor.island(%3#2) wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<10> : tensor<i32>} : () -> tensor<i32> loc("while/Less/y")
16
+ %5:2 = tf_executor.island(%3#2) wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_BOOL", value = dense<true> : tensor<i1>} : () -> tensor<i1> loc("while/Less")
17
+ %6:2 = tf_executor.LoopCond %5#0 : (tensor<i1>) -> (tensor<i1>, !tf_executor.control) {device = ""} loc("while/LoopCond")
18
+ %7:3 = tf_executor.Switch %3#0, %6#0 : (tensor<*x!tf_type.int32ref>, tensor<i1>) -> (tensor<*x!tf_type.int32ref>, tensor<*x!tf_type.int32ref>, !tf_executor.control) {device = "", T = "tfdtype$DT_INT32", _class = ["loc:@while/Merge"]} loc("while/Switch")
19
+ %8:2 = tf_executor.Exit %7#1 : tensor<*x!tf_type.int32ref> {device = "", T = "tfdtype$DT_INT32"} loc("while/Exit")
20
+ %10:2 = tf_executor.island(%7#2) wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<1> : tensor<i32>} : () -> tensor<i32> loc("while/Add/y")
21
+ %11:2 = tf_executor.island wraps "tf.AssignAdd"(%7#0, %10#0) {device = "", T = "tfdtype$DT_INT32"} : (tensor<*x!tf_type.int32ref>, tensor<i32>) -> tensor<*x!tf_type.int32ref> loc("while/Add")
22
+ tf_executor.NextIteration.Sink [%0#1] %11#0 : tensor<*x!tf_type.int32ref> {device = "", T = "tfdtype$DT_INT32"} loc("while/NextIteration")
23
+ tf_executor.fetch
24
+ }
25
+ func.return
26
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/shape_list_attr.mlir ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+
4
+ // CHECK: attr {
5
+ // CHECK: key: "dtypes"
6
+ // CHECK-NEXT: value {
7
+ // CHECK-NEXT: list {
8
+ // CHECK-NEXT: type: DT_INT32
9
+ // CHECK-NEXT: type: DT_FLOAT
10
+ // CHECK-NEXT: type: DT_INT16
11
+
12
+ // CHECK: attr {
13
+ // CHECK-NEXT: key: "shapes"
14
+ // CHECK-NEXT: value {
15
+ // CHECK-NEXT: list {
16
+ // CHECK-NEXT: shape {
17
+ // CHECK-NEXT: dim {
18
+ // CHECK-NEXT: size: 3
19
+ // CHECK: shape {
20
+ // CHECK-NEXT: dim {
21
+ // CHECK-NEXT: size: 4
22
+ // CHECK-NEXT: }
23
+ // CHECK-NEXT: dim {
24
+ // CHECK-NEXT: size: -1
25
+ // CHECK: shape {
26
+ // CHECK-NEXT: unknown_rank: true
27
+
28
+
29
+ func.func @main() {
30
+ tf_executor.graph {
31
+ %0:4 = tf_executor.island wraps "tf.InfeedDequeueTuple"() : () -> (tensor<3xi32>, tensor<4x?xf32>, tensor<*xi16>)
32
+ tf_executor.fetch
33
+ }
34
+ func.return
35
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/simple.mlir ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ // CHECK: node {
5
+ // CHECK-NEXT: name: "Empty/shape"
6
+ // CHECK-NEXT: op: "Const"
7
+ // CHECK: attr {
8
+ // CHECK: key: "dtype"
9
+ // CHECK-NEXT: value {
10
+ // CHECK-NEXT: type: DT_INT32
11
+ // CHECK-NEXT: }
12
+ // CHECK-NEXT: }
13
+ // CHECK-NEXT: attr {
14
+ // CHECK-NEXT: key: "value"
15
+ // CHECK-NEXT: value {
16
+ // CHECK-NEXT: tensor {
17
+ // CHECK-NEXT: dtype: DT_INT32
18
+ // CHECK-NEXT: tensor_shape {
19
+ // CHECK-NEXT: dim {
20
+ // CHECK-NEXT: size: 2
21
+ // CHECK-NEXT: }
22
+ // CHECK-NEXT: }
23
+ // CHECK-NEXT: tensor_content: "\200\000\000\000\200\000\000\000"
24
+ tf_executor.graph {
25
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "/job:localhost/replica:0/task:0/device:TPU:0", dtype = "tfdtype$DT_INT32", value = #tf_type<tensor_proto : "0x746674656E736F722464747970653A2044545F494E5433320A74656E736F725F7368617065207B0A202064696D207B0A2020202073697A653A20320A20207D0A7D0A74656E736F725F636F6E74656E743A20225C3230305C3030305C3030305C3030305C3230305C3030305C3030305C303030220A"> : tensor<2xi32>} : () -> tensor<2xi32> loc("Empty/shape")
26
+ tf_executor.fetch
27
+ }
28
+ func.return
29
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/stringescape.mlir ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ ^bb0:
5
+ // CHECK: key: "listvalue"
6
+ // CHECK-NEXT: value {
7
+ // CHECK-NEXT: list {
8
+ // CHECK-NEXT: s: " \n"
9
+ // CHECK-NEXT: }
10
+ // CHECK: key: "value"
11
+ // CHECK-NEXT: value {
12
+ // CHECK-NEXT: s: " 0\n\000\000"
13
+ tf_executor.graph {
14
+ %0:2 = tf_executor.island wraps "tf.Placeholder"() {name = "dummy", dtype = "tfdtype$DT_INT32", value = "\200\n\00\00", listvalue = ["\20\0A"]} : () -> tensor<2xi32>
15
+ tf_executor.fetch
16
+ }
17
+ func.return
18
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/switchn.mlir ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ "builtin.module"() ({
4
+ "func.func"() ({
5
+ "tf_executor.graph"() ({
6
+ %outputs, %control = "tf_executor.island"() ({
7
+ %0 = "tf.Const"() {device = "", value = dense<0> : tensor<i32>} : () -> tensor<i32>
8
+ "tf_executor.yield"(%0) : (tensor<i32>) -> ()
9
+ }) : () -> (tensor<i32>, !tf_executor.control)
10
+ %outputs_0:3, %control_1 = "tf_executor._SwitchN"(%outputs, %outputs) {T = i32, device = "", num_outs = 3 : i64} : (tensor<i32>, tensor<i32>) -> (tensor<*xi32>, tensor<*xi32>, tensor<*xi32>, !tf_executor.control)
11
+ %outputs_2, %control_3 = "tf_executor.island"() ({
12
+ %0 = "tf.Identity"(%outputs_0#0) {device = ""} : (tensor<*xi32>) -> tensor<*xi32>
13
+ "tf_executor.yield"(%0) : (tensor<*xi32>) -> ()
14
+ }) : () -> (tensor<*xi32>, !tf_executor.control)
15
+ %outputs_4, %control_5 = "tf_executor.island"(%control_3) ({
16
+ %0 = "tf.Const"() {device = "", value = dense<2.000000e+00> : tensor<f32>} : () -> tensor<f32>
17
+ "tf_executor.yield"(%0) : (tensor<f32>) -> ()
18
+ }) : (!tf_executor.control) -> (tensor<f32>, !tf_executor.control)
19
+ %outputs_6, %control_7 = "tf_executor.island"() ({
20
+ %0 = "tf.Identity"(%outputs_0#1) {device = ""} : (tensor<*xi32>) -> tensor<*xi32>
21
+ "tf_executor.yield"(%0) : (tensor<*xi32>) -> ()
22
+ }) : () -> (tensor<*xi32>, !tf_executor.control)
23
+ %outputs_8, %control_9 = "tf_executor.island"(%control_7) ({
24
+ %0 = "tf.Const"() {device = "", value = dense<3.000000e+00> : tensor<f32>} : () -> tensor<f32>
25
+ "tf_executor.yield"(%0) : (tensor<f32>) -> ()
26
+ }) : (!tf_executor.control) -> (tensor<f32>, !tf_executor.control)
27
+ %outputs_10, %control_11 = "tf_executor.island"() ({
28
+ %0 = "tf.Identity"(%outputs_0#2) {device = ""} : (tensor<*xi32>) -> tensor<*xi32>
29
+ "tf_executor.yield"(%0) : (tensor<*xi32>) -> ()
30
+ }) : () -> (tensor<*xi32>, !tf_executor.control)
31
+ %outputs_12, %control_13 = "tf_executor.island"(%control_11) ({
32
+ %0 = "tf.Const"() {device = "", value = dense<4.000000e+00> : tensor<f32>} : () -> tensor<f32>
33
+ "tf_executor.yield"(%0) : (tensor<f32>) -> ()
34
+ }) : (!tf_executor.control) -> (tensor<f32>, !tf_executor.control)
35
+ %outputs_14, %control_15 = "tf_executor.island"() ({
36
+ %0 = "tf.Const"() {device = "", value = dense<1.000000e+00> : tensor<f32>} : () -> tensor<f32>
37
+ "tf_executor.yield"(%0) : (tensor<f32>) -> ()
38
+ }) : () -> (tensor<f32>, !tf_executor.control)
39
+ %outputs_16:2, %control_17 = "tf_executor._SwitchN"(%outputs_14, %outputs) {T = f32, _class = ["Case/input_0"], device = "", num_outs = 2 : i64} : (tensor<f32>, tensor<i32>) -> (tensor<*xf32>, tensor<*xf32>, !tf_executor.control)
40
+ %outputs_18, %control_19 = "tf_executor.island"() ({
41
+ %0 = "tf.Mul"(%outputs_16#0, %outputs_4) {device = ""} : (tensor<*xf32>, tensor<f32>) -> tensor<*xf32>
42
+ "tf_executor.yield"(%0) : (tensor<*xf32>) -> ()
43
+ }) : () -> (tensor<*xf32>, !tf_executor.control)
44
+ %outputs_20, %control_21 = "tf_executor.island"() ({
45
+ %0 = "tf.Mul"(%outputs_16#1, %outputs_8) {device = ""} : (tensor<*xf32>, tensor<f32>) -> tensor<*xf32>
46
+ "tf_executor.yield"(%0) : (tensor<*xf32>) -> ()
47
+ }) : () -> (tensor<*xf32>, !tf_executor.control)
48
+ %output, %value_index, %control_22 = "tf_executor.Merge"(%outputs_18, %outputs_20) {N = 2 : i64, T = f32, device = ""} : (tensor<*xf32>, tensor<*xf32>) -> (tensor<*xf32>, tensor<*xi32>, !tf_executor.control)
49
+ %control_23 = "tf_executor.island"() ({
50
+ "tf._Retval"(%output) {T = f32, device = "/job:localhost/replica:0/task:0/device:CPU:0", index = 0 : i64} : (tensor<*xf32>) -> ()
51
+ "tf_executor.yield"() : () -> ()
52
+ }) : () -> !tf_executor.control
53
+ "tf_executor.fetch"() : () -> ()
54
+ }) : () -> ()
55
+ "func.return"() : () -> ()
56
+ }) {sym_name = "main", function_type = () -> ()} : () -> ()
57
+ }) {tf.versions = {bad_consumers = [], min_consumer = 0 : i32, producer = 126 : i32}} : () -> ()
58
+
59
+ // CHECK: _SwitchN
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf-gradient-attr.mlir ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ // CHECK: node {
6
+ // CHECK-NEXT: name: "Const"
7
+ // CHECK-NEXT: op: "Const"
8
+ %0:2 = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_FLOAT", value = dense<2.500000e-01> : tensor<f32>} : () -> tensor<f32> loc("Const")
9
+
10
+ // CHECK: node {
11
+ // CHECK-NEXT: name: "tf.PartitionedCall"
12
+ // CHECK-NEXT: op: "PartitionedCall"
13
+ // CHECK: func {
14
+ // CHECK: name: "foo"
15
+ // CHECK: }
16
+ %1:2 = tf_executor.island wraps "tf.PartitionedCall"(%0) {Tin = [], Tout = [], config = "", config_proto = "", device = "", executor_type = "", f = @foo, name = "Call_foo"} : (tensor<f32>) -> tensor<*xf32>
17
+ tf_executor.fetch
18
+ }
19
+ func.return
20
+ }
21
+
22
+ // CHECK: library {
23
+ // CHECK-NEXT: function {
24
+ // CHECK-NEXT: signature {
25
+ // CHECK-NEXT: name: "foo"
26
+ // CHECK: function {
27
+ // CHECK-NEXT: signature {
28
+ // CHECK-NEXT: name: "foo_grad"
29
+ // CHECK: gradient {
30
+ // CHECK-NEXT: function_name: "foo"
31
+ // CHECK-NEXT: gradient_func: "foo_grad"
32
+ // CHECK-NEXT: }
33
+ // CHECK-NEXT: }
34
+ func.func @foo_grad(%arg0: tensor<*xf32>, %arg1: tensor<*xf32>) -> tensor<*xf32> {
35
+ %graph = tf_executor.graph {
36
+ tf_executor.fetch %arg0 : tensor<*xf32>
37
+ }
38
+ func.return %graph : tensor<*xf32>
39
+ }
40
+
41
+ func.func @foo(%arg0: tensor<*xf32>) -> tensor<*xf32>
42
+ attributes {tf.gradient = @foo_grad} {
43
+ %graph = tf_executor.graph {
44
+ tf_executor.fetch %arg0 : tensor<*xf32>
45
+ }
46
+ func.return %graph : tensor<*xf32>
47
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf-legacy-call.mlir ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", name = "Constant", value = dense<0> : tensor<i32>} : () -> tensor<i32>
6
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.LegacyCall"(%outputs) {_tpu_replicate = "cluster", device = "", f = @foo0} : (tensor<i32>) -> tensor<i32>
7
+ tf_executor.fetch
8
+ }
9
+ func.return
10
+ }
11
+ func.func @foo0(%arg0: tensor<*xi32>) -> tensor<*xi32> {
12
+ %0 = tf_executor.graph {
13
+ tf_executor.fetch %arg0 : tensor<*xi32>
14
+ }
15
+ func.return %0 : tensor<*xi32>
16
+ }
17
+
18
+ // CHECK: node {
19
+ // CHECK: name: "tf.LegacyCall"
20
+ // CHECK-NEXT: op: "foo0"
21
+ // CHECK: attr {
22
+ // CHECK-NEXT: key: "_output_shapes"
23
+ // CHECK-NEXT: value {
24
+ // CHECK-NEXT: list {
25
+ // CHECK-NEXT: shape {
26
+ // CHECK: attr {
27
+ // CHECK-NEXT: key: "_tpu_replicate"
28
+ // CHECK-NEXT: value {
29
+ // CHECK-NEXT: s: "cluster"
30
+ // CHECK-NEXT: }
31
+ // CHECK-NEXT: }
32
+
33
+ // CHECK: library {
34
+ // CHECK-NEXT: function {
35
+ // CHECK-NEXT: signature {
36
+ // CHECK-NEXT: name: "foo0"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf_add.mlir ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main(%arg0: tensor<10xi32>, %arg1: tensor<10xi32>) -> tensor<10xi32>
4
+ attributes {tf.entry_function = {inputs = "input0,input1", outputs = "Add"}} {
5
+ %graph = tf_executor.graph {
6
+ %2:2 = tf_executor.island wraps "tf.Add"(%arg0, %arg1) {T = "tfdtype$DT_INT32", device = ""} : (tensor<10xi32>, tensor<10xi32>) -> tensor<10xi32> loc("Add")
7
+ tf_executor.fetch %2 : tensor<10xi32>
8
+ }
9
+ func.return %graph : tensor<10xi32>
10
+ }
11
+
12
+ // CHECK: node {
13
+ // CHECK-NEXT: name: "input0"
14
+ // CHECK-NEXT: op: "_Arg"
15
+ // CHECK: node {
16
+ // CHECK-NEXT: name: "input1"
17
+ // CHECK-NEXT: op: "_Arg"
18
+ // CHECK: node {
19
+ // CHECK-NEXT: name: "Add{{_.*_1}}"
20
+ // CHECK-NEXT: op: "Add"
21
+ // CHECK-NEXT: input: "input0"
22
+ // CHECK-NEXT: input: "input1"
23
+ // CHECK: node {
24
+ // CHECK-NEXT: name: "Add"
25
+ // CHECK-NEXT: op: "_Retval"
26
+ // CHECK-NEXT: input: "Add{{_.*_1}}"
27
+ // CHECK-NEXT: attr {
28
+ // CHECK-NEXT: key: "T"
29
+ // CHECK-NEXT: value {
30
+ // CHECK-NEXT: type: DT_INT32
31
+ // CHECK-NEXT: }
32
+ // CHECK-NEXT: }
33
+ // CHECK-NEXT: attr {
34
+ // CHECK-NEXT: key: "index"
35
+ // CHECK-NEXT: value {
36
+ // CHECK-NEXT: i: 0
37
+ // CHECK-NEXT: }
38
+ // CHECK-NEXT: }
39
+ // CHECK-NEXT: }
40
+ // CHECK-NEXT: library {
41
+ // CHECK-NEXT: }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf_identity_n.mlir ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() -> tensor<2x3xi32> {
4
+ %graph = tf_executor.graph {
5
+ %0:2 = tf_executor.island wraps "tf.Const"() {value = dense<5> : tensor<2x3xi32>} : () -> tensor<2x3xi32> loc("Const0")
6
+ %1:2 = tf_executor.island wraps "tf.Const"() {value = dense<4.2> : tensor<4x5xf32>} : () -> tensor<4x5xf32> loc("Const1")
7
+ %2:3 = tf_executor.island wraps "tf.IdentityN"(%0, %1) : (tensor<2x3xi32>, tensor<4x5xf32>) -> (tensor<2x3xi32>, tensor<4x5xf32>) loc("MyIdentityN")
8
+ tf_executor.fetch %2#0 : tensor<2x3xi32>
9
+ }
10
+ func.return %graph : tensor<2x3xi32>
11
+ }
12
+
13
+ // CHECK: name: "MyIdentityN"
14
+ // CHECK-NEXT: op: "IdentityN"
15
+ // CHECK-NEXT: input: "Const0"
16
+ // CHECK-NEXT: input: "Const1"
17
+ // CHECK-NEXT: attr {
18
+ // CHECK-NEXT: key: "T"
19
+ // CHECK-NEXT: value {
20
+ // CHECK-NEXT: list {
21
+ // CHECK-NEXT: type: DT_INT32
22
+ // CHECK-NEXT: type: DT_FLOAT
23
+ // CHECK-NEXT: }
24
+ // CHECK-NEXT: }
25
+ // CHECK-NEXT: }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/tf_tpu_embedding_ops.mlir ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ %0:2 = tf_executor.island wraps "tf.RecvTPUEmbeddingActivations"() {config = "test_config_recv_embedding"} : () -> tensor<512x256xf32> loc("RecvTPUEmbedding")
6
+ %1:1 = tf_executor.island wraps "tf.SendTPUEmbeddingGradients"(%0) {N = 1 : i64, NN = 0 : i64, config = "test_config_send_embedding", operandSegmentSizes = array<i32: 1, 0>} : (tensor<512x256xf32>) -> () loc("SendTPUEmbedding")
7
+ tf_executor.fetch
8
+ }
9
+ func.return
10
+ }
11
+
12
+ // CHECK: name: "RecvTPUEmbedding"
13
+ // CHECK-NEXT: op: "RecvTPUEmbeddingActivations"
14
+ // CHECK-NEXT: attr {
15
+ // CHECK-NEXT: key: "_output_shapes"
16
+ // CHECK-NEXT: value {
17
+ // CHECK-NEXT: list {
18
+ // CHECK-NEXT: shape {
19
+ // CHECK-NEXT: dim {
20
+ // CHECK-NEXT: size: 512
21
+ // CHECK-NEXT: }
22
+ // CHECK-NEXT: dim {
23
+ // CHECK-NEXT: size: 256
24
+ // CHECK-NEXT: }
25
+ // CHECK-NEXT: }
26
+ // CHECK-NEXT: }
27
+ // CHECK-NEXT: }
28
+ // CHECK-NEXT: }
29
+ // CHECK-NEXT: attr {
30
+ // CHECK-NEXT: key: "config"
31
+ // CHECK-NEXT: value {
32
+ // CHECK-NEXT: s: "test_config_recv_embedding"
33
+ // CHECK-NEXT: }
34
+ // CHECK-NEXT: }
35
+ // CHECK-NEXT: attr {
36
+ // CHECK-NEXT: key: "num_outputs"
37
+ // CHECK-NEXT: value {
38
+ // CHECK-NEXT: i: 1
39
+ // CHECK-NEXT: }
40
+ // CHECK-NEXT: }
41
+
42
+ // CHECK: name: "SendTPUEmbedding"
43
+ // CHECK-NEXT: op: "SendTPUEmbeddingGradients"
44
+ // CHECK-NEXT: input: "RecvTPUEmbedding"
45
+ // CHECK-NEXT: attr {
46
+ // CHECK-NEXT: key: "N"
47
+ // CHECK-NEXT: value {
48
+ // CHECK-NEXT: i: 1
49
+ // CHECK-NEXT: }
50
+ // CHECK-NEXT: }
51
+ // CHECK-NEXT: attr {
52
+ // CHECK-NEXT: key: "NN"
53
+ // CHECK-NEXT: value {
54
+ // CHECK-NEXT: i: 0
55
+ // CHECK-NEXT: }
56
+ // CHECK-NEXT: }
57
+ // CHECK-NEXT: attr {
58
+ // CHECK-NEXT: key: "config"
59
+ // CHECK-NEXT: value {
60
+ // CHECK-NEXT: s: "test_config_send_embedding"
61
+ // CHECK-NEXT: }
62
+ // CHECK-NEXT: }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/type_attr.mlir ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ // Check that attributes that define types are exported.
4
+
5
+ // CHECK: key: "Tinputs"
6
+ // CHECK-NEXT: value
7
+ // CHECK-NEXT: list
8
+ // CHECK-NEXT: type: DT_FLOAT
9
+
10
+ // CHECK: key: "Toutputs"
11
+ // CHECK-NEXT: value
12
+ // CHECK-NEXT: list
13
+ // CHECK-NEXT: type: DT_FLOAT
14
+
15
+ // CHECK: "extra_type_attr"
16
+ // CHECK-NEXT: value
17
+ // CHECK-NEXT: list
18
+ // CHECK-NEXT: type: DT_INT32
19
+ // CHECK-NEXT: type: DT_FLOAT
20
+
21
+ // CHECK-LABEL: function
22
+ // CHECK: name: "plain"
23
+ // CHECK: Placeholder
24
+ // CHECK: key: "type"
25
+ // CHECK: type: DT_INT8
26
+
27
+ func.func @main(%arg0 : tensor<16xf32>) {
28
+ tf_executor.graph {
29
+ %1:2 = tf_executor.island wraps "tf.MlirPassthroughOp"(%arg0) {extra_type_attr = [tensor<5xi32>, tensor<16xf32>], Tinputs = [tensor<16xf32>], Toutputs = [tensor<16xf32>], mlir_module = ""} : (tensor<16xf32>) -> tensor<16xf32>
30
+ tf_executor.fetch
31
+ }
32
+ func.return
33
+ }
34
+
35
+ func.func @plain() {
36
+ tf_executor.graph {
37
+ %0:2 = tf_executor.island wraps "tf.Placeholder"() {type = i8} : () -> tensor<16xi8>
38
+ tf_executor.fetch
39
+ }
40
+ func.return
41
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/type_list_attr.mlir ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ // CHECK: key: "emptylist"
6
+ // CHECK-NEXT: value {
7
+ // CHECK-NEXT: list {
8
+ // CHECK-NEXT: }
9
+ // CHECK-NEXT: }
10
+ // CHECK: key: "typelist"
11
+ // CHECK-NEXT: value {
12
+ // CHECK-NEXT: list {
13
+ // CHECK-NEXT: type: DT_INT32
14
+ // CHECK-NEXT: type: DT_FLOAT
15
+ // CHECK-NEXT: }
16
+ // CHECK-NEXT: }
17
+ %0:2 = tf_executor.island wraps "tf.Placeholder"() {name = "dummy", dtype = "tfdtype$DT_FLOAT", emptylist = [], typelist = ["tfdtype$DT_INT32", "tfdtype$DT_FLOAT"]} : () -> tensor<*xi32>
18
+ tf_executor.fetch
19
+ }
20
+ func.return
21
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/unique_name.mlir ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ tf_executor.graph {
5
+ // CHECK: name: "foo"
6
+ %0:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<i32>} : () -> (tensor<i32>) loc("foo")
7
+ // CHECK: name: "foo{{_.*_1}}"
8
+ %1:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<1> : tensor<i32>} : () -> (tensor<i32>) loc("foo")
9
+ // CHECK: name: "foo1"
10
+ %2:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<2> : tensor<i32>} : () -> (tensor<i32>) loc("foo1")
11
+ // CHECK: name: "foo{{_.*_2}}"
12
+ %3:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<2> : tensor<i32>} : () -> (tensor<i32>) loc("foo")
13
+ // CHECK: name: "2"
14
+ %4:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<3> : tensor<i32>} : () -> (tensor<i32>) loc("2")
15
+ // CHECK: name: "3"
16
+ %5:2 = tf_executor.island wraps "tf.Const"() {dtype = "tfdtype$DT_INT32", value = dense<3> : tensor<i32>} : () -> (tensor<i32>) loc("3")
17
+ tf_executor.fetch
18
+ }
19
+ func.return
20
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/unique_output_name.mlir ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ module attributes {tf.versions = {producer = 946 : i32}, tf_saved_model.semantics, tfl.description = "MLIR Converted.", tfl.schema_version = 3 : i32} {
4
+ func.func @main(%arg0: tensor<2x4x2x2xf32> {tf_saved_model.index_path = ["x"]}) -> (tensor<2x2x1x2xi32> {tf_saved_model.index_path = ["output_1"]}, tensor<2x2x1x2xf32> {tf_saved_model.index_path = ["output_0"]}) attributes {tf.entry_function = {inputs = "serving_default_x:0", outputs = "PartitionedCall:1,PartitionedCall:0"}, tf_saved_model.exported_names = ["serving_default"]} {
5
+ %0:2 = tf_executor.graph {
6
+ %outputs:2, %control = tf_executor.island wraps "tf.MaxPoolWithArgmax"(%arg0) {T = f32, Targmax = i32, include_batch_in_index = false, ksize = [1, 2, 2, 1], padding = "SAME", strides = [1, 2, 2, 1]} : (tensor<2x4x2x2xf32>) -> (tensor<2x2x1x2xf32>, tensor<2x2x1x2xi32>)
7
+ tf_executor.fetch %outputs#1, %outputs#0 : tensor<2x2x1x2xi32>, tensor<2x2x1x2xf32>
8
+ }
9
+ func.return %0#0, %0#1 : tensor<2x2x1x2xi32>, tensor<2x2x1x2xf32>
10
+ }
11
+ }
12
+
13
+ // CHECK: name: "serving_default_x"
14
+ // CHECK-NEXT: op: "_Arg"
15
+
16
+ // CHECK: name: "tf.MaxPoolWithArgmax"
17
+ // CHECK-NEXT: op: "MaxPoolWithArgmax"
18
+ // CHECK-NEXT: input: "serving_default_x"
19
+
20
+
21
+ // CHECK: name: "PartitionedCall"
22
+ // CHECK-NEXT: op: "_Retval"
23
+ // CHECK-NEXT: input: "tf.MaxPoolWithArgmax:1"
24
+
25
+ // CHECK: name: "PartitionedCall1"
26
+ // CHECK-NOT: name: "PartitionedCall"
27
+ // CHECK-NEXT: op: "_Retval"
28
+ // CHECK-NEXT: input: "tf.MaxPoolWithArgmax"
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlir2graphdef/while-loop.mlir ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-mlir-translate -mlir-to-graphdef %s -o - | FileCheck %s
2
+
3
+ func.func @main() {
4
+ // CHECK: name: "while/Merge"
5
+ // CHECK-NEXT: op: "Merge"
6
+ // CHECK-NEXT: input: "while/Enter"
7
+ // CHECK-NEXT: input: "while/NextIteration"
8
+ // CHECK: name: "while/NextIteration"
9
+ // CHECK-NEXT: op: "NextIteration"
10
+ // CHECK-NEXT: input: "while/Add"
11
+ tf_executor.graph {
12
+ %0:3 = tf_executor.NextIteration.Source : tensor<*xi32> {device = "", T = "tfdtype$DT_INT32"} loc("while/NextIteration")
13
+ %1:2 = tf_executor.island wraps "tf.VariableV2"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<0> : tensor<i32>, shape = #tf_type.shape<0>, container = "", shared_name = ""} : () -> tensor<i32> loc("Ref_Variable")
14
+ %2:2 = tf_executor.Enter %1#0 frame "while/while_context" parallel_iterations 10 : (tensor<i32>) -> (tensor<*xi32>, !tf_executor.control) {device = "", T = "tfdtype$DT_INT32"} loc("while/Enter")
15
+ %3:3 = tf_executor.Merge %2#0, %0#0 : tensor<*xi32> {device = "", N = 2, T = "tfdtype$DT_INT32"} loc("while/Merge")
16
+ %4:2 = tf_executor.island(%3#2) wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<10> : tensor<i32>} : () -> tensor<i32> loc("while/Less/y")
17
+ %5:2 = tf_executor.island wraps "tf.Less"(%3#0, %4#0) {device = "", T = "tfdtype$DT_INT32"} : (tensor<*xi32>, tensor<i32>) -> tensor<*xi1> loc("while/Less")
18
+ %6:2 = tf_executor.LoopCond %5#0 : (tensor<*xi1>) -> (tensor<*xi1>, !tf_executor.control) {device = ""} loc("while/LoopCond")
19
+ %7:3 = tf_executor.Switch %3#0, %6#0 : (tensor<*xi32>, tensor<*xi1>) -> (tensor<*xi32>, tensor<*xi32>, !tf_executor.control) {device = "", T = "tfdtype$DT_INT32", _class = ["loc:@while/Merge"]} loc("while/Switch")
20
+ %8:2 = tf_executor.Exit %7#1 : tensor<*xi32> {device = "", T = "tfdtype$DT_INT32"} loc("while/Exit")
21
+ %10:2 = tf_executor.island(%7#2) wraps "tf.Const"() {device = "", dtype = "tfdtype$DT_INT32", value = dense<1> : tensor<i32>} : () -> tensor<i32> loc("while/Add/y")
22
+ %11:2 = tf_executor.island wraps "tf.AssignAdd"(%7#0, %10#0) {device = "", T = "tfdtype$DT_INT32"} : (tensor<*xi32>, tensor<i32>) -> tensor<*xi32> loc("while/Add")
23
+ tf_executor.NextIteration.Sink [%0#1] %11#0 : tensor<*xi32> {device = "", T = "tfdtype$DT_INT32"} loc("while/NextIteration")
24
+ tf_executor.fetch
25
+ }
26
+ func.return
27
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/mlprogram.mlir ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-opt --split-input-file -tf-lower-to-mlprogram-and-hlo %s -o - | FileCheck %s
2
+
3
+ module attributes {tf_saved_model.semantics} {
4
+ // CHECK-LABEL: func @lowers_to_stablehlo
5
+ func.func @lowers_to_stablehlo(%arg0: tensor<i32> {tf_saved_model.index_path = []}) -> (tensor<i32> {tf_saved_model.index_path = []})
6
+ attributes {tf_saved_model.exported_names = ["lowers_to_stablehlo"]}
7
+ {
8
+ // CHECK-DAG: [[one:%.*]] = stablehlo.constant dense<1>
9
+ // CHECK-DAG: [[twenty:%.*]] = stablehlo.constant dense<20>
10
+ // CHECK-DAG: [[r3:%.*]] = stablehlo.subtract [[twenty]], %arg0
11
+ // CHECK-DAG: [[zero:%.*]] = stablehlo.constant dense<0>
12
+ // CHECK-DAG: [[r4:%.*]] = stablehlo.divide [[r3]], [[one]]
13
+ // CHECK-DAG: [[r5:%.*]] = stablehlo.compare NE
14
+ // CHECK-DAG: [[r6:%.*]] = stablehlo.compare LT
15
+ // CHECK: [[result:%.*]] = stablehlo.select
16
+ // CHECK-NEXT: return [[result]]
17
+ %0 = tf_executor.graph {
18
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", value = dense<1> : tensor<i32>} : () -> tensor<i32>
19
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<20> : tensor<i32>} : () -> tensor<i32>
20
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<0> : tensor<i32>} : () -> tensor<i32>
21
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.Range"(%outputs_2, %outputs_0, %outputs) {device = ""} : (tensor<i32>, tensor<i32>, tensor<i32>) -> tensor<?xi32>
22
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.Sub"(%outputs_0, %arg0) {device = ""} : (tensor<i32>, tensor<i32>) -> tensor<i32>
23
+ %outputs_8, %control_9 = tf_executor.island wraps "tf.FloorDiv"(%outputs_6, %outputs) {device = ""} : (tensor<i32>, tensor<i32>) -> tensor<i32>
24
+ tf_executor.fetch %outputs_8 : tensor<i32>
25
+ }
26
+ func.return %0 : tensor<i32>
27
+ }
28
+ }
29
+
30
+ // -----
31
+
32
+ module attributes {tf_saved_model.semantics} {
33
+ // CHECK-LABEL: func @removes_dead_code
34
+ func.func @removes_dead_code(%arg0: tensor<?x!tf_type.resource> {tf._user_specified_name = "iterator", tf.device = "/job:localhost/replica:0/task:0/device:CPU:0", tf_saved_model.index_path = []})
35
+ attributes {tf_saved_model.exported_names = ["removes_dead_code"]}
36
+ {
37
+ // CHECK-NEXT: return
38
+ tf_executor.graph {
39
+ %outputs, %control = tf_executor.island wraps "tf.Const"() {device = "", value = dense<1> : tensor<i32>} : () -> tensor<i32>
40
+ %outputs_0, %control_1 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<20> : tensor<i32>} : () -> tensor<i32>
41
+ %outputs_2, %control_3 = tf_executor.island wraps "tf.Const"() {device = "", value = dense<0> : tensor<i32>} : () -> tensor<i32>
42
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.Range"(%outputs_2, %outputs_0, %outputs) {device = ""} : (tensor<i32>, tensor<i32>, tensor<i32>) -> tensor<?xi32>
43
+ %outputs_6, %control_7 = tf_executor.island wraps "tf.Sub"(%outputs_0, %outputs_2) {device = ""} : (tensor<i32>, tensor<i32>) -> tensor<i32>
44
+ %outputs_8, %control_9 = tf_executor.island wraps "tf.FloorDiv"(%outputs_6, %outputs) {device = ""} : (tensor<i32>, tensor<i32>) -> tensor<i32>
45
+ tf_executor.fetch %control_9 : !tf_executor.control
46
+ }
47
+ return
48
+ }
49
+ }
50
+
51
+ // -----
52
+
53
+ module attributes {tf_saved_model.semantics} {
54
+ // CHECK-LABEL: func @lowers_variable_ops
55
+ func.func @lowers_variable_ops()
56
+ attributes {tf_saved_model.exported_names = ["lowers_variable_ops"]}
57
+ {
58
+ // CHECK: ml_program.global_store
59
+ tf_executor.graph {
60
+ %0, %c0 = tf_executor.island wraps "tf.Const"() {value = dense<1> : tensor<i32>} : () -> tensor<i32>
61
+ %1, %c1 = tf_executor.island wraps "tf.VarHandleOp"() {container = "", shared_name = "v"} : () -> tensor<!tf_type.resource<tensor<i32>>>
62
+ %c2 = tf_executor.island wraps "tf.AssignVariableOp"(%1, %0) : (tensor<!tf_type.resource<tensor<i32>>>, tensor<i32>) -> ()
63
+ tf_executor.fetch %c2 : !tf_executor.control
64
+ }
65
+ return
66
+ }
67
+ }
68
+
69
+ // -----
70
+
71
+ module attributes {tf_saved_model.semantics} {
72
+
73
+ func.func private @while_cond(%arg0: tensor<i32>, %arg1: tensor<i32>) -> tensor<i1> {
74
+ %0 = tf_executor.graph {
75
+ %1, %c0 = tf_executor.island wraps "tf.Const"() {value = dense<1> : tensor<i1>} : () -> tensor<i1>
76
+ tf_executor.fetch %1 : tensor<i1>
77
+ }
78
+ return %0 : tensor<i1>
79
+ }
80
+
81
+ func.func private @while_body(%arg0: tensor<i32>, %arg1: tensor<i32>) -> (tensor<i32>, tensor<i32>) {
82
+ tf_executor.graph {
83
+ %1, %c1 = tf_executor.island wraps "tf.VarHandleOp"() {container = "", shared_name = "v"} : () -> tensor<!tf_type.resource<tensor<i32>>>
84
+ %c2 = tf_executor.island wraps "tf.AssignVariableOp"(%1, %arg1) : (tensor<!tf_type.resource<tensor<i32>>>, tensor<i32>) -> ()
85
+ tf_executor.fetch %c2 : !tf_executor.control
86
+ }
87
+ return %arg0, %arg1 : tensor<i32>, tensor<i32>
88
+ }
89
+
90
+ // CHECK-LABEL: func @handles_variables_in_while_loops
91
+ func.func @handles_variables_in_while_loops(%arg0: tensor<!tf_type.resource<tensor<i32>>> {tf._user_specified_name = "arg0", tf.device = "/job:localhost/replica:0/task:0/device:CPU:0", tf_saved_model.index_path = []})
92
+ attributes {tf_saved_model.exported_names = ["handles_variables_in_while_loops"]}
93
+ {
94
+ // CHECK: stablehlo.while
95
+ tf_executor.graph {
96
+ %0, %c0 = tf_executor.island wraps "tf.Const"() {value = dense<1> : tensor<i32>} : () -> tensor<i32>
97
+ %1, %c1 = tf_executor.island wraps "tf.Const"() {value = dense<1> : tensor<i32>} : () -> tensor<i32>
98
+ %2, %3, %c2 = tf_executor.island wraps "tf.While"(%0, %1) {
99
+ body = @while_body , cond = @while_cond, is_stateless = true
100
+ } : (tensor<i32>, tensor<i32>) -> (tensor<i32>, tensor<i32>)
101
+ tf_executor.fetch %c2 : !tf_executor.control
102
+ }
103
+ return
104
+ }
105
+ }
106
+
107
+ // -----
108
+
109
+ module attributes {tf_saved_model.semantics} {
110
+ // CHECK: func @a
111
+ // CHECK: func @b
112
+ // CHECK: func @c
113
+ // CHECK-LABEL @expands_exported_names
114
+ func.func @expands_exported_names()
115
+ attributes {tf_saved_model.exported_names = ["a", "b", "c"]} {
116
+ return
117
+ }
118
+ }
119
+
120
+ // -----
121
+
122
+ module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 1512 : i32}} {
123
+ // CHECK-LABEL @lowers_string_ops
124
+ // CHECK-DAG: ml_program.global public @vars.Variable_1([]) : tensor<!tf_type.string>
125
+ func.func @lowers_string_ops(%arg0: tensor<128xi32>, %arg1: tensor<128xi32>, %arg2: tensor<128x1xi32>, %arg3: tensor<128x90xi32>, %arg4: tensor<128x90xi32>, %arg5: tensor<128x90xi32>, %arg6: tensor<128x90x64xf32>, %arg7: tensor<128x90x64xf32>) -> tensor<!tf_type.string> {
126
+ // CHECK: %[[v0:.*]] = ml_program.global_load @vars.Variable_1 : tensor<!tf_type.string>
127
+ %0 = tf_executor.graph {
128
+ %outputs_4, %control_5 = tf_executor.island wraps "tf.VarHandleOp"() {container = "", shared_name = "Variable"} : () -> tensor<!tf_type.resource<tensor<!tf_type.string>>>
129
+ %outputs_10, %control_11 = tf_executor.island wraps "tf.VarHandleOp"() {container = "", shared_name = "Variable_1"} : () -> tensor<!tf_type.resource<tensor<!tf_type.string>>>
130
+ %outputs_14, %control_15 = tf_executor.island wraps "tf.ReadVariableOp"(%outputs_10) : (tensor<!tf_type.resource<tensor<!tf_type.string>>>) -> tensor<!tf_type.string>
131
+ %control_18 = tf_executor.island wraps "tf.AssignVariableOp"(%outputs_4, %outputs_14) : (tensor<!tf_type.resource<tensor<!tf_type.string>>>, tensor<!tf_type.string>) -> ()
132
+ tf_executor.fetch %outputs_14 : tensor<!tf_type.string>
133
+ }
134
+ func.return %0 : tensor<!tf_type.string>
135
+ }
136
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/move_tpu_compile_to_front.mlir ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-opt %s -allow-unregistered-dialect --tf-move-tpu-compile-to-front --split-input-file | FileCheck %s
2
+
3
+ module {
4
+
5
+ // CHECK-LABEL: does_basic_reordering
6
+ func.func @does_basic_reordering() -> () {
7
+ // CHECK: _TPUCompileMlir
8
+ // CHECK-SAME: X
9
+ // CHECK: _TPUCompileMlir
10
+ // CHECK-SAME: Y
11
+ // CHECK: OpA
12
+ // CHECK: OpB
13
+ // CHECK: OpC
14
+ "tf.OpA"() : () -> ()
15
+ %status_x, %program_x = "tf._TPUCompileMlir"() { metadata = "X", mlir_module = "..." } : () -> (tensor<!tf_type.string>, tensor<!tf_type.string>)
16
+ "tf.OpB"() : () -> ()
17
+ %status_y, %program_y = "tf._TPUCompileMlir"() { metadata = "Y", mlir_module = "..." } : () -> (tensor<!tf_type.string>, tensor<!tf_type.string>)
18
+ "tf.OpC"() : () -> ()
19
+ }
20
+
21
+ // CHECK-LABEL: does_reordering_for_nested_compiles
22
+ func.func @does_reordering_for_nested_compiles() -> () {
23
+ // CHECK: _TPUCompileMlir
24
+ // CHECK-SAME: Z
25
+ // CHECK: tf_device.launch
26
+ // CHECK-NEXT: _TPUCompileMlir
27
+ // CHECK-SAME: X
28
+ // CHECK: tf_device.launch
29
+ // CHECK-NEXT: _TPUCompileMlir
30
+ // CHECK-SAME: Y
31
+ // CHECK: OpA
32
+ // CHECK: OpB
33
+ // CHECK: OpC
34
+ "tf.OpA"() : () -> ()
35
+ "tf_device.launch"() ({
36
+ %status_x, %program_x = "tf._TPUCompileMlir"() { metadata = "X", mlir_module = "..." } : () -> (tensor<!tf_type.string>, tensor<!tf_type.string>)
37
+ tf_device.return
38
+ }) {device = ""} : () -> ()
39
+ "tf.OpB"() : () -> ()
40
+ "tf_device.launch"() ({
41
+ %status_y, %program_y = "tf._TPUCompileMlir"() { metadata = "Y", mlir_module = "..." } : () -> (tensor<!tf_type.string>, tensor<!tf_type.string>)
42
+ tf_device.return
43
+ }) {device = ""} : () -> ()
44
+ %status_z, %program_z = "tf._TPUCompileMlir"() { metadata = "Z", mlir_module = "..." } : () -> (tensor<!tf_type.string>, tensor<!tf_type.string>)
45
+ "tf.OpC"() : () -> ()
46
+ }
47
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/name_anonymous_iterators.mlir ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-opt %s --tf-name-anonymous-iterators --split-input-file | FileCheck %s
2
+
3
+ // CHECK-LABEL: gives_a_name_to_anonymous_iterators
4
+ func.func private @gives_a_name_to_anonymous_iterators() {
5
+ // CHECK: "tf.Iterator"
6
+ // CHECK-SAME: output_shapes{{.*}}200x28x28x1{{.*}}200x10
7
+ // CHECK-SAME: output_types = [f32, f32]
8
+ // CHECK-SAME: shared_name = "_iterator1"
9
+ %0 = "tf.AnonymousIteratorV3"() {output_shapes = [
10
+ #tf_type.shape<200x28x28x1>,
11
+ #tf_type.shape<200x10>], output_types = [f32, f32]} : () -> tensor<!tf_type.resource>
12
+ // CHECK: "tf.Iterator"
13
+ // CHECK-SAME: shared_name = "_iterator2"
14
+ %1 = "tf.AnonymousIteratorV3"() {output_shapes = [
15
+ #tf_type.shape<200x10>], output_types = [f32]} : () -> tensor<!tf_type.resource>
16
+ return
17
+ }
18
+
19
+ // -----
20
+
21
+ // CHECK-LABEL: handles_all_versions
22
+ func.func private @handles_all_versions() {
23
+ // CHECK: "tf.Iterator"
24
+ // CHECK-SAME: 1x42
25
+ %0 = "tf.AnonymousIterator"() {output_shapes = [
26
+ #tf_type.shape<1x42>], output_types = [f32]} : () -> tensor<!tf_type.resource>
27
+ // CHECK: "tf.Iterator"
28
+ // CHECK-SAME: 2x42
29
+ %1, %2 = "tf.AnonymousIteratorV2"() {output_shapes = [
30
+ #tf_type.shape<2x42>], output_types = [f32]} : () -> (tensor<!tf_type.resource>, tensor<!tf_type.variant>)
31
+ // CHECK: "tf.Iterator"
32
+ // CHECK-SAME: 3x42
33
+ %3 = "tf.AnonymousIteratorV3"() {output_shapes = [
34
+ #tf_type.shape<3x42>], output_types = [f32]} : () -> tensor<!tf_type.resource>
35
+ return
36
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/optimize-arg-operand-constraint.mlir ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-opt -tf-optimize %s | FileCheck %s
2
+
3
+ // Check passing an argument into DefinedByConv2D constraint does not crash.
4
+
5
+ // CHECK-LABEL: func @main
6
+ func.func @main(%arg0: tensor<1xf32>) -> tensor<1xf32>
7
+ attributes {tf.entry_function = {inputs = "input", outputs = "output_node"}} {
8
+ %0 = arith.constant dense<2.000000e+00> : tensor<f32>
9
+ %1 = arith.constant dense<1.000000e+00> : tensor<f32>
10
+ %2 = "tf.AddV2"(%arg0, %1) {T = "tfdtype$DT_FLOAT", device = "", name = "StatefulPartitionedCall/add"} : (tensor<1xf32>, tensor<f32>) -> tensor<1xf32>
11
+ %3 = "tf.Mul"(%2, %0) {T = "tfdtype$DT_FLOAT", device = "", name = "output_node"} : (tensor<1xf32>, tensor<f32>) -> tensor<1xf32>
12
+ func.return %3 : tensor<1xf32>
13
+ }
western_ai/usa/tensorflow/tensorflow/compiler/mlir/tensorflow/tests/optimize.mlir ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RUN: tf-opt -tf-optimize %s -o %t && FileCheck %s < %t
2
+
3
+ // CHECK-LABEL: convbiasaddmul
4
+ func.func @convbiasaddmul(%arg: tensor<256x32x32x3xf32>) -> tensor<256x8x7x16xf32> {
5
+ %filter = arith.constant dense<2.0> : tensor<3x3x3x16xf32>
6
+ %bias = arith.constant dense<3.0> : tensor<16xf32>
7
+ %value = arith.constant dense<4.0> : tensor<16xf32>
8
+ %0 = "tf.Conv2D"(%arg, %filter) {T = "tfdtype$DT_FLOAT", data_format = "NHWC", dilations = [1, 2, 3, 1], padding = "SAME", strides = [1, 4, 5, 1]} : (tensor<256x32x32x3xf32>, tensor<3x3x3x16xf32>) -> tensor<256x8x7x16xf32>
9
+ %1 = "tf.BiasAdd"(%0, %bias) {T = "tfdtype$DT_FLOAT", data_format = "NHWC"}: (tensor<256x8x7x16xf32>, tensor<16xf32>) -> tensor<256x8x7x16xf32>
10
+ %2 = "tf.Mul"(%1, %value) {T = "tfdtype$DT_FLOAT"} : (tensor<256x8x7x16xf32>, tensor<16xf32>) -> tensor<256x8x7x16xf32>
11
+ func.return %2 : tensor<256x8x7x16xf32>
12
+
13
+ // CHECK-DAG: %[[cst:.*]] = "tf.Const{{.*}} dense<8.000000e+00> : tensor<3x3x3x16xf32>
14
+ // CHECK-DAG: %[[cst_0:.*]] = "tf.Const{{.*}} dense<1.200000e+01> : tensor<16xf32>
15
+ // CHECK-NEXT: %[[conv:.*]] = "tf.Conv2D"(%arg0, %[[cst]])
16
+ // CHECK-NEXT: %[[bias:.*]] = "tf.AddV2"(%[[conv]], %[[cst_0]])
17
+ // CHECK-NEXT: return %[[bias]] : tensor<256x8x7x16xf32>
18
+ }
19
+
20
+ // CHECK-LABEL: convaddv2mul
21
+ func.func @convaddv2mul(%arg: tensor<256x32x32x3xf32>) -> tensor<256x8x7x16xf32> {
22
+ %filter = arith.constant dense<2.0> : tensor<3x3x3x16xf32>
23
+ %bias = arith.constant dense<3.0> : tensor<16xf32>
24
+ %value = arith.constant dense<4.0> : tensor<16xf32>
25
+ %0 = "tf.Conv2D"(%arg, %filter) {T = "tfdtype$DT_FLOAT", data_format = "NHWC", dilations = [1, 2, 3, 1], padding = "SAME", strides = [1, 4, 5, 1]} : (tensor<256x32x32x3xf32>, tensor<3x3x3x16xf32>) -> tensor<256x8x7x16xf32>
26
+ %1 = "tf.AddV2"(%0, %bias) {T = "tfdtype$DT_FLOAT"}: (tensor<256x8x7x16xf32>, tensor<16xf32>) -> tensor<256x8x7x16xf32>
27
+ %2 = "tf.Mul"(%1, %value) {T = "tfdtype$DT_FLOAT"} : (tensor<256x8x7x16xf32>, tensor<16xf32>) -> tensor<256x8x7x16xf32>
28
+ func.return %2 : tensor<256x8x7x16xf32>
29
+
30
+ // CHECK-DAG: %[[cst:.*]] = "tf.Const{{.*}} dense<8.000000e+00> : tensor<3x3x3x16xf32>
31
+ // CHECK-DAG: %[[cst_0:.*]] = "tf.Const{{.*}} dense<1.200000e+01> : tensor<16xf32>
32
+ // CHECK-NEXT: %[[conv:.*]] = "tf.Conv2D"(%arg0, %[[cst]])
33
+ // CHECK-NEXT: %[[add:.*]] = "tf.AddV2"(%[[conv]], %[[cst_0]])
34
+ // CHECK-NEXT: return %[[add]] : tensor<256x8x7x16xf32>
35
+ }
36
+
37
+ // CHECK-LABEL: fold_cast_fft_to_rfft
38
+ func.func @fold_cast_fft_to_rfft(%arg0: tensor<10x20x30xf32>) -> tensor<10x20x30xcomplex<f32>> {
39
+ %0 = "tf.Cast"(%arg0) : (tensor<10x20x30xf32>) -> tensor<10x20x30xcomplex<f32>>
40
+ %1 = "tf.FFT"(%0) : (tensor<10x20x30xcomplex<f32>>) -> tensor<10x20x30xcomplex<f32>>
41
+ func.return %1: tensor<10x20x30xcomplex<f32>>
42
+
43
+ // CHECK: %[[cst:.*]] = arith.constant dense<30> : tensor<1xi32>
44
+ // CHECK: %[[rff:.*]] = "tf.RFFT"(%arg0, %[[cst]]) : (tensor<10x20x30xf32>, tensor<1xi32>) -> tensor<10x20x30xcomplex<f32>>
45
+ }
46
+
47
+ // CHECK-LABEL: not_fold_cast_fft_to_rfft
48
+ func.func @not_fold_cast_fft_to_rfft(%arg0: tensor<10x20x30xcomplex<f64>>) -> tensor<10x20x30xcomplex<f32>> {
49
+ %0 = "tf.Cast"(%arg0) : (tensor<10x20x30xcomplex<f64>>) -> tensor<10x20x30xcomplex<f32>>
50
+ %1 = "tf.FFT"(%0) : (tensor<10x20x30xcomplex<f32>>) -> tensor<10x20x30xcomplex<f32>>
51
+ func.return %1: tensor<10x20x30xcomplex<f32>>
52
+
53
+ // CHECK: %[[fft:.*]] = "tf.FFT"(%0) : (tensor<10x20x30xcomplex<f32>>) -> tensor<10x20x30xcomplex<f32>>
54
+ }