10000 hlo/tools : move hlo tools tests to dedicated hlo/tools/tests directory. · linux-on-ibm-z/tensorflow@4cbcaca · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cbcaca

Browse files
abhigunjtensorflower-gardener
authored andcommitted
hlo/tools : move hlo tools tests to dedicated hlo/tools/tests directory.
PiperOrigin-RevId: 730535112
1 parent f189fb0 commit 4cbcaca

14 files changed

+152
-115
lines changed

third_party/xla/xla/hlo/tools/BUILD

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Tools and utilities that aid in XLA development and usage.
22

3-
load("@bazel_skylib//rules:build_test.bzl", "build_test")
4-
load("//xla:lit.bzl", "lit_test_suite")
5-
load("//xla:strict.default.bzl", "py_strict_library", "py_strict_test")
3+
load("//xla:strict.default.bzl", "py_strict_library")
64
load(
75
"//xla:xla.bzl",
86
"xla_cc_binary",
@@ -25,13 +23,6 @@ filegroup(
2523
visibility = ["//xla:internal"],
2624
)
2725

28-
build_test(
29-
name = "hex_floats_to_packed_literal_build_test",
30-
targets = [
31-
":hex_floats_to_packed_literal",
32-
],
33-
)
34-
3526
xla_cc_binary(
3627
name = "hex_floats_to_packed_literal",
3728
srcs = ["hex_floats_to_packed_literal.cc"],
@@ -48,13 +39,6 @@ xla_cc_binary(
4839
],
4940
)
5041

51-
build_test(
52-
name = "show_literal_build_test",
53-
targets = [
54-
":show_literal",
55-
],
56-
)
57-
5842
xla_cc_binary(
5943
name = "show_literal",
6044
srcs = ["show_literal.cc"],
@@ -69,13 +53,6 @@ xla_cc_binary(
6953
],
7054
)
7155

72-
build_test(
73-
name = "convert_computation_build_test",
74-
targets = [
75-
":convert_computation",
76-
],
77-
)
78-
7956
xla_cc_binary(
8057
name = "convert_computation",
8158
srcs = ["convert_computation.cc"],
@@ -89,13 +66,6 @@ xla_cc_binary(
8966
],
9067
)
9168

92-
build_test(
93-
name = "hlo_module_metadata_processor_build_test",
94-
targets = [
95-
":hlo_module_metadata_processor",
96-
],
97-
)
98-
9969
xla_cc_binary(
10070
name = "hlo_module_metadata_processor",
10171
srcs = ["hlo_module_metadata_processor.cc"],
@@ -112,13 +82,6 @@ xla_cc_binary(
11282
],
11383
)
11484

115-
build_test(
116-
name = "show_text_literal_build_test",
117-
targets = [
118-
":show_text_literal",
119-
],
120-
)
121-
12285
xla_cc_binary(
12386
name = "show_text_literal",
12487
srcs = ["show_text_literal.cc"],
@@ -148,29 +111,6 @@ xla_cc_binary(
148111
],
149112
)
150113

151-
lit_test_suite(
152-
name = "hlo_convert_tests",
153-
srcs = [
154-
"tests/convert_to_pbtxt.hlo",
155-
"tests/convert_to_text.hlo",
156-
],
157-
cfg = "//xla:lit.cfg.py",
158-
data = [
159-
"tests/convert_to_text.hlo.pb",
160-
],
161-
tools = [
162-
":convert",
163-
"@llvm-project//llvm:FileCheck",
164-
],
165-
)
166-
167-
build_test(
168-
name = "hlo_proto_to_json_build_test",
169-
targets = [
170-
":hlo_proto_to_json",
171-
],
172-
)
173-
174114
xla_cc_binary(
175115
name = "hlo_proto_to_json",
176116
srcs = ["hlo_proto_to_json.cc"],
@@ -231,31 +171,3 @@ py_strict_library(
231171
srcs = ["generate_hlo_test_checks.py"],
232172
srcs_version = "PY3",
233173
)
234-
235-
py_strict_test(
236-
name = "generate_hlo_test_checks_test",
237-
srcs = ["generate_hlo_test_checks_test.py"],
238-
data = [
239-
"generate_hlo_test_checks_test_input.hlo",
240-
"generate_hlo_test_checks_test_output.hlo",
241-
":hlo-opt",
242-
],
243-
python_version = "PY3",
244-
deps = [
245-
":generate_hlo_test_checks",
246-
"@absl_py//absl/testing:absltest",
247-
],
248-
)
249-
250-
# Whereas `:generate_hlo_test_checks_test` checks that the test-generation tool
251-
# behaves as expected, this test verifies that the expected reference output
252-
# from that test is itself a passing test.
253-
lit_test_suite(
254-
name = "generate_hlo_test_checks_meta_test",
255-
srcs = ["generate_hlo_test_checks_test_output.hlo"],
256-
cfg = "//xla:lit.cfg.py",
257-
tools = [
258-
"//xla/hlo/tools:hlo-opt",
259-
"@llvm-project//llvm:FileCheck",
260-
],
261-
)

third_party/xla/xla/hlo/tools/hlo_opt/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ cc_library(
4141
"//xla/hlo/analysis:indexed_array_analysis",
4242
"//xla/hlo/ir:hlo",
4343
"//xla/hlo/pass:hlo_pass_pipeline",
44+
"//xla/hlo/tools/tests:hlo_opt_dummy_passes",
4445
"//xla/hlo/transforms:add_original_value",
4546
"//xla/hlo/transforms:bfloat16_propagation",
4647
"//xla/hlo/transforms:convert_memory_placement_to_internal_annotations",
@@ -120,7 +121,6 @@ cc_library(
120121
"//xla/hlo/transforms/simplifiers:tree_reduction_rewriter",
121122
"//xla/hlo/transforms/simplifiers:tuple_simplifier",
122123
"//xla/hlo/transforms/simplifiers:zero_sized_hlo_elimination",
123-
"//xla/hlo/transforms/tests:dummy_passes",
124124
"//xla/service:buffer_value",
125125
"//xla/service:float_support",
126126
"//xla/service:platform_util",

third_party/xla/xla/hlo/tools/hlo_opt/opt_lib.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ limitations under the License.
4040
#include "xla/hlo/ir/hlo_instruction.h"
4141
#include "xla/hlo/ir/hlo_module.h"
4242
#include "xla/hlo/pass/hlo_pass_pipeline.h"
43+
#include "xla/hlo/tools/tests/hlo_opt_dummy_passes.h"
4344
#include "xla/hlo/transforms/add_original_value.h"
4445
#include "xla/hlo/transforms/bfloat16_propagation.h"
4546
#include "xla/hlo/transforms/collectives/all_gather_broadcast_reorder.h"
@@ -118,7 +119,6 @@ limitations under the License.
118119
#include "xla/hlo/transforms/simplifiers/tree_reduction_rewriter.h"
119120
#include "xla/hlo/transforms/simplifiers/tuple_simplifier.h"
120121
#include "xla/hlo/transforms/simplifiers/zero_sized_hlo_elimination.h"
121-
#include "xla/hlo/transforms/tests/dummy_passes.h"
122122
#include "xla/hlo/transforms/while_loop_trip_count_annotator.h"
123123
#include "xla/literal_pool.h"
124124
#include "xla/service/buffer_value.h"
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2+
load("//xla:lit.bzl", "enforce_glob", "lit_test_suite")
3+
load("//xla:strict.default.bzl", "py_strict_test")
4+
load("//xla/tsl:tsl.default.bzl", "filegroup")
5+
6+
package(
7+
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
8+
default_visibility = ["//xla:internal"],
9+
licenses = ["notice"],
10+
)
11+
12+
# Filegroup used to collect source files for dependency checking.
13+
filegroup(
14+
name = "c_srcs",
15+
data = glob([
16+
"**/*.cc",
17+
"**/*.h",
18+
]),
19+
visibility = ["//xla:internal"],
20+
)
21+
22+
lit_test_suite(
23+
name = "hlo_opt_tests",
24+
srcs = enforce_glob(
25+
[
26+
# go/keep-sorted start
27+
"hlo_opt_all_passes_smoke_test.hlo",
28+
"hlo_opt_emit_proto.hlo",
29+
"hlo_opt_nonexistent_pass_failure.hlo",
30+
"hlo_opt_run_multiple_passes.hlo",
31+
"hlo_opt_run_single_pass.hlo",
32+
# go/keep-sorted end
33+
],
34+
include = [
35+
"hlo_opt_*.hlo",
36+
],
37+
),
38+
cfg = "//xla:lit.cfg.py",
39+
tools = [
40+
"//xla/hlo/tools:hlo-opt",
41+
"@llvm-project//llvm:FileCheck",
42+
"@llvm-project//llvm:not",
43+
],
44+
)
45+
46+
py_strict_test(
47+
name = "generate_hlo_test_checks_test",
48+
srcs = ["generate_hlo_test_checks_test.py"],
49+
data = [
50+
"generate_hlo_test_checks_test_input.hlo",
51+
"generate_hlo_test_checks_test_output.hlo",
52+
"//xla/hlo/tools:hlo-opt",
53+
],
54+
python_version = "PY3",
55+
deps = [
56+
"//xla/hlo/tools:generate_hlo_test_checks",
57+
"@absl_py//absl/testing:absltest",
58+
],
59+
)
60+
61+
# Whereas `:generate_hlo_test_checks_test` checks that the test-generation tool
62+
# behaves as expected, this test verifies that the expected reference output
63+
# from that test is itself a passing test.
64+
lit_test_suite(
65+
name = "generate_hlo_test_checks_meta_test",
66+
srcs = ["generate_hlo_test_checks_test_output.hlo"],
67+
cfg = "//xla:lit.cfg.py",
68+
tools = [
69+
"//xla/hlo/tools:hlo-opt",
70+
"@llvm-project//llvm:FileCheck",
71+
],
72+
)
73+
74+
lit_test_suite(
75+
name = "hlo_convert_tests",
76+
srcs = [
77+
"convert_to_pbtxt.hlo",
78+
"convert_to_text.hlo",
79+
],
80+
cfg = "//xla:lit.cfg.py",
81+
data = [
82+
"convert_to_text.hlo.pb",
83+
],
84+
tools = [
85+
"//xla/hlo/tools:convert",
86+
"@llvm-project//llvm:FileCheck",
87+
],
88+
)
89+
90+
cc_library(
91+
name = "hlo_opt_dummy_passes",
92+
hdrs = ["hlo_opt_dummy_passes.h"],
93+
deps = [
94+
"//xla/hlo/ir:hlo",
95+
"//xla/hlo/pass:hlo_pass",
96+
"@com_google_absl//absl/container:flat_hash_set",
97+
"@com_google_absl//absl/log:check",
98+
"@com_google_absl//absl/status:statusor",
99+
"@com_google_absl//absl/strings:string_view",
100+
],
101+
)
102+
103+
build_test(
104+
name = "hex_floats_to_packed_literal_build_test",
105+
targets = [
106+
"//xla/hlo/tools:hex_floats_to_packed_literal",
107+
],
108+
)
109+
110+
build_test(
111+
name = "convert_computation_build_test",
112+
targets = [
113+
"//xla/hlo/tools:convert_computation",
114+
],
115+
)
116+
117+
build_test(
118+
name = "show_text_literal_build_test",
119+
targets = [
120+
"//xla/hlo/tools:show_text_literal",
121+
],
122+
)
123+
124+
build_test(
125+
name = "hlo_proto_to_json_build_test",
126+
targets = [
127+
"//xla/hlo/tools:hlo_proto_to_json",
128+
],
129+
)
130+
131+
build_test(
132+
name = "hlo_module_metadata_processor_build_test",
133+
targets = [
134+
"//xla/hlo/tools:hlo_module_metadata_processor",
135+
],
136+
)
137+
138+
build_test(
139+
name = "show_literal_build_test",
140+
targets = [
141+
"//xla/hlo/tools:show_literal",
142+
],
143+
)

third_party/xla/xla/hlo/tools/generate_hlo_test_checks_test.py renamed to third_party/xla/xla/hlo/tools/tests/generate_hlo_test_checks_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class GenerateHloTestChecksTest(absltest.TestCase):
2626
def setUp(self):
2727
super().setUp()
2828
self._data_dir = os.path.dirname(__file__)
29-
self._optimizer_path = os.path.join(self._data_dir, "hlo-opt")
29+
parent_dir = os.path.abspath(os.path.join(self._data_dir, os.pardir))
30+
self._optimizer_path = os.path.join(parent_dir, "hlo-opt")
3031
self._input_file_path = os.path.join(
3132
self._data_dir, "generate_hlo_test_checks_test_input.hlo"
3233
)

third_party/xla/xla/hlo/transforms/tests/dummy_passes.h renamed to third_party/xla/xla/hlo/tools/tests/hlo_opt_dummy_passes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#ifndef XLA_HLO_TRANSFORMS_TESTS_DUMMY_PASSES_H_
17-
#define XLA_HLO_TRANSFORMS_TESTS_DUMMY_PASSES_H_
16+
#ifndef XLA_HLO_TOOLS_TESTS_HLO_OPT_DUMMY_PASSES_H_
17+
#define XLA_HLO_TOOLS_TESTS_HLO_OPT_DUMMY_PASSES_H_
1818

1919
#include "absl/container/flat_hash_set.h"
2020
#include "absl/log/check.h"
@@ -73,4 +73,4 @@ class BarToHelloModulePass : public HloModulePass {
7373

7474
} // namespace xla
7575

76-
#endif // XLA_HLO_TRANSFORMS_TESTS_DUMMY_PASSES_H_
76+
#endif // XLA_HLO_TOOLS_TESTS_HLO_OPT_DUMMY_PASSES_H_

0 commit comments

Comments
 (0)
0