Skip to content

Commit

Permalink
Fix HloRunnerAgnosticTestBase includes.
Browse files Browse the repository at this point in the history
Many of the tests that extend `HloTestBase` rely on symbols included
transitively.  The main ones are:

- `PlatformUtil`
- `LiteralUtil`
- `LiteralTestUtil`

This patch adds includes for these explicitly.

PiperOrigin-RevId: 712656979
  • Loading branch information
nvgrw authored and Google-ML-Automation committed Jan 7, 2025
1 parent 43e5b9c commit e457606
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 75 deletions.
41 changes: 31 additions & 10 deletions xla/service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1837,21 +1837,21 @@ xla_cc_test(
name = "hlo_schedule_test",
srcs = ["hlo_schedule_test.cc"],
deps = [
":buffer_value",
"//xla:literal_util",
"//xla:shape_util",
"//xla:test_helpers",
"//xla:types",
"//xla:xla_data_proto_cc",
"//xla/hlo/analysis:hlo_ordering",
"//xla/hlo/ir:hlo",
"//xla/hlo/transforms/simplifiers:hlo_dce",
"//xla/hlo/transforms/simplifiers:hlo_memory_scheduler",
"//xla/tests:hlo_test_base",
"//xla/tests:xla_internal_test_main",
"//xla/tsl/lib/core:status_test_util",
"//xla/tsl/platform:statusor",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/log",
"@com_google_googletest//:gtest",
"@tsl//tsl/platform:statusor",
],
)

Expand Down Expand Up @@ -2024,14 +2024,22 @@ xla_cc_test(
":hlo_creation_utils",
":pattern_matcher",
":pattern_matcher_gmock",
"//xla:array2d",
"//xla:literal",
"//xla:literal_util",
"//xla:shape_util",
"//xla:test",
"//xla:xla_data_proto_cc",
"//xla/hlo/evaluator:hlo_evaluator",
"//xla/hlo/ir:hlo",
"//xla/hlo/testlib:verified_hlo_module",
"//xla/tests:hlo_test_base",
"//xla/tests:literal_test_util",
"//xla/tests:xla_internal_test_main",
"@tsl//tsl/platform:test",
"//xla/tsl/platform:statusor",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest",
],
)

Expand Down Expand Up @@ -2230,13 +2238,16 @@ xla_cc_test(
shard_count = 12,
deps = [
":triangular_solve_expander",
"//xla:array2d",
"//xla:error_spec",
"//xla:literal",
"//xla:literal_util",
"//xla:reference_util",
"//xla:test",
"//xla:types",
"//xla/tests:hlo_test_base",
"//xla/tests:literal_test_util",
"//xla/tests:xla_internal_test_main",
"//xla/tsl/lib/core:status_test_util",
"//xla/tsl/platform:statusor",
"//xla/tsl/platform:test",
],
)

Expand Down Expand Up @@ -3493,25 +3504,35 @@ xla_cc_test(
name = "hlo_module_test",
srcs = ["hlo_module_test.cc"],
deps = [
":buffer_value",
":computation_placer_hdr",
":hlo_module_config",
":test_compilation_environment_proto_cc",
"//xla:literal",
"//xla:comparison_util",
"//xla:debug_options_flags",
"//xla:literal_util",
"//xla:shape_util",
"//xla:test",
"//xla:xla_data_proto_cc",
"//xla:xla_proto_cc",
"//xla/hlo/ir:hlo",
"//xla/hlo/testlib:verified_hlo_module",
"//xla/hlo/transforms/simplifiers:hlo_memory_scheduler",
"//xla/hlo/utils:hlo_matchers",
"//xla/tests:hlo_test_base",
"//xla/tests:xla_internal_test_main",
"//xla/tsl/lib/core:status_test_util",
"//xla/tsl/lib/strings:proto_serialization",
"//xla/tsl/platform:statusor",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest_main",
"@tsl//tsl/platform:errors",
"@tsl//tsl/platform:statusor",
"@tsl//tsl/platform:casts",
"@tsl//tsl/platform:protobuf",
],
)

