package(
    # copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
    default_visibility = ["//xla:internal"],
    licenses = ["notice"],
)

cc_library(
    name = "opt_main",
    testonly = True,
    srcs = ["opt_main.cc"],
    deps = [
        ":opt_lib",
        "//xla:debug_options_flags",
        "//xla/hlo/ir:hlo",
        "//xla/service:hlo_module_config",
        "//xla/service:hlo_proto_util",
        "//xla/tools:hlo_module_loader",
        "//xla/tsl/platform:env",
        "//xla/tsl/platform:errors",
        "//xla/tsl/platform:statusor",
        "//xla/tsl/util:command_line_flags",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@local_tsl//tsl/platform:path",
        "@local_tsl//tsl/platform:platform_port",
    ],
)

# Includes a macro to register a provider.
cc_library(
    name = "opt_lib",
    testonly = True,
    srcs = ["opt_lib.cc"],
    hdrs = ["opt_lib.h"],
    deps = [
        "//xla:literal_pool",
        "//xla:shape_util",
        "//xla:xla_data_proto_cc",
        "//xla/hlo/analysis:alias_info",
        "//xla/hlo/analysis:indexed_array_analysis",
        "//xla/hlo/ir:hlo",
        "//xla/hlo/pass:hlo_pass_pipeline",
        "//xla/hlo/tools/tests:hlo_opt_test_only_passes",
        "//xla/hlo/transforms:add_original_value",
        "//xla/hlo/transforms:bfloat16_propagation",
        "//xla/hlo/transforms:convert_memory_placement_to_internal_annotations",
        "//xla/hlo/transforms:defuser",
        "//xla/hlo/transforms:despecializer",
        "//xla/hlo/transforms:host_offload_legalize",
        "//xla/hlo/transforms:host_offloading_prepare",
        "//xla/hlo/transforms:literal_canonicalizer",
        "//xla/hlo/transforms:memory_space_propagation",
        "//xla/hlo/transforms:operand_upcaster",
        "//xla/hlo/transforms:while_loop_trip_count_annotator",
        "//xla/hlo/transforms/collectives:all_gather_broadcast_reorder",
        "//xla/hlo/transforms/collectives:all_gather_combiner",
        "//xla/hlo/transforms/collectives:all_gather_cse",
        "//xla/hlo/transforms/collectives:all_reduce_combiner",
        "//xla/hlo/transforms/collectives:all_reduce_contiguous",
        "//xla/hlo/transforms/collectives:async_collective_creator",
        "//xla/hlo/transforms/collectives:collective_quantizer",
        "//xla/hlo/transforms/collectives:collective_transformation_reorderer",
        "//xla/hlo/transforms/collectives:collectives_schedule_linearizer",
        "//xla/hlo/transforms/collectives:convert_async_collectives_to_sync",
        "//xla/hlo/transforms/collectives:infeed_token_propagation",
        "//xla/hlo/transforms/collectives:while_loop_all_reduce_code_motion_setup",
        "//xla/hlo/transforms/expanders:cholesky_expander",
        "//xla/hlo/transforms/expanders:comparison_expander",
        "//xla/hlo/transforms/expanders:convolution_4d_expander",
        "//xla/hlo/transforms/expanders:convolution_pred_expander",
        "//xla/hlo/transforms/expanders:dot_decomposer",
        "//xla/hlo/transforms/expanders:dynamic_index_splitter",
        "//xla/hlo/transforms/expanders:eigh_expander",
        "//xla/hlo/transforms/expanders:logistic_expander",
        "//xla/hlo/transforms/expanders:optimization_barrier_expander",
        "//xla/hlo/transforms/expanders:qr_expander",
        "//xla/hlo/transforms/expanders:real_imag_expander",
        "//xla/hlo/transforms/expanders:reduce_decomposer",
        "//xla/hlo/transforms/expanders:reshape_decomposer",
        "//xla/hlo/transforms/expanders:rng_bit_generator_expander",
        "//xla/hlo/transforms/expanders:rng_expander",
        "//xla/hlo/transforms/expanders:stable_sort_expander",
        "//xla/hlo/transforms/expanders:stochastic_convert_decomposer",
        "//xla/hlo/transforms/simplifiers:algebraic_simplifier",
        "//xla/hlo/transforms/simplifiers:all_reduce_folder",
        "//xla/hlo/transforms/simplifiers:ar_crs_combiner",
        "//xla/hlo/transforms/simplifiers:batch_dot_simplification",
        "//xla/hlo/transforms/simplifiers:bfloat16_conversion_folding",
        "//xla/hlo/transforms/simplifiers:broadcast_canonicalizer",
        "//xla/hlo/transforms/simplifiers:conditional_canonicalizer",
        "//xla/hlo/transforms/simplifiers:convert_mover",
        "//xla/hlo/transforms/simplifiers:convert_operand_folding",
        "//xla/hlo/transforms/simplifiers:convolution_group_converter",
        "//xla/hlo/transforms/simplifiers:dot_dimension_merger",
        "//xla/hlo/transforms/simplifiers:dot_merger",
        "//xla/hlo/transforms/simplifiers:dynamic_dimension_simplifier",
        "//xla/hlo/transforms/simplifiers:flatten_call_graph",
        "//xla/hlo/transforms/simplifiers:float_normalization",
        "//xla/hlo/transforms/simplifiers:fusion_constant_sinking",
        "//xla/hlo/transforms/simplifiers:gather_simplifier",
        "//xla/hlo/transforms/simplifiers:hlo_computation_deduplicator",
        "//xla/hlo/transforms/simplifiers:hlo_constant_folding",
        "//xla/hlo/transforms/simplifiers:hlo_constant_splitter",
        "//xla/hlo/transforms/simplifiers:hlo_dce",
        "//xla/hlo/transforms/simplifiers:hlo_element_type_converter",
        "//xla/hlo/transforms/simplifiers:hlo_memory_scheduler",
        "//xla/hlo/transforms/simplifiers:host_memory_transfer_asyncifier",
        "//xla/hlo/transforms/simplifiers:instruction_hoister",
        "//xla/hlo/transforms/simplifiers:optimize_input_output_buffer_alias",
        "//xla/hlo/transforms/simplifiers:reduce_window_rewriter",
        "//xla/hlo/transforms/simplifiers:reshape_mover",
        "//xla/hlo/transforms/simplifiers:result_caster",
        "//xla/hlo/transforms/simplifiers:root_instruction_sinker",
        "//xla/hlo/transforms/simplifiers:simplify_fp_conversions",
        "//xla/hlo/transforms/simplifiers:slice_sinker",
        "//xla/hlo/transforms/simplifiers:sort_simplifier",
        "//xla/hlo/transforms/simplifiers:sub_byte_normalization",
        "//xla/hlo/transforms/simplifiers:tree_reduction_rewriter",
        "//xla/hlo/transforms/simplifiers:tuple_simplifier",
        "//xla/hlo/transforms/simplifiers:zero_sized_hlo_elimination",
        "//xla/service:buffer_value",
        "//xla/service:dump",
        "//xla/service:float_support",
        "//xla/service:platform_util",
        "//xla/stream_executor/platform:initialize",
        "//xla/tsl/platform:statusor",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/synchronization",
    ],
)
