load("//tensorflow/compiler/xla:xla.bzl", "xla_cc_binary")
load("//tensorflow/tsl:tsl.default.bzl", "get_compatible_with_portable")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

package_group(
    name = "friends",
    packages = [
        # copybara:uncomment_begin(google-only)
        # "//platforms/xla/service/cpu/...",
        # "//third_party/mlir_edge/tpgen/...",
        # # TODO(ezhulenev): Clean up dependencies that are leftovers from Autofusion project.
        # "@tf_runtime//...",
        # "//third_party/tf_runtime_google/...",
        # copybara:uncomment_end(google-only)
        "//tensorflow/compiler/mlir/tfrt/...",
        "//tensorflow/compiler/xla/mlir/...",
        "//tensorflow/compiler/xla/runtime/...",
        # TODO(ezhulenev): All targets depending on mlir must be under xla/mlir folder
        "//tensorflow/compiler/xla/service/cpu/...",
        "//tensorflow/compiler/xla/service/gpu/...",
    ],
)

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

build_test(
    name = "xla-runtime-opt_build_test",
    targets = [
        ":xla-runtime-opt",
    ],
)

xla_cc_binary(
    name = "xla-runtime-opt",
    srcs = ["xla-runtime-opt.cc"],
    compatible_with = get_compatible_with_portable(),
    deps = [
        "//tensorflow/compiler/xla/mlir/math/transforms:passes",
        "//tensorflow/compiler/xla/mlir/memref/transforms:passes",
        "//tensorflow/compiler/xla/mlir/runtime/ir/tests:testlib",
        "//tensorflow/compiler/xla/mlir/runtime/transforms:compilation_pipeline_cpu",
        "//tensorflow/compiler/xla/mlir/runtime/transforms:compilation_pipeline_gpu",
        "//tensorflow/compiler/xla/mlir/runtime/transforms:passes",
        "@llvm-project//mlir:AsyncDialect",
        "@llvm-project//mlir:FuncDialect",
        "@llvm-project//mlir:FuncExtensions",
        "@llvm-project//mlir:MathDialect",
        "@llvm-project//mlir:MemRefDialect",
        "@llvm-project//mlir:MlirOptLib",
    ],
)