Expand Down
2 changes: 2 additions & 0 deletions xla/service/cpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ xla_cc_test(
tags = ["not_run:arm"],
deps = [
":cpu_instruction_fusion",
"//xla:literal_util",
"//xla:shape_util",
"//xla:xla_data_proto_cc",
"//xla/hlo/ir:hlo",
Expand Down Expand Up @@ -1539,6 +1540,7 @@ xla_cc_test(
deps = [
":conv_canonicalization",
":target_machine_features_stub",
"//xla:literal_util",
"//xla:test",
"//xla:test_helpers",
"//xla:util",
Expand Down
1 change: 1 addition & 0 deletions xla/service/cpu/conv_canonicalization_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include "xla/hlo/ir/hlo_computation.h"
#include "xla/hlo/ir/hlo_instruction.h"
#include "xla/hlo/ir/hlo_module.h"
#include "xla/literal_util.h"
#include "xla/service/cpu/target_machine_features_stub.h"
#include "xla/test.h"
#include "xla/test_helpers.h"
Expand Down
1 change: 1 addition & 0 deletions xla/service/cpu/cpu_instruction_fusion_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ limitations under the License.
#include "xla/hlo/ir/hlo_instruction.h"
#include "xla/hlo/ir/hlo_opcode.h"
#include "xla/hlo/utils/hlo_matchers.h"
#include "xla/literal_util.h"
#include "xla/service/transpose_folding.h"
#include "xla/shape.h"
#include "xla/tests/hlo_test_base.h"
Expand Down
12 changes: 11 additions & 1 deletion xla/service/hlo_creation_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@ limitations under the License.

#include "xla/service/hlo_creation_utils.h"

#include <cstdint>
#include <memory>

#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/types/span.h"
#include "xla/array2d.h"
#include "xla/hlo/evaluator/hlo_evaluator.h"
#include "xla/hlo/ir/hlo_instruction.h"
#include "xla/hlo/ir/hlo_module.h"
#include "xla/hlo/ir/hlo_opcode.h"
#include "xla/hlo/testlib/verified_hlo_module.h"
#include "xla/literal.h"
#include "xla/literal_util.h"
#include "xla/service/pattern_matcher.h"
#include "xla/service/pattern_matcher_gmock.h"
#include "xla/shape.h"
#include "xla/shape_util.h"
#include "xla/test.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tests/literal_test_util.h"
#include "xla/tsl/platform/statusor.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/test.h"

namespace xla {
namespace {
Expand Down
18 changes: 15 additions & 3 deletions xla/service/hlo_module_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,37 @@ limitations under the License.
#include <vector>

#include <gtest/gtest.h>
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/types/span.h"
#include "xla/comparison_util.h"
#include "xla/debug_options_flags.h"
#include "xla/hlo/ir/hlo_computation.h"
#include "xla/hlo/ir/hlo_instruction.h"
#include "xla/hlo/ir/hlo_opcode.h"
#include "xla/hlo/ir/hlo_original_value.h"
#include "xla/hlo/testlib/verified_hlo_module.h"
#include "xla/hlo/transforms/simplifiers/hlo_memory_scheduler.h"
#include "xla/hlo/utils/hlo_matchers.h"
#include "xla/literal.h"
#include "xla/literal_util.h"
#include "xla/service/buffer_value.h"
#include "xla/service/computation_placer.h"
#include "xla/service/hlo_module_config.h"
#include "xla/service/test_compilation_environment.pb.h"
#include "xla/shape.h"
#include "xla/shape_util.h"
#include "xla/test.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tsl/lib/core/status_test_util.h"
#include "xla/tsl/lib/strings/proto_serialization.h"
#include "xla/tsl/platform/statusor.h"
#include "xla/xla.pb.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/errors.h"
#include "tsl/platform/statusor.h"
#include "tsl/platform/casts.h"
#include "tsl/platform/protobuf.h"

namespace xla {

Expand Down
7 changes: 4 additions & 3 deletions xla/service/hlo_schedule_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ limitations under the License.
#include <gtest/gtest.h>
#include "absl/algorithm/container.h"
#include "absl/log/log.h"
#include "xla/hlo/analysis/hlo_ordering.h"
#include "xla/hlo/ir/hlo_computation.h"
#include "xla/hlo/ir/hlo_instruction.h"
#include "xla/hlo/ir/hlo_opcode.h"
#include "xla/hlo/transforms/simplifiers/hlo_dce.h"
#include "xla/hlo/transforms/simplifiers/hlo_memory_scheduler.h"
#include "xla/literal_util.h"
#include "xla/service/buffer_value.h"
#include "xla/shape.h"
#include "xla/shape_util.h"
#include "xla/test_helpers.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tsl/lib/core/status_test_util.h"
#include "xla/types.h"
#include "xla/tsl/platform/statusor.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/statusor.h"

namespace xla {
namespace {
Expand Down
11 changes: 8 additions & 3 deletions xla/service/triangular_solve_expander_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ limitations under the License.

#include "xla/service/triangular_solve_expander.h"

#include <cstdint>
#include <memory>
#include <string>
#include <utility>

#include "xla/array2d.h"
#include "xla/error_spec.h"
#include "xla/literal.h"
#include "xla/literal_util.h"
#include "xla/reference_util.h"
#include "xla/test.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tsl/lib/core/status_test_util.h"
#include "xla/types.h"
#include "xla/tests/literal_test_util.h"
#include "xla/tsl/platform/statusor.h"
#include "xla/tsl/platform/test.h"

namespace xla {
namespace {
Expand Down
29 changes: 13 additions & 16 deletions xla/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -214,35 +214,27 @@ cc_library(
deps = [
":literal_test_util",
":test_utils",
"//xla:debug_options_flags",
"//xla:error_spec",
"//xla:literal",
"//xla:literal_util",
"//xla:shape_layout",
"//xla:shape_util",
"//xla:test_helpers",
"//xla:util",
"//xla:xla_data_proto_cc",
"//xla/hlo/ir:hlo",
"//xla/hlo/ir:hlo_module_group",
"//xla/hlo/pass:hlo_pass",
"//xla/hlo/testlib:hlo_hardware_independent_test_base",
"//xla/hlo/testlib:verified_hlo_module",
"//xla/hlo/utils:hlo_query",
"//xla/service:backend",
"//xla/service:computation_layout",
"//xla/service:computation_placer_hdr",
"//xla/service:executable",
"//xla/service:hlo_module_config",
"//xla/service:hlo_module_util",
"//xla/service:hlo_runner",
"//xla/service:hlo_runner_interface",
"//xla/service:hlo_verifier",
"//xla/service:interpreter_plugin", # reference backend
"//xla/service:platform_util",
"//xla/stream_executor:device_memory_allocator",
"//xla/tsl/platform:errors",
"//xla/tsl/platform:logging",
"//xla/tsl/platform:statusor",
"//xla/tsl/platform:test",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
Expand All @@ -252,10 +244,7 @@ cc_library(
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
"@llvm-project//llvm:Support",
"@tsl//tsl/platform:errors",
"@tsl//tsl/platform:logging",
"@tsl//tsl/platform:statusor",
"@tsl//tsl/platform:test",
"@tsl//tsl/platform:protobuf",
],
)

Expand Down Expand Up @@ -979,6 +968,8 @@ xla_test(
"//xla/stream_executor:device_description",
"//xla/stream_executor:platform",
"//xla/stream_executor:stream_executor_memory_allocator",
"//xla/tsl/platform:test",
"//xla/tsl/platform:test_benchmark",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
Expand Down Expand Up @@ -1070,7 +1061,10 @@ xla_test(
"//xla/hlo/builder/lib:arithmetic",
"//xla/hlo/builder/lib:matrix",
"//xla/hlo/parser:hlo_parser",
"//xla/service:platform_util",
"//xla/stream_executor:stream_executor_memory_allocator",
"//xla/tsl/platform:test",
"//xla/tsl/platform:test_benchmark",
"@com_google_absl//absl/strings",
"@tsl//tsl/platform:ml_dtypes",
"@tsl//tsl/platform:test",
Expand Down Expand Up @@ -1158,7 +1152,10 @@ xla_test(
"//xla/hlo/builder/lib:arithmetic",
"//xla/hlo/builder/lib:matrix",
"//xla/hlo/parser:hlo_parser",
"//xla/service:platform_util",
"//xla/stream_executor:stream_executor_memory_allocator",
"//xla/tsl/platform:test",
"//xla/tsl/platform:test_benchmark",
"@com_google_absl//absl/strings",
"@tsl//tsl/platform:ml_dtypes",
"@tsl//tsl/platform:test",
Expand Down
6 changes: 3 additions & 3 deletions xla/tests/dot_operation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ limitations under the License.
#include "xla/array3d.h"
#include "xla/client/local_client.h"
#include "xla/error_spec.h"
#include "xla/hlo/builder/lib/arithmetic.h"
#include "xla/hlo/builder/lib/matrix.h"
#include "xla/hlo/builder/xla_builder.h"
#include "xla/hlo/parser/hlo_parser.h"
#include "xla/literal_util.h"
#include "xla/primitive_util.h"
#include "xla/reference_util.h"
#include "xla/service/platform_util.h"
#include "xla/shape_util.h"
#include "xla/stream_executor/stream_executor_memory_allocator.h"
#include "xla/tests/client_library_test_base.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tests/test_macros.h"
#include "xla/tsl/platform/test.h"
#include "xla/tsl/platform/test_benchmark.h"
#include "tsl/platform/ml_dtypes.h"
#include "tsl/platform/test.h"
#include "tsl/platform/test_benchmark.h"

#if TENSORFLOW_USE_ROCM
#include "rocm/rocm_config.h"
Expand Down
Loading

0 comments on commit e457606

Please sign in to comment.