#
# Public targets:
#  ":platform" - Low-level and platform-specific Python code.

load("//tensorflow:tensorflow.bzl", "py_strict_library")
load("//tensorflow:tensorflow.bzl", "cc_header_only_library", "if_mlir", "if_xla_available", "py_test", "tf_enable_mlir_bridge")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "tf_monitoring_python_deps")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "tf_python_pybind_extension")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "pywrap_tensorflow_macro")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "cuda_py_test")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "tf_external_workspace_visible")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "tf_pybind_cc_library_wrapper")

# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "tf_py_test")
load("//tensorflow/core/platform:build_config.bzl", "pyx_library", "tf_additional_all_protos", "tf_additional_lib_deps", "tf_proto_library", "tf_protos_grappler")  # @unused
load("//tensorflow/core/platform:build_config_root.bzl", "if_static", "tf_additional_plugin_deps", "tf_additional_profiler_deps")
load("//tensorflow/python:build_defs.bzl", "tf_gen_op_wrapper_private_py")

# TODO(mdan): Break into per-directory files.

visibility = [
    "//engedu/ml/tf_from_scratch:__pkg__",
    "//third_party/cloud_tpu/convergence_tools:__subpackages__",
    "//third_party/mlperf:__subpackages__",
    "//tensorflow:internal",
    "//tensorflow/lite/toco/python:__pkg__",
    "//tensorflow_models:__subpackages__",
    "//tensorflow_model_optimization:__subpackages__",
    "//third_party/py/cleverhans:__subpackages__",
    "//third_party/courier:__subpackages__",
    "//third_party/py/courier:__subpackages__",
    "//third_party/py/reverb:__subpackages__",
    "//third_party/py/neural_structured_learning:__subpackages__",
    "//third_party/py/tensorflow_examples:__subpackages__",
    "//third_party/py/tf_agents:__subpackages__",  # For benchmarks.
    "//third_party/py/tf_slim:__subpackages__",
    "//third_party/py/tensorflow_docs:__subpackages__",
    "//third_party/py/keras:__subpackages__",
    "//third_party/py/tensorflow_gnn:__subpackages__",
    "//third_party/py/tensorflow_numerics:__subpackages__",
]

package(
    default_visibility = visibility,
    licenses = ["notice"],
)

# Description:

py_library(
    name = "python",
    srcs = ["__init__.py"],
    srcs_version = "PY3",
    visibility = [
        "//tensorflow:__pkg__",
        "//tensorflow/compiler/aot/tests:__pkg__",  # TODO(b/34059704): remove when fixed
        "//tensorflow/lite/toco/python:__pkg__",  # TODO(b/34059704): remove when fixed
        "//tensorflow/python/debug:__subpackages__",
        "//tensorflow/python/tools:__pkg__",  # TODO(b/34059704): remove when fixed
        "//tensorflow/tools/quantization:__pkg__",  # TODO(b/34059704): remove when fixed
    ],
    deps = [
        ":no_contrib",
        "//tensorflow/python/estimator:estimator_py",
        "//tensorflow/python/tpu:tpu_estimator",
    ],
)

py_library(
    name = "keras_lib",
    srcs_version = "PY3",
    visibility = [
        "//tensorflow:__pkg__",
        "//tensorflow:internal",
        "//tensorflow/python/estimator:__subpackages__",
        "//tensorflow/python/keras:__subpackages__",
        "//tensorflow/python/tools:__pkg__",
        "//tensorflow/python/tools/api/generator:__pkg__",
        "//tensorflow/tools/api/tests:__pkg__",
        "//tensorflow/tools/compatibility/update:__pkg__",
        "//tensorflow_estimator:__subpackages__",
        "//third_party/py/tensorflow_privacy:__subpackages__",  # TODO(b/163395075): remove when fixed
    ],
    deps = [
        ":layers",
        ":rnn",
        "//tensorflow/python/feature_column:feature_column_py",
        "//tensorflow/python/keras",
    ],
)

py_library(
    name = "no_contrib",
    srcs = ["__init__.py"],
    srcs_version = "PY3",
    visibility = [
        "//tensorflow:__pkg__",
        "//tensorflow/python/estimator:__subpackages__",
        "//tensorflow/python/keras:__subpackages__",
        "//tensorflow/python/tools:__pkg__",
        "//tensorflow/python/tools/api/generator:__pkg__",
        "//tensorflow/tools/api/tests:__pkg__",
        "//tensorflow/tools/compatibility/update:__pkg__",
        "//third_party/py/keras:__subpackages__",
        "//third_party/py/tensorflow_core:__subpackages__",
    ],
    deps = [
        ":_pywrap_py_exception_registry",
        ":_pywrap_quantize_training",
        ":_pywrap_utils",
        ":array_ops",
        ":audio_ops_gen",
        ":bincount_ops",
        ":bitwise_ops",
        ":boosted_trees_ops",
        ":check_ops",
        ":client_testlib",
        ":clustering_ops",
        ":collective_ops",
        ":composite_tensor_ops",
        ":cond_v2",
        ":confusion_matrix",
        ":control_flow_ops",
        ":cudnn_rnn_ops_gen",
        ":distributed_framework_test_lib",
        ":functional_ops",
        ":gradient_checker",
        ":gradient_checker_v2",
        ":histogram_ops",
        ":image_ops",
        ":initializers_ns",
        ":io_ops",
        ":keras_lib",
        ":lib",
        ":list_ops",
        ":manip_ops",
        ":map_fn",
        ":map_ops",
        ":math_ops",
        ":metrics",
        ":nccl_ops",
        ":nn",
        ":ops",
        ":platform",
        ":proto_ops",
        ":pywrap_tensorflow",
        ":pywrap_tfe",
        ":rnn_ops_gen",
        ":script_ops",
        ":sendrecv_ops_gen",
        ":session_ops",
        ":sets",
        ":sparse_ops",
        ":standard_ops",
        ":state_ops",
        ":string_ops",
        ":tensor_array_ops",
        ":training",
        ":weights_broadcast_ops",
        ":while_v2",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/lite/python:lite",
        "//tensorflow/python/client",
        "//tensorflow/python/client:_pywrap_events_writer",
        "//tensorflow/python/client:pywrap_tf_session",
        "//tensorflow/python/compat",
        "//tensorflow/python/compat:v2_compat",
        "//tensorflow/python/compiler",
        "//tensorflow/python/data",
        "//tensorflow/python/debug:debug_py",
        "//tensorflow/python/distribute",
        "//tensorflow/python/distribute:combinations",  # For tf.__internal__ API.
        "//tensorflow/python/distribute:distribute_config",
        "//tensorflow/python/distribute:estimator_training",
        "//tensorflow/python/distribute:strategy_combinations",  # For tf.__internal__,
        "//tensorflow/python/dlpack",
        "//tensorflow/python/eager:def_function",
        "//tensorflow/python/eager:monitoring",
        "//tensorflow/python/eager:profiler",
        "//tensorflow/python/eager:profiler_client",
        "//tensorflow/python/eager:remote",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:_pywrap_python_op_gen",
        "//tensorflow/python/framework:combinations",
        "//tensorflow/python/framework:config",
        "//tensorflow/python/framework:errors",
        "//tensorflow/python/framework:extension_type",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:graph_util",
        "//tensorflow/python/framework:kernels",
        "//tensorflow/python/framework:subscribe",
        "//tensorflow/python/framework:test_ops",  # TODO(b/183988750): Break testing code out into separate rule.
        "//tensorflow/python/grappler:tf_cluster",
        "//tensorflow/python/grappler:tf_item",
        "//tensorflow/python/grappler:tf_optimizer",
        "//tensorflow/python/module",
        "//tensorflow/python/ops/distributions",
        "//tensorflow/python/ops/linalg",
        "//tensorflow/python/ops/linalg/sparse",
        "//tensorflow/python/ops/losses",
        "//tensorflow/python/ops/numpy_ops:numpy",
        "//tensorflow/python/ops/parallel_for",
        "//tensorflow/python/ops/ragged",
        "//tensorflow/python/ops/signal",
        "//tensorflow/python/platform:_pywrap_stacktrace_handler",
        "//tensorflow/python/profiler",
        "//tensorflow/python/profiler:profiler_client",
        "//tensorflow/python/profiler:profiler_v2",
        "//tensorflow/python/profiler:trace",
        "//tensorflow/python/saved_model",
        "//tensorflow/python/summary",
        "//tensorflow/python/summary/writer",
        "//tensorflow/python/tools:module_util",
        "//tensorflow/python/tools/api/generator:create_python_api",
        "//tensorflow/python/tpu:tpu_noestimator",
        "//tensorflow/python/training:saver_test_utils",
        "//tensorflow/python/types",
        "//tensorflow/python/util",
        "//tensorflow/python/util:_pywrap_checkpoint_reader",
        "//tensorflow/python/util:_pywrap_kernel_registry",
        "//tensorflow/python/util:_pywrap_nest",
        "//tensorflow/python/util:_pywrap_stat_summarizer",
        "//tensorflow/python/util:_pywrap_tfprof",
        "//tensorflow/python/util:_pywrap_transform_graph",
        "//tensorflow/python/util:_pywrap_util_port",
        "//third_party/py/numpy",
    ],
)

py_strict_library(
    name = "core",
    visibility = [
        "//tensorflow:__pkg__",
    ],
    deps = [
        "//tensorflow/python/types",
        "//tensorflow/python/util:core",
    ],
)

# This target should only be used for API generation.
py_library(
    name = "modules_with_exports",
    srcs = ["modules_with_exports.py"],
    srcs_version = "PY3",
    visibility = [
        "//tensorflow:__pkg__",
        "//tensorflow/python/tools/api/generator:__pkg__",
        "//third_party/py/tensorflow_core:__subpackages__",
    ],
    deps = [
        ":no_contrib",
        "//tensorflow/python/distribute:multi_process_runner",
        "//tensorflow/python/distribute:multi_worker_test_base",
    ],
)

alias(
    name = "util",
    actual = "//tensorflow/python/util:util",
    visibility = visibility + [
        "//tensorflow:__pkg__",
        "//third_party/py/tensorflow_core:__subpackages__",
        "//third_party/py/tf_agents:__subpackages__",
        "//third_party/py/tfx:__subpackages__",
    ],
)

alias(
    name = "tf_decorator",
    actual = "//tensorflow/python/util:tf_decorator",
)

alias(
    name = "bfloat16_lib",
    actual = "//tensorflow/python/lib/core:bfloat16_lib",
)

# Necessary for the pywrap inclusion below.
tf_pybind_cc_library_wrapper(
    name = "tfcompile_headers_lib",
    compatible_with = [],
    deps = [
        "//tensorflow/compiler/aot:tfcompile_lib",
    ],
)

tf_python_pybind_extension(
    name = "_pywrap_tfcompile",
    srcs = ["tfcompile_wrapper.cc"],
    features = ["-layering_check"],
    module_name = "_pywrap_tfcompile",
    deps = [
        ":tfcompile_headers_lib",
        "@pybind11",
        "//third_party/python_runtime:headers",
        "//tensorflow/python/lib/core:pybind11_lib",
        "//tensorflow/python/lib/core:pybind11_status",
        # The headers here cannot be brought in via cc_header_only_library
        "//tensorflow/compiler/aot:llvm_targets",
    ],
)

alias(
    name = "pywrap_tf_session",
    actual = "//tensorflow/python/client:pywrap_tf_session",
)

alias(
    name = "_pywrap_utils",
    actual = "//tensorflow/python/util:_pywrap_utils",
)

tf_python_pybind_extension(
    name = "_pywrap_quantize_training",
    srcs = [
        "//tensorflow/python/training:quantize_training_wrapper.cc",
    ],
    hdrs = ["//tensorflow/core/common_runtime:quantize_training_hdrs"],
    module_name = "_pywrap_quantize_training",
    deps = [
        "//tensorflow/core:framework_headers_lib",
        "//tensorflow/core:lib_headers_for_pybind",
        "//tensorflow/core:protos_all_cc",
        "//tensorflow/core/common_runtime:core_cpu_headers_lib",
        "//tensorflow/python/lib/core:pybind11_lib",
        "//tensorflow/python/lib/core:pybind11_proto",
        "//tensorflow/python/lib/core:pybind11_status",
        "//third_party/python_runtime:headers",
        "@com_google_absl//absl/strings",
        "@pybind11",
    ],
)

# TODO(yanhuasun): Move this back and the source file back to lib/core directory.
tf_python_pybind_extension(
    name = "_pywrap_py_exception_registry",
    srcs = ["py_exception_registry_wrapper.cc"],
    hdrs = [
        "//tensorflow/c:headers",
        "//tensorflow/c/eager:headers",
        "//tensorflow/python/lib/core:py_exception_registry_hdr",
    ],
    module_name = "_pywrap_py_exception_registry",
    deps = [
        "//tensorflow/core:protos_all_cc",
        "//tensorflow/core/platform:status",
        "//third_party/python_runtime:headers",
        "@com_google_absl//absl/container:fixed_array",
        "@pybind11",
    ],
)

tf_python_pybind_extension(
    name = "_pywrap_toco_api",
    srcs = [
        "lite/toco_python_api_wrapper.cc",
    ],
    hdrs = ["//tensorflow/lite/toco/python:toco_python_api_hdrs"],
    module_name = "_pywrap_toco_api",
    deps = [
        "//tensorflow/python/lib/core:pybind11_lib",
        "//third_party/python_runtime:headers",
        "@pybind11",
    ],
)

# TODO(edloper): Remove unused dependency on safe_ptr.  (Blocker: there are
# targets that depend are relying on cpp_python_util to pull in safe_ptr's
# third_party/tensorflow/c:c_api_no_xla dependency, which registers
# ops/gradients, rather than depending on it themselves.)
cc_header_only_library(
    name = "py_func_headers_lib",
    features = ["-parse_headers"],
    tags = ["no-ide"],
    deps = [
        "//tensorflow/python/lib/core:py_func_lib",
    ],
)

cc_header_only_library(
    name = "python_op_gen_headers_lib",
    extra_deps = [
        "//tensorflow/core:protos_all_cc",
    ],
    features = ["-parse_headers"],
    tags = ["no-ide"],
    deps = [
        "//tensorflow/python/framework:python_op_gen",
    ],
)

py_library(
    name = "map_fn",
    srcs = ["ops/map_fn.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":tensor_array_ops",
        ":variable_scope",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "extra_py_tests_deps",
    srcs_version = "PY3",
    deps = [
        ":keras_lib",
        "//third_party/py/numpy",
        "@six_archive//:six",
    ],
)

py_library(
    name = "distributed_framework_test_lib",
    srcs_version = "PY3",
    deps = ["//tensorflow/python/framework:test_lib"],
)

tf_gen_op_wrapper_private_py(
    name = "functional_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

py_library(
    name = "functional_ops",
    srcs = ["ops/functional_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":functional_ops_gen",
        ":tensor_array_ops",
        ":variable_scope",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:auto_control_deps_utils",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
    ],
)

py_test(
    name = "functional_ops_test",
    srcs = ["ops/functional_ops_test.py"],
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        ":client_testlib",
        ":functional_ops",
        "//tensorflow/python/eager:def_function",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:function",
        "//tensorflow/python/framework:tensor_spec",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "debug_ops_gen",
    out = "ops/gen_debug_ops.py",
    visibility = [
        "//tensorflow/python/debug:__subpackages__",
    ],
    deps = ["//tensorflow/core:debug_ops_op_lib"],
)

tf_gen_op_wrapper_private_py(
    name = "array_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/compiler/tests:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/kernel_tests/v1_compat_tests:__pkg__",
        "//tensorflow/python/training:__pkg__",
    ],
    deps = [
        "//tensorflow/c/kernels:bitcast_op_lib",
        "//tensorflow/core:array_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "bitwise_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/compiler/tests:__pkg__",
        "//tensorflow/contrib/quantization:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "boosted_trees_ops_gen",
    visibility = ["//tensorflow:internal"],
    deps = [
        "//tensorflow/core:boosted_trees_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "summary_ops_gen",
    visibility = ["//tensorflow:__subpackages__"],
    deps = ["//tensorflow/core:summary_ops_op_lib"],
)

tf_gen_op_wrapper_private_py(
    name = "audio_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "cudnn_rnn_ops_gen",
    visibility = [
        "//tensorflow:__subpackages__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "candidate_sampling_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "checkpoint_ops_gen",
    visibility = [
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/training:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "clustering_ops_gen",
    visibility = ["//tensorflow:internal"],
    deps = [
        "//tensorflow/core:clustering_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "collective_ops_gen",
    visibility = ["//tensorflow:internal"],
    deps = [
        "//tensorflow/core:collective_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "control_flow_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
    ],
    deps = [
        "//tensorflow/core:control_flow_ops_op_lib",
        "//tensorflow/core:no_op_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "ctc_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "data_flow_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/training:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "dataset_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow:__subpackages__",
        "//tensorflow/python/kernel_tests:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "experimental_dataset_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow:__subpackages__",
        "//tensorflow/python/kernel_tests:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "image_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "io_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/training:__pkg__",
        "//tensorflow/python/training/tracking:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "linalg_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "logging_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/framework:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/summary:__pkg__",
        "//tensorflow/python/summary/writer:__pkg__",
    ],
    deps = [
        "//tensorflow/c/kernels:histogram_summary_op_lib",
        "//tensorflow/c/kernels:merge_summary_op_lib",
        "//tensorflow/c/kernels:summary_op_lib",
        "//tensorflow/core:logging_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "lookup_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/training:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "batch_ops_gen",
    visibility = [
        "//tensorflow:__subpackages__",
    ],
)

py_library(
    name = "batch_ops",
    srcs = [
        "ops/batch_ops.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":batch_ops_gen",
    ],
)

cuda_py_test(
    name = "batch_ops_test",
    size = "small",
    srcs = ["ops/batch_ops_test.py"],
    python_version = "PY3",
    srcs_version = "PY3",
    tags = [
        "manual",
        "no_cuda_asan",  # b/177916286
        "no_pip",
        "nomac",
    ],
    deps = [
        ":array_ops",
        ":batch_ops",
        ":client_testlib",
        ":gradients",
        ":script_ops",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:dtypes",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "manip_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "math_ops_gen",
    visibility = [
        "//learning/brain/google/python/ops:__pkg__",
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/compiler/tests:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "nn_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/compiler/tests:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/tools:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "count_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "parsing_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "random_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "special_math_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "stateful_random_ops_gen",
    visibility = ["//learning/brain/python/ops:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "resource_variable_ops_gen",
    visibility = [
        "//tensorflow/compiler/tf2xla:internal",
        "//tensorflow/python/distribute:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "stateless_random_ops_gen",
    visibility = [
        "//tensorflow/python/data/experimental/ops:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "stateless_random_ops_v2_gen",
)

tf_gen_op_wrapper_private_py(
    name = "list_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "map_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "script_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "sdca_ops_gen",
    visibility = ["//tensorflow_estimator/python/estimator/canned/linear_optimizer:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "set_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "state_ops_gen",
    visibility = [
        "//learning/brain/python/ops:__pkg__",
        "//tensorflow/python/framework:__pkg__",
        "//tensorflow/python/kernel_tests:__pkg__",
        "//tensorflow/python/training:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "sparse_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "spectral_ops_gen",
    visibility = ["//tensorflow/python/ops/signal:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "string_ops_gen",
)

tf_gen_op_wrapper_private_py(
    name = "training_ops_gen",
    visibility = [
        "//tensorflow/python/training:__pkg__",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "composite_tensor_ops_gen",
    visibility = [],
)

tf_gen_op_wrapper_private_py(
    name = "ragged_array_ops_gen",
    visibility = ["//tensorflow/python/ops/ragged:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "ragged_math_ops_gen",
    visibility = ["//tensorflow/python/ops/ragged:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "ragged_conversion_ops_gen",
    visibility = ["//tensorflow/python/ops/ragged:__pkg__"],
)

tf_gen_op_wrapper_private_py(
    name = "risc_ops_gen",
    visibility = [
        "//tensorflow/python/ops/risc:__pkg__",
    ],
    deps = [
        "//tensorflow/core:risc_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(name = "rnn_ops_gen")

tf_gen_op_wrapper_private_py(
    name = "sendrecv_ops_gen",
    visibility = ["//tensorflow:internal"],
    deps = [
        "//tensorflow/core:sendrecv_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "tpu_ops_gen",
    visibility = [
        "//smartass/brain/configure/python:__pkg__",
        "//tensorflow/python/tpu:__pkg__",
        "//tensorflow/python/tpu/ops:__pkg__",
    ],
    deps = [
        "//tensorflow/core:tpu_configuration_ops_op_lib",
        "//tensorflow/core:tpu_cross_replica_ops_op_lib",
        "//tensorflow/core:tpu_embedding_load_retrieve_ops_op_lib",
        "//tensorflow/core:tpu_embedding_ops_op_lib",
        "//tensorflow/core:tpu_functional_ops_op_lib",
        "//tensorflow/core:tpu_heartbeat_ops_op_lib",
        "//tensorflow/core:tpu_host_compute_ops_op_lib",
        "//tensorflow/core:tpu_infeed_ops_op_lib",
        "//tensorflow/core:tpu_ordinal_selector_ops_op_lib",
        "//tensorflow/core:tpu_outfeed_ops_op_lib",
        "//tensorflow/core:tpu_replication_ops_op_lib",
    ],
)

py_library(
    name = "array_grad",
    srcs = ["ops/array_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":array_ops_gen",
        ":math_ops",
        ":sparse_ops",
        "//tensorflow/compiler/tf2xla/ops:gen_xla_ops",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "array_grad_test",
    srcs = ["ops/array_grad_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":gradients",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "array_ops",
    srcs = [
        "ops/array_ops.py",
        "ops/inplace_ops.py",
    ],
    srcs_version = "PY3",
    visibility = visibility,
    deps = [
        ":array_ops_gen",
        ":math_ops_gen",
        "//tensorflow/python/framework:common_shapes",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/framework:tensor_util",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
        "@six_archive//:six",
    ],
)

py_library(
    name = "bitwise_ops",
    srcs = ["ops/bitwise_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":bitwise_ops_gen",
        "//tensorflow/python/framework",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "boosted_trees_ops",
    srcs = ["ops/boosted_trees_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":boosted_trees_ops_gen",
        ":ops",
        ":training",
        "//tensorflow/core/kernels/boosted_trees:boosted_trees_proto_py",
        "//tensorflow/python/framework",
    ],
)

py_library(
    name = "optional_grad",
    srcs = ["ops/optional_grad.py"],
    srcs_version = "PY3",
    deps = [
        "//tensorflow/python/framework:ops",
    ],
)

py_library(
    name = "sets",
    srcs = [
        "ops/sets.py",
        "ops/sets_impl.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":set_ops_gen",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "candidate_sampling_ops",
    srcs = ["ops/candidate_sampling_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":candidate_sampling_ops_gen",
        ":math_ops",
        "//tensorflow/python/framework",
    ],
)

py_library(
    name = "check_ops",
    srcs = ["ops/check_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:tensor_util",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "clip_ops",
    srcs = ["ops/clip_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        ":nn_ops_gen",
        ":numerics",
        "//tensorflow/python/framework:for_generated_wrappers",
        "@six_archive//:six",
    ],
)

tf_py_test(
    name = "clip_ops_test",
    size = "small",
    srcs = ["ops/clip_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":clip_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "clustering_ops",
    srcs = ["ops/clustering_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":clustering_ops_gen",
        ":ops",
        ":training",
        "//tensorflow/python/framework",
    ],
)

tf_py_test(
    name = "clustering_ops_test",
    size = "medium",
    srcs = ["ops/clustering_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":clustering_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "collective_ops",
    srcs = ["ops/collective_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":collective_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

tf_py_test(
    name = "collective_ops_test",
    size = "small",
    srcs = ["ops/collective_ops_test.py"],
    python_version = "PY3",
    tags = [
        "no_rocm",
    ],
    deps = [
        ":client_testlib",
        ":collective_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:kernels",
        "//third_party/py/numpy",
    ],
)

tf_py_test(
    name = "collective_ops_xla_test",
    size = "small",
    srcs = ["ops/collective_ops_xla_test.py"],
    python_version = "PY3",
    tags = [
        "no_pip",
        "no_rocm",
        "no_windows",
        "nomac",
    ],
    xla_enable_strict_auto_jit = True,
    deps = [
        ":client_testlib",
        ":collective_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:kernels",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "collective_ops_gpu_test",
    size = "small",
    srcs = ["ops/collective_ops_gpu_test.py"],
    python_version = "PY3",
    tags = [
        "guitar",
        "multi_gpu",
        "no_windows",
    ],
    deps = [
        ":client_testlib",
        ":collective_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "control_flow_grad",
    srcs =
        ["ops/control_flow_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":control_flow_ops",
        ":control_flow_ops_gen",
        ":control_flow_util",
        ":math_ops",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

# Note: targets depending on this should also depend on ":cond_v2" and ":while_v2".
# See b/118513001.
py_library(
    name = "control_flow_ops",
    srcs = ["ops/control_flow_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":array_ops_gen",
        ":control_flow_ops_gen",
        ":control_flow_util",
        ":logging_ops_gen",
        ":math_ops",
        ":platform",
        ":tensor_array_ops",
        ":tf2",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
        "//tensorflow/python/util:tf_should_use",
        "@six_archive//:six",
    ],
)

py_library(
    name = "control_flow_util",
    srcs = ["ops/control_flow_util.py"],
    srcs_version = "PY3",
    deps = [
        ":platform",
    ],
)

py_library(
    name = "control_flow_util_v2",
    srcs = ["ops/control_flow_util_v2.py"],
    srcs_version = "PY3",
    deps = [
        ":control_flow_util",
        ":control_flow_v2_func_graphs",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/distribute:distribute_lib",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/eager:function",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "control_flow_v2_func_graphs",
    srcs = ["ops/control_flow_v2_func_graphs.py"],
    srcs_version = "PY3",
    deps = [
        "//tensorflow/python/framework:func_graph",
    ],
)

py_library(
    name = "control_flow_v2_toggles",
    srcs = ["ops/control_flow_v2_toggles.py"],
    srcs_version = "PY3",
    deps = [
        ":control_flow_util",
        ":control_flow_util_v2",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/util",
    ],
)

tf_py_test(
    name = "control_flow_v2_toggles_test",
    size = "small",
    srcs = ["ops/control_flow_v2_toggles_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":control_flow_util_v2",
        ":control_flow_v2_toggles",
        ":platform_test",
    ],
)

tf_py_test(
    name = "control_flow_v2_enable_test",
    size = "small",
    srcs = ["ops/control_flow_v2_enable_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":control_flow_util",
        ":platform_test",
        ":tf2",
    ],
)

tf_py_test(
    name = "control_flow_v2_disable_test",
    size = "small",
    srcs = ["ops/control_flow_v2_disable_test.py"],
    python_version = "PY3",
    # This tests that it is possible to disable cfv2 using env vars.
    # This does not apply to TF 2.0 nightly builds which enable
    # v2 behavior using `tf.compat.v1.enable_v2_behavior()` in which case
    # `tf.compat.v1.disable_control_flow_v2()` needs to be used.
    tags = [
        "no_oss",
        "no_pip",
    ],
    deps = [
        ":client_testlib",
        ":control_flow_util",
        ":platform_test",
        ":tf2",
    ],
)

py_library(
    name = "cond_v2",
    srcs = [
        "ops/cond_v2.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_util_v2",
        ":functional_ops_gen",
        ":gradients_util",
        ":handle_data_util",
        ":pywrap_tensorflow",
        "//tensorflow/python/compat",
        "//tensorflow/python/data/ops:dataset_ops",
        "//tensorflow/python/eager:function",
        "//tensorflow/python/framework:auto_control_deps_utils",
        "//tensorflow/python/framework:c_api_util",
        "//tensorflow/python/framework:function",
        "//tensorflow/python/framework:function_def_to_graph",
        "//tensorflow/python/framework:graph_to_function_def",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "while_v2",
    srcs = [
        "ops/while_v2.py",
        "ops/while_v2_indexed_slices_rewriter.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":control_flow_util",
        ":control_flow_util_v2",
        ":functional_ops_gen",
        ":gradients_util",
        ":handle_data_util",
        ":list_ops",
        ":map_ops",
        ":tensor_array_ops",
        "//tensorflow/python/client:pywrap_tf_session",
        "//tensorflow/python/eager:function",
        "//tensorflow/python/framework:auto_control_deps_utils",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:function_def_to_graph",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/framework:tensor_util",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "bincount_ops",
    srcs = ["ops/bincount_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":count_ops_gen",
        "//tensorflow/python/compat",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

tf_py_test(
    name = "bincount_ops_test",
    size = "small",
    srcs = ["ops/bincount_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":bincount_ops",
        ":platform_test",
    ],
)

py_library(
    name = "ctc_ops",
    srcs = ["ops/ctc_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":ctc_ops_gen",
        ":nn_grad",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "cudnn_rnn_grad",
    srcs = ["ops/cudnn_rnn_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":cudnn_rnn_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "data_flow_grad",
    srcs = ["ops/data_flow_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":data_flow_ops",
        ":math_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "data_flow_ops",
    srcs = ["ops/data_flow_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":data_flow_ops_gen",
        ":math_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:random_seed",
        "//tensorflow/python/framework:tensor_util",
        "@six_archive//:six",
    ],
)

py_library(
    name = "embedding_ops",
    srcs = ["ops/embedding_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":clip_ops",
        ":data_flow_grad",
        ":data_flow_ops",
        ":math_ops",
        ":platform",
        ":resource_variable_ops",
        ":sparse_ops",
        ":variables",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:tensor_shape",
    ],
)

py_library(
    name = "handle_data_util",
    srcs = [
        "ops/handle_data_util.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":protos_all_py",
        "//tensorflow/python/client:pywrap_tf_session",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "gradients",
    srcs = [
        "ops/custom_gradient.py",
        "ops/gradients.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":gradients_impl",
        ":gradients_util",
        ":handle_data_util",
        ":unconnected_gradients",
        "//tensorflow/python/client:pywrap_tf_session",
        "//tensorflow/python/eager:forwardprop",
        "//tensorflow/python/eager:function",
        "//tensorflow/python/eager:tape",
    ],
)

py_library(
    name = "gradients_impl",
    srcs = [
        "ops/gradients_impl.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_grad",
        ":array_ops",
        ":bitwise_ops",
        ":check_ops",
        ":control_flow_grad",
        ":control_flow_ops",
        ":control_flow_util",
        ":image_grad",
        ":linalg_grad",
        ":linalg_ops",
        ":logging_ops",
        ":manip_grad",
        ":manip_ops",
        ":math_grad",
        ":math_ops",
        ":optional_grad",
        ":platform",
        ":random_grad",
        ":tensor_array_ops",
        ":unconnected_gradients",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/ops/linalg/sparse",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "gradients_util",
    srcs = [
        "ops/gradients_util.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":control_flow_state",
        ":control_flow_util",
        ":default_gradient",
        ":functional_ops",
        ":math_ops",
        ":platform",
        ":resource_variable_ops",
        ":unconnected_gradients",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/eager:backprop",
        "//tensorflow/python/eager:backprop_util",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_util",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
        "@six_archive//:six",
    ],
)

py_library(
    name = "default_gradient",
    srcs = [
        "ops/default_gradient.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":resource_variable_ops",
        "//tensorflow/python/framework:dtypes",
    ],
)

py_library(
    name = "control_flow_state",
    srcs = [
        "ops/control_flow_state.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":control_flow_util",
        ":data_flow_ops_gen",
        ":resource_variable_ops_gen",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_util",
    ],
)

py_library(
    name = "unconnected_gradients",
    srcs = ["ops/unconnected_gradients.py"],
    srcs_version = "PY3",
    deps = [
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "histogram_ops",
    srcs = ["ops/histogram_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":clip_ops",
        ":math_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "image_grad",
    srcs = ["ops/image_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":image_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "image_ops",
    srcs = [
        "ops/image_ops.py",
        "ops/image_ops_impl.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":check_ops",
        ":clip_ops",
        ":control_flow_ops",
        ":gradients",
        ":image_ops_gen",
        ":math_ops",
        ":nn",
        ":nn_ops_gen",
        ":random_ops",
        ":string_ops",
        ":variables",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "init_ops",
    srcs = ["ops/init_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":linalg_ops_gen",
        ":linalg_ops_impl",
        ":math_ops",
        ":random_ops",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "init_ops_v2",
    srcs = ["ops/init_ops_v2.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":linalg_ops_gen",
        ":linalg_ops_impl",
        ":math_ops",
        ":random_ops",
        ":stateless_random_ops",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "initializers_ns",
    srcs = ["ops/initializers_ns.py"],
    srcs_version = "PY3",
    deps = [
        ":init_ops",
        ":variables",
    ],
)

py_library(
    name = "io_ops",
    srcs = ["ops/io_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":io_ops_gen",
        ":lib",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "linalg_grad",
    srcs = ["ops/linalg_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":linalg_ops",
        ":math_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/ops/linalg:linalg_impl",
    ],
)

py_library(
    name = "linalg_ops",
    srcs = ["ops/linalg_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":linalg_ops_gen",
        ":linalg_ops_impl",
        ":map_fn",
        ":math_ops",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "linalg_ops_impl",
    srcs = ["ops/linalg_ops_impl.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "manip_grad",
    srcs = ["ops/manip_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":control_flow_ops",
        ":manip_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "manip_ops",
    srcs = ["ops/manip_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":manip_ops_gen",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "logging_ops",
    srcs = ["ops/logging_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":logging_ops_gen",
        ":platform",
        ":string_ops",
        "//tensorflow/python/compat",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "lookup_ops",
    srcs = ["ops/lookup_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":lookup_ops_gen",
        ":math_ops",
        ":string_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/util",
        "@six_archive//:six",
    ],
)

py_library(
    name = "math_grad",
    srcs = ["ops/math_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":array_ops_gen",
        ":math_ops",
        ":math_ops_gen",
        ":special_math_ops",
        "//tensorflow/python/client:pywrap_tf_session",
        "//tensorflow/python/compat",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:tensor_util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "op_selector",
    srcs = ["ops/op_selector.py"],
    srcs_version = "PY3",
    deps = ["//tensorflow/python/framework:ops"],
)

py_library(
    name = "math_ops",
    srcs = ["ops/math_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":bitwise_ops_gen",
        ":control_flow_ops_gen",
        ":data_flow_ops_gen",
        ":math_ops_gen",
        ":nn_ops_gen",
        ":sparse_ops_gen",
        ":state_ops",
        ":state_ops_gen",
        "//tensorflow/python/compat",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:common_shapes",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:graph_util",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "resources",
    srcs = ["ops/resources.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util:tf_should_use",
    ],
)

py_library(
    name = "resource_variable_ops",
    srcs = ["ops/resource_variable_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":array_ops_gen",
        ":handle_data_util",
        ":resource_variable_ops_gen",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client:pywrap_tf_session",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/eager:tape",
        "//tensorflow/python/framework:auto_control_deps_utils",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "critical_section_ops",
    srcs = ["ops/critical_section_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":resource_variable_ops_gen",
        ":tensor_array_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "list_ops",
    srcs = ["ops/list_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":handle_data_util",
        ":list_ops_gen",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "map_ops",
    srcs = ["ops/map_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":map_ops_gen",
    ],
)

py_library(
    name = "nn",
    srcs = [
        "ops/nn.py",
        "ops/nn_impl.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":candidate_sampling_ops",
        ":ctc_ops",
        ":embedding_ops",
        ":math_ops",
        ":nn_grad",
        ":nn_ops",
        ":nn_ops_gen",
        ":sparse_ops",
        ":variables",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/platform:device_context",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "nn_grad",
    srcs = ["ops/nn_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":gradients",
        ":math_ops",
        ":nn_ops",
        ":nn_ops_gen",
        ":sparse_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:tensor_util",
    ],
)

py_library(
    name = "nn_ops",
    srcs = ["ops/nn_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        ":nn_ops_gen",
        ":platform",
        ":random_ops",
        ":variables",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:graph_util",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/framework:tensor_util",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "numerics",
    srcs = ["ops/numerics.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "parsing_config",
    srcs = ["ops/parsing_config.py"],
    srcs_version = "PY3",
    deps = [
        "//tensorflow/python/framework",
    ],
)

py_library(
    name = "parsing_ops",
    srcs = ["ops/parsing_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        ":parsing_config",
        ":parsing_ops_gen",
        ":sparse_ops",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "partitioned_variables",
    srcs = ["ops/partitioned_variables.py"],
    srcs_version = "PY3",
    deps = [
        ":platform",
        ":variable_scope",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "random_grad",
    srcs = ["ops/random_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        ":random_ops_gen",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
    ],
)

py_library(
    name = "random_ops",
    srcs = ["ops/random_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        ":random_ops_gen",
        ":stateless_random_ops",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:random_seed",
    ],
)

py_library(
    name = "stateful_random_ops",
    srcs = ["ops/stateful_random_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":math_ops",
        ":stateful_random_ops_gen",
        ":stateless_random_ops_v2_gen",
        ":variables",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "stateful_random_ops_test",
    size = "medium",
    srcs = ["ops/stateful_random_ops_test.py"],
    python_version = "PY3",
    xla_enable_strict_auto_jit = False,
    xla_enabled = True,
    deps = [
        ":client_testlib",
        ":logging_ops",
        ":random_ops_gen",
        ":stateful_random_ops",
        "//tensorflow/python/distribute:mirrored_strategy",
        "//tensorflow/python/framework:config",
        "//tensorflow/python/kernel_tests/random:util",
    ],
)

py_library(
    name = "stateless_random_ops",
    srcs = ["ops/stateless_random_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        ":stateless_random_ops_gen",
        ":stateless_random_ops_v2_gen",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
    ],
)

py_library(
    name = "rnn",
    srcs = ["ops/rnn.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":control_flow_util",
        ":control_flow_util_v2",
        ":math_ops",
        ":rnn_cell",
        ":tensor_array_ops",
        ":variable_scope",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "rnn_cell",
    srcs = [
        "ops/rnn_cell.py",
        "ops/rnn_cell_impl.py",
        "ops/rnn_cell_wrapper_impl.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":clip_ops",
        ":init_ops",
        ":math_ops",
        ":nn_ops",
        ":partitioned_variables",
        ":random_ops",
        ":variable_scope",
        ":variables",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/keras/layers/legacy_rnn:rnn_cell_impl",
        "//tensorflow/python/keras/layers/legacy_rnn:rnn_cell_wrapper_impl",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "script_ops",
    srcs = ["ops/script_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":script_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/lib/core:_pywrap_py_func",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "sdca_ops",
    srcs = ["ops/sdca_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":sdca_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "session_ops",
    srcs = ["ops/session_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":data_flow_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "sparse_grad",
    srcs = ["ops/sparse_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        ":sparse_ops",
        ":sparse_ops_gen",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "sparse_ops",
    srcs = ["ops/sparse_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":check_ops",
        ":control_flow_ops",
        ":math_ops",
        ":sparse_ops_gen",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
        "//third_party/py/numpy",
    ],
)

tf_py_test(
    name = "sparse_ops_test",
    srcs = ["ops/sparse_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":array_grad",
        ":gradient_checker_v2",
        ":sparse_grad",
        ":sparse_ops",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:sparse_tensor",
        "//tensorflow/python/framework:test_lib",
        "@absl_py//absl/testing:parameterized",
    ],
)

py_library(
    name = "sort_ops",
    srcs = ["ops/sort_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops",
        ":nn_ops",
        "//tensorflow/python/framework",
        "//third_party/py/numpy",
    ],
)

tf_py_test(
    name = "sort_ops_test",
    srcs = ["ops/sort_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":random_ops",
        ":sort_ops",
        "//tensorflow/python/framework",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "confusion_matrix",
    srcs = ["ops/confusion_matrix.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":check_ops",
        ":control_flow_ops",
        ":math_ops",
        ":sparse_ops",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "weights_broadcast_ops",
    srcs = [
        "ops/weights_broadcast_ops.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        ":sets",
        "//tensorflow/python/framework",
    ],
)

py_library(
    name = "metrics",
    srcs = [
        "ops/metrics.py",
        "ops/metrics_impl.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":check_ops",
        ":confusion_matrix",
        ":control_flow_ops",
        ":math_ops",
        ":nn",
        ":sets",
        ":sparse_ops",
        ":state_ops",
        ":variable_scope",
        ":variables",
        ":weights_broadcast_ops",
        "//tensorflow/python/distribute:distribute_lib",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "special_math_ops",
    srcs = ["ops/special_math_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":check_ops",
        ":control_flow_ops",
        ":math_ops",
        ":platform",
        ":special_math_ops_gen",
        "//tensorflow/compiler/tf2xla/ops:gen_xla_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "@opt_einsum_archive//:opt_einsum",
    ],
)

py_library(
    name = "rnn_grad",
    srcs = ["ops/rnn_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":rnn_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "rnn_grad_test",
    srcs = ["ops/rnn_grad_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":gradients",
        ":math_ops",
        ":rnn_grad",
        ":rnn_ops_gen",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

py_test(
    name = "script_ops_test",
    srcs = ["ops/script_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":script_ops",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "standard_ops",
    srcs = ["ops/standard_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_grad",
        ":array_ops",
        ":batch_ops",
        ":check_ops",
        ":clip_ops",
        ":confusion_matrix",
        ":control_flow_ops",
        ":critical_section_ops",
        ":cudnn_rnn_grad",
        ":data_flow_grad",
        ":data_flow_ops",
        ":functional_ops",
        ":gradients",
        ":histogram_ops",
        ":init_ops",
        ":io_ops",
        ":linalg_ops",
        ":logging_ops",
        ":lookup_ops",
        ":manip_grad",
        ":manip_ops",
        ":math_grad",
        ":math_ops",
        ":numerics",
        ":parsing_ops",
        ":partitioned_variables",
        ":proto_ops",
        ":random_ops",
        ":rnn_grad",
        ":script_ops",
        ":session_ops",
        ":sort_ops",
        ":sparse_grad",
        ":sparse_ops",
        ":special_math_ops",
        ":state_grad",
        ":state_ops",
        ":stateful_random_ops",
        ":stateless_random_ops",
        ":string_ops",
        ":template",
        ":tensor_array_grad",
        ":tensor_array_ops",
        ":variable_scope",
        ":variables",
        "//tensorflow/python/compiler",
        "//tensorflow/python/eager:wrap_function",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/ops/distributions",
        "//tensorflow/python/ops/linalg",
        "//tensorflow/python/ops/linalg/sparse",
        "//tensorflow/python/ops/ragged",
        "//tensorflow/python/ops/structured",
        "//tensorflow/python/training/experimental:loss_scaling_gradient_tape",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "state_grad",
    srcs = ["ops/state_grad.py"],
    srcs_version = "PY3",
    deps = ["//tensorflow/python/framework:for_generated_wrappers"],
)

py_library(
    name = "state_ops",
    srcs = ["ops/state_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":math_ops_gen",
        ":resource_variable_ops_gen",
        ":state_ops_gen",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "string_ops",
    srcs = ["ops/string_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":string_ops_gen",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "summary_ops_v2",
    srcs = ["ops/summary_ops_v2.py"],
    srcs_version = "PY3",
    visibility = ["//tensorflow:internal"],
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        ":resource_variable_ops",
        ":resource_variable_ops_gen",
        ":summary_op_util",
        ":summary_ops_gen",
        ":training_util",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/eager:profiler",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:smart_cond",
        "//tensorflow/python/framework:tensor_util",
        "//tensorflow/python/util",
        "@six_archive//:six",
    ],
)

py_library(
    name = "template",
    srcs = ["ops/template.py"],
    srcs_version = "PY3",
    deps = [
        ":platform",
        ":variable_scope",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/eager:function",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/util",
    ],
)

py_library(
    name = "tensor_array_grad",
    srcs = ["ops/tensor_array_grad.py"],
    srcs_version = "PY3",
    deps = [
        ":tensor_array_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

py_library(
    name = "tensor_array_ops",
    srcs = ["ops/tensor_array_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops_gen",
        ":data_flow_ops_gen",
        ":list_ops",
        ":math_ops",
        ":tf2",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:errors",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/framework:tensor_util",
        "//tensorflow/python/util:tf_should_use",
    ],
)

py_library(
    name = "composite_tensor_ops",
    srcs = ["ops/composite_tensor_ops.py"],
    srcs_version = "PY2AND3",
    deps = ["composite_tensor_ops_gen"],
)

py_library(
    name = "variable_scope",
    srcs = ["ops/variable_scope.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":init_ops",
        ":platform",
        ":resource_variable_ops",
        ":tf2",
        ":variables",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/eager:monitoring",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/util",
        "@six_archive//:six",
    ],
)

py_library(
    name = "variables",
    srcs = ["ops/variables.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":control_flow_ops",
        ":math_ops",
        ":state_ops",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:tensor_shape",
        "//tensorflow/python/training/tracking:base",
        "//tensorflow/python/util",
        "//tensorflow/python/util:tf_should_use",
    ],
)

py_library(
    name = "gradient_checker",
    srcs = ["ops/gradient_checker.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":gradients",
        ":platform",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_library(
    name = "gradient_checker_v2",
    srcs = ["ops/gradient_checker_v2.py"],
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":gradients",
        ":platform",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "bitwise_ops_test",
    size = "small",
    srcs = ["ops/bitwise_ops_test.py"],
    python_version = "PY3",
    tags = ["no_windows"],
    deps = [
        ":bitwise_ops",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:test_lib",
    ],
)

cuda_py_test(
    name = "control_flow_ops_test",
    size = "medium",  # Contains artificial waits.
    srcs = ["ops/control_flow_ops_test.py"],
    python_version = "PY3",
    shard_count = 2,
    tags = [
        "no_cuda_asan",  # b/173241932
    ],
    xla_tags = [
        "no_cuda_asan",  # times out
    ],
    deps = [
        ":array_ops",
        ":cond_v2",
        ":control_flow_ops",
        ":control_flow_v2_toggles",
        ":embedding_ops",
        ":gradients",
        ":init_ops",
        ":math_ops",
        ":platform_test",
        ":state_ops",
        ":tensor_array_grad",
        ":tensor_array_ops",
        ":training",
        ":variable_scope",
        ":variables",
        ":while_v2",
        "//tensorflow/python/eager:def_function",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//tensorflow/python/util",
    ],
)

py_test(
    name = "op_selector_test",
    srcs = ["ops/op_selector_test.py"],
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        ":client_testlib",
        ":math_ops",
        ":op_selector",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:ops",
    ],
)

cuda_py_test(
    name = "embedding_ops_test",
    srcs = ["ops/embedding_ops_test.py"],
    python_version = "PY3",
    tags = ["no_windows_gpu"],
    deps = [
        ":embedding_ops",
        ":gradients",
        ":resource_variable_ops",
        "//tensorflow/python/eager:def_function",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "gradient_checker_v2_test",
    size = "medium",
    srcs = ["ops/gradient_checker_v2_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":math_ops",
        ":nn_grad",
        ":nn_ops",
        ":platform",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "gradients_test",
    size = "medium",
    srcs = ["ops/gradients_test.py"],
    python_version = "PY3",
    tags = ["no_oss"],  # b/118709825
    deps = [
        ":array_grad",
        ":array_ops",
        ":control_flow_grad",
        ":control_flow_ops",
        ":data_flow_grad",
        ":data_flow_ops",
        ":functional_ops",
        ":gradients",
        ":init_ops",
        ":list_ops",
        ":map_ops",
        ":math_grad",
        ":math_ops",
        ":nn_grad",
        ":nn_ops",
        ":platform_test",
        ":state_grad",
        ":state_ops",
        ":tensor_array_grad",
        ":tensor_array_ops",
        ":unconnected_gradients",
        ":variable_scope",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//tensorflow/python/framework:test_ops",
        "//third_party/py/numpy",
        "@absl_py//absl/testing:parameterized",
    ],
)

cuda_py_test(
    name = "histogram_ops_test",
    size = "small",
    srcs = ["ops/histogram_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":histogram_ops",
        ":init_ops",
        ":variables",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "image_grad_deterministic_test",
    size = "large",
    srcs = ["ops/image_grad_deterministic_test.py"],
    python_version = "PY3",
    shard_count = 5,
    deps = [
        ":image_grad_test_base",
    ],
)

cuda_py_test(
    name = "image_grad_test",
    size = "large",
    srcs = ["ops/image_grad_test.py"],
    python_version = "PY3",
    shard_count = 5,
    deps = [
        ":image_grad_test_base",
    ],
)

py_library(
    name = "image_grad_test_base",
    srcs = ["ops/image_grad_test_base.py"],
    srcs_version = "PY3",
    deps = [
        ":client_testlib",
        ":errors",
        ":gradients",
        ":image_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "image_ops_test",
    size = "medium",
    srcs = ["ops/image_ops_test.py"],
    data = ["//tensorflow/core:image_testdata"],
    python_version = "PY3",
    shard_count = 16,
    tags = [
        "no_cuda_asan",  # TODO(b/171511582): re-enable.
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":control_flow_ops",
        ":image_ops",
        ":io_ops",
        ":math_ops",
        ":platform_test",
        ":random_ops",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:errors",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
        "@absl_py//absl/testing:parameterized",
    ],
)

cuda_py_test(
    name = "init_ops_test",
    size = "small",
    srcs = ["ops/init_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":init_ops",
        ":resource_variable_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:ops",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "init_ops_v2_test",
    size = "medium",
    srcs = ["ops/init_ops_v2_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":init_ops_v2",
        ":random_ops",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:ops",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "math_grad_test",
    size = "small",
    srcs = ["ops/math_grad_test.py"],
    python_version = "PY3",
    tags = ["no_windows_gpu"],
    xla_tags = [
        "no_cuda_asan",  # times out
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":math_ops",
        "//tensorflow/python/eager:backprop",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "math_ops_test",
    size = "medium",
    srcs = ["ops/math_ops_test.py"],
    python_version = "PY3",
    tags = ["no_windows_gpu"],
    deps = [
        ":array_ops",
        ":gradients",
        ":math_ops",
        ":platform_test",
        ":variables",
        "//tensorflow/python/framework:errors",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "math_ops_linspace_test",
    size = "medium",
    srcs = ["ops/math_ops_linspace_test.py"],
    python_version = "PY3",
    tags = [
        "no_windows_gpu",
    ],
    deps = [
        ":math_ops",
        ":platform_test",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "nn_batchnorm_test",
    size = "medium",
    srcs = ["ops/nn_batchnorm_test.py"],
    python_version = "PY3",
    shard_count = 4,
    tags = ["no_windows"],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":gradients",
        ":math_ops",
        ":nn",
        ":nn_grad",
        ":nn_ops_gen",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "nn_fused_batchnorm_test",
    size = "large",
    srcs = ["ops/nn_fused_batchnorm_test.py"],
    python_version = "PY3",
    shard_count = 24,
    tags = ["no_rocm"],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":gradients",
        ":nn",
        ":nn_grad",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "nn_test",
    size = "medium",
    srcs = ["ops/nn_test.py"],
    python_version = "PY3",
    tags = ["no_windows"],
    xla_tags = [
        "no_cuda_asan",  # times out
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":nn",
        ":nn_grad",
        ":nn_ops",
        ":partitioned_variables",
        ":variable_scope",
        ":variables",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
        "@absl_py//absl/testing:parameterized",
    ],
)

py_test(
    name = "nn_loss_scaling_utilities_test",
    size = "small",
    srcs = ["ops/nn_loss_scaling_utilities_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        "//tensorflow/python/distribute:combinations",
        "//tensorflow/python/distribute:strategy_combinations",
        "//tensorflow/python/distribute:test_util",
        "@absl_py//absl/testing:parameterized",
    ],
)

cuda_py_test(
    name = "nn_xent_test",
    size = "medium",
    srcs = ["ops/nn_xent_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":gradients",
        ":nn",
        ":nn_grad",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_test(
    name = "tensor_array_ops_test",
    size = "small",
    srcs = ["ops/tensor_array_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        "//tensorflow/python/client",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "sobol_ops_test",
    size = "small",
    srcs = ["ops/sobol_ops_test.py"],
    kernels = [
        "//tensorflow/core/kernels:libtfkernel_sobol_op.so",
    ],
    tags = [
        "no_oss",  # TODO(b/149565560)
        "no_windows_gpu",
    ],
    deps = [
        ":math_ops",
        ":platform_test",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "special_math_ops_test",
    size = "medium",
    srcs = ["ops/special_math_ops_test.py"],
    python_version = "PY3",
    shard_count = 10,
    tags = [
        "no_rocm",
        "no_windows_gpu",
        "noasan",  # b/159332048
        "nomsan",  # b/148630708
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":math_ops",
        ":special_math_ops",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

tf_py_test(
    name = "variable_spec_test",
    size = "small",
    srcs = ["ops/variable_spec_test.py"],
    python_version = "PY3",
    deps = [
        ":platform_test",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

alias(
    name = "client",
    actual = "//tensorflow/python/client:client",
)

# Note: this is a heavyweight library specialized for TensorFlow graphs. Do not use for
# other purposes.

py_library(
    name = "global_test_configuration",
    compatible_with = get_compatible_with_portable(),
    srcs_version = "PY3",
    deps = if_mlir(["//tensorflow/compiler/mlir/tensorflow:mlir_roundtrip_pass_registration"]) +
           tf_enable_mlir_bridge(),
)

# `tree.compat` requires visibility exception to test against `nest_test`
# to facilitate convergence between `tree.compat` and `nest`.

tf_proto_library(
    name = "protos_all",
    srcs = glob(
        ["**/*.proto"],
        exclude = [
            "//tensorflow/python/util:compare_test_proto_src",
            "framework/cpp_shape_inference.proto",
        ],
    ),
    protodeps = ["//tensorflow/python/training:checkpoint_state"],
    visibility = visibility,
)

alias(
    name = "device_lib",
    actual = "//tensorflow/python/client:device_lib",
)

py_library(
    name = "pywrap_tensorflow",
    srcs = [
        "pywrap_tensorflow.py",
    ] + if_static(
        ["pywrap_dlopen_global_flags.py"],
        # Import will fail, indicating no global dlopen flags
        otherwise = [],
    ),  # b/153585257
    srcs_version = "PY3",
    deps = [":pywrap_tensorflow_internal"],
)

pywrap_tensorflow_macro(
    name = "pywrap_tensorflow_internal",
    srcs = ["pywrap_tensorflow_internal.cc"],
    # copybara:comment_begin(OSS Windows only: DEF file for exported symbols)
    win_def_file = select({
        "//tensorflow:windows": ":pywrap_tensorflow_filtered_def_file",
        "//conditions:default": None,
    }),
    # copybara:comment_end
    deps = [
        ":bfloat16_lib",
        "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib",
        "//tensorflow/core/distributed_runtime/rpc:grpc_session",
        "//tensorflow/python/grappler:cost_analyzer_lib",
        "//tensorflow/python/grappler:model_analyzer_lib",
        "//tensorflow/python/util:cpp_nest",
        "//tensorflow/python/util:cpp_python_util",
        "//tensorflow/python/util:function_parameter_canonicalizer",
        "//tensorflow/python/util:kernel_registry",
        ":numpy_lib",
        ":safe_ptr",
        ":py_exception_registry",
        "//tensorflow/python/lib/core:py_func_lib",
        "//tensorflow/python/lib/io:py_record_reader_lib",
        "//tensorflow/python/lib/core:pybind11_absl",
        "//tensorflow/python/lib/core:pybind11_lib",
        "//tensorflow/python/lib/core:pybind11_status",
        "//tensorflow/python/lib/core:pybind11_proto",
        "//tensorflow/python/framework:python_api_dispatcher",
        "//tensorflow/python/framework:python_api_info",
        "//tensorflow/python/framework:python_api_parameter_converter",
        "//tensorflow/python/framework:python_op_gen",
        "//tensorflow/python/framework:python_tensor_converter",
        "//tensorflow/python/lib/core:safe_pyobject_ptr",
        "//third_party/python_runtime:headers",
        "//tensorflow/c:c_api",
        "//tensorflow/c:c_api_experimental",
        "//tensorflow/c:checkpoint_reader",
        "//tensorflow/c:python_api",
        "//tensorflow/c:tf_status_helper",
        "//tensorflow/c/eager:c_api",
        "//tensorflow/c/eager:c_api_experimental",
        "//tensorflow/c/experimental/ops",
        "//tensorflow/c/experimental/gradients",
        "//tensorflow/c/experimental/gradients/tape",
        "//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration",
        "//tensorflow/core/data/service:server_lib",
        "//tensorflow/core/grappler:grappler_item",
        "//tensorflow/core/grappler:grappler_item_builder",
        "//tensorflow/core/grappler/clusters:cluster",
        "//tensorflow/core/grappler/clusters:single_machine",
        "//tensorflow/core/grappler/clusters:virtual_cluster",
        "//tensorflow/core/grappler/costs:graph_memory",
        "//tensorflow/core/grappler/graph_analyzer:graph_analyzer_tool",
        "//tensorflow/core/grappler/optimizers:meta_optimizer",
        "//tensorflow/core:lib",
        "//tensorflow/core:reader_base",
        "//tensorflow/core/kernels:data_service_ops",
        "//tensorflow/core/debug",
        "//tensorflow/core/distributed_runtime:server_lib",
        "//tensorflow/core/platform:stacktrace_handler",
        "//tensorflow/core/profiler/rpc:profiler_server_impl",
        "//tensorflow/core/profiler/rpc/client:profiler_client_impl",
        "//tensorflow/core/profiler/internal:print_model_analysis",
        "//tensorflow/lite/delegates/flex:delegate",
        "//tensorflow/core/profiler/internal/cpu:python_tracer",
        "//tensorflow/tools/graph_transforms:transform_graph_lib",
        "//tensorflow/lite/toco/python:toco_python_api",
        "//tensorflow/python/client:tf_session_helper",
        "//tensorflow/python/eager:pywrap_tfe_lib",
        "//tensorflow/core/util/tensor_bundle",
        "//tensorflow/compiler/mlir/python:mlir",
    ] + (tf_additional_lib_deps() +
         tf_monitoring_python_deps() +
         tf_additional_plugin_deps() +
         tf_additional_profiler_deps()) + if_xla_available([
        "//tensorflow/compiler/aot:tfcompile_lib",
    ]) + if_static(extra_deps = [
        "//tensorflow/core/platform:tensor_float_32_utils",
        "//tensorflow/core/platform:enable_tf2_utils",
    ]),
)

# ** Targets for Windows build (start) **
# We need the following targets to expose symbols from _pywrap_tensorflow.dll

filegroup(
    name = "win_lib_files_for_exported_symbols",
    srcs = [
        ":bfloat16_lib",  # bfloat16
        "//tensorflow/python/grappler:cost_analyzer_lib",
        "//tensorflow/python/util:cpp_nest",
        "//tensorflow/python/util:cpp_python_util",
        "//tensorflow/python/util:kernel_registry",
        "//tensorflow/python/grappler:model_analyzer_lib",  # model_analyzer
        ":ndarray_tensor",  # checkpoint_reader
        ":numpy_lib",  # checkpoint_reader
        ":py_exception_registry",  # py_exception_registry
        "//tensorflow/python/lib/core:py_func_lib",
        "//tensorflow/python/framework:python_api_dispatcher",  # python_api_dispatcher
        "//tensorflow/python/framework:python_tensor_converter",  # python_tensor_converter
        "//tensorflow/python/framework:python_op_gen",  # python_op_gen
        ":safe_ptr",  # checkpoint_reader
        "//tensorflow/c:checkpoint_reader",  # checkpoint_reader
        "//tensorflow/c:python_api",  # tf_session
        "//tensorflow/c:tf_status_helper",  # tfe
        "//tensorflow/cc/experimental/libexport:metrics_impl",  # SavedModel metrics
        "//tensorflow/compiler/jit:get_compiler_ir",  # tfe
        "//tensorflow/core/platform:statusor",  # tfe
        "//tensorflow/compiler/jit:flags",  # tfe
        "//tensorflow/compiler/mlir/python:mlir",  # mlir
        "//tensorflow/core/common_runtime:graph_constructor",  # tf_session
        "//tensorflow/core/common_runtime:quantize_training",  # quantize_training
        "//tensorflow/core/common_runtime:session_options",  # device_lib, tfe, tf_session
        "//tensorflow/core/common_runtime:session_state",  # tf_session
        "//tensorflow/core/data/service:server_lib",  # server_lib
        "//tensorflow/core:framework_internal_impl",  # op_def_registry
        "//tensorflow/core:lib_internal_impl",  # device_lib
        "//tensorflow/core:op_gen_lib",  # tf_session, tf_text
        "//tensorflow/core/common_runtime/eager:context",  # tfe
        "//tensorflow/core/common_runtime/eager:tensor_handle",  # tfe
        "//tensorflow/core/common_runtime/eager:eager_executor",  # tfe
        "//tensorflow/core/grappler:devices",  # tf_cluster
        "//tensorflow/core/grappler:grappler_item",  # tf_item
        "//tensorflow/core/grappler:grappler_item_builder",  # tf_item
        "//tensorflow/core/grappler/clusters:cluster",  # tf_cluster
        "//tensorflow/core/grappler/clusters:single_machine",  # tf_cluster
        "//tensorflow/core/grappler/clusters:utils",  # tf_optimizer
        "//tensorflow/core/grappler/clusters:virtual_cluster",  # tf_cluster
        "//tensorflow/core/grappler/costs:analytical_cost_estimator",  # cost analyzer
        "//tensorflow/core/grappler/costs:graph_memory",  # tf_cluster
        "//tensorflow/core/grappler/costs:graph_properties",  # tf_item
        "//tensorflow/core/grappler/costs:measuring_cost_estimator",  # tf_cluster
        "//tensorflow/core/grappler/costs:op_level_cost_estimator",  # tf_cluster
        "//tensorflow/core/grappler/costs:utils",  # tf_cluster
        "//tensorflow/core/grappler/graph_analyzer:graph_analyzer_tool",  # graph_analyzer
        "//tensorflow/core/grappler/optimizers:meta_optimizer",  # tf_optimizer
        "//tensorflow/core/grappler/utils:topological_sort",  # tf_item
        "//tensorflow/core/platform:tensor_float_32_utils",  # tensor_float_32
        "//tensorflow/core/profiler/internal:print_model_analysis",  # tfprof
        "//tensorflow/core/profiler/internal/cpu:traceme_recorder_impl",  # profiler
        "//tensorflow/core/profiler/lib:profiler_session_impl",  # profiler
        "//tensorflow/core/profiler/rpc:profiler_server_impl",  # profiler
        "//tensorflow/core/profiler/rpc/client:profiler_client_impl",  # profiler
        "//tensorflow/python/framework:python_api_info",  # python_api_info
        "//tensorflow/python/framework:python_api_parameter_converter",  # python_api_parameter_converter
        "//tensorflow/core/util:port",  # util_port
        "//tensorflow/core/util/tensor_bundle",  # checkpoint_reader
        "//tensorflow/lite/toco/python:toco_python_api",  # toco
        "//tensorflow/python/client:tf_session_helper",  # tf_session
        "//tensorflow/python/eager:pywrap_tfe_lib",  # pywrap_tfe_lib
        "//tensorflow/stream_executor:stream_executor_pimpl",  # stat_summarizer
        "//tensorflow/tools/graph_transforms:transform_graph_lib",  # transform_graph
    ] + if_xla_available([
        "//tensorflow/compiler/aot:tfcompile_lib",  # tfcompile
        "//tensorflow/compiler/xla:status_macros",  # tfcompile
        "//tensorflow/compiler/xla/service:hlo",  # tfcompile
    ]),
    visibility = ["//visibility:private"],
)

# Filter the DEF file to reduce the number of symbols to 64K or less.
# Note that we also write the name of the pyd file into DEF file so that
# the dynamic libraries of custom ops can find it at runtime.
genrule(
    name = "pywrap_tensorflow_filtered_def_file",
    srcs = select({
        "//tensorflow:windows": [
            ":pybind_symbol_target_libs_file",
            ":win_lib_files_for_exported_symbols",
            "//tensorflow:tensorflow_def_file",
            "//tensorflow/tools/def_file_filter:symbols_pybind",
        ],
        "//conditions:default": [],
    }),
    outs = ["pywrap_tensorflow_filtered_def_file.def"],
    cmd = select({
        "//tensorflow:windows": """
              $(location @local_config_def_file_filter//:def_file_filter) \\
              --input $(location //tensorflow:tensorflow_def_file) \\
              --output $@ \\
              --target _pywrap_tensorflow_internal.pyd \\
              --symbols $(location //tensorflow/tools/def_file_filter:symbols_pybind) \\
              --lib_paths_file $(location :pybind_symbol_target_libs_file)
          """,
        "//conditions:default": "touch $@",  # Just a placeholder for Unix platforms
    }),
    tools = ["@local_config_def_file_filter//:def_file_filter"],
    visibility = ["//visibility:public"],
)

# Write to a file a list of all cc_library targets that we need for exporting symbols on Windows.
genrule(
    name = "pybind_symbol_target_libs_file",
    srcs = [":win_lib_files_for_exported_symbols"],
    outs = ["pybind_symbol_target_libs_file.txt"],
    cmd = select({
        "//tensorflow:windows": """
            for SRC in $(SRCS); do
              echo $$SRC | sed 's/third_party\\///g' >> $@
            done
          """,
        "//conditions:default": "touch $@",  # Just a placeholder for Unix platforms
    }),
    visibility = ["//visibility:public"],
)

# Get the import library of _pywrap_tensorflow_internal.pyd
filegroup(
    name = "get_pywrap_tensorflow_import_lib_file",
    srcs = [":_pywrap_tensorflow_internal.so"],
    output_group = "interface_library",
)

cc_import(
    name = "_pywrap_tensorflow_internal_linux",
    shared_library = "//tensorflow/python:lib_pywrap_tensorflow_internal.so",
    visibility = tf_external_workspace_visible(visibility),
)

cc_import(
    name = "_pywrap_tensorflow_internal_macos",
    shared_library = "//tensorflow/python:lib_pywrap_tensorflow_internal.dylib",
    visibility = tf_external_workspace_visible(visibility),
)

cc_import(
    name = "_pywrap_tensorflow_internal_windows",
    interface_library = "//tensorflow/python:pywrap_tensorflow_import_lib_file",
    shared_library = "//tensorflow/python:_pywrap_tensorflow_internal.dll",
    visibility = tf_external_workspace_visible(visibility),
)

# Rename the import library for _pywrap_tensorflow_internal.pyd to _pywrap_tensorflow_internal.lib
# (It was _pywrap_tensorflow_internal.so.if.lib).
genrule(
    name = "pywrap_tensorflow_import_lib_file",
    srcs = [":get_pywrap_tensorflow_import_lib_file"],
    outs = ["_pywrap_tensorflow_internal.lib"],
    cmd = select({
        "//tensorflow:windows": "cp -f $< $@",
        "//conditions:default": "touch $@",  # Just a placeholder for Unix platforms
    }),
    visibility = ["//visibility:public"],
)

# Create a cc_import rule for the import library of _pywrap_tensorflow_internal.dll
# so that custom ops' dynamic libraries can link against it.
cc_import(
    name = "pywrap_tensorflow_import_lib",
    interface_library = select({
        "//tensorflow:windows": ":pywrap_tensorflow_import_lib_file",
        "//conditions:default": "not_existing_on_unix.lib",  # Just a placeholder for Unix platforms
    }),
    system_provided = 1,
)

# ** Targets for Windows build (end) **

alias(
    name = "session",
    actual = "//tensorflow/python/client:session",
)

alias(
    name = "timeline",
    actual = "//tensorflow/python/client:timeline",
    visibility = [
        "//visibility:public",
    ],
)

py_library(
    name = "summary_op_util",
    srcs = ["ops/summary_op_util.py"],
    srcs_version = "PY3",
    visibility = ["//visibility:public"],
    deps = [
        ":platform",
        "//tensorflow/python/framework",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

alias(
    name = "summary",
    actual = "//tensorflow/python/summary:summary",
    visibility = ["//visibility:public"],
)

alias(
    name = "fake_summary_writer",
    actual = "//tensorflow/python/summary/writer:fake_summary_writer",
    visibility = ["//visibility:public"],
)

# -----------------------------------------------------------------------------
# Quantization

tf_py_test(
    name = "dequantize_op_test",
    size = "small",
    srcs = ["ops/dequantize_op_test.py"],
    python_version = "PY3",
    tags = [
        "no_windows",
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

tf_py_test(
    name = "quantized_ops_test",
    size = "small",
    srcs = ["ops/quantized_ops_test.py"],
    python_version = "PY3",
    tags = [
        "no_windows",
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

tf_py_test(
    name = "quantized_conv_ops_test",
    size = "small",
    srcs = ["ops/quantized_conv_ops_test.py"],
    python_version = "PY3",
    tags = [
        "no_windows",
    ],
    deps = [
        ":client_testlib",
        ":nn_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

py_test(
    name = "ops/array_ops_test",
    srcs = ["ops/array_ops_test.py"],
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":gradients",
        ":math_ops",
        ":random_ops",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:dtypes",
        "//tensorflow/python/framework:ops",
        "//tensorflow/python/framework:test_lib",
    ],
)

cuda_py_test(
    name = "accumulate_n_benchmark",
    size = "medium",
    srcs = ["ops/accumulate_n_benchmark.py"],
    main = "ops/accumulate_n_benchmark.py",
    python_version = "PY3",
    shard_count = 6,
    deps = [
        ":array_ops",
        ":client_testlib",
        ":control_flow_ops_gen",
        ":data_flow_ops",
        ":math_ops",
        ":random_ops",
        ":state_ops",
        ":state_ops_gen",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "batch_norm_benchmark",
    srcs = ["ops/batch_norm_benchmark.py"],
    main = "ops/batch_norm_benchmark.py",
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":gradients",
        ":math_ops",
        ":nn",
        ":nn_grad",
        ":nn_ops_gen",
        ":platform",
        ":random_ops",
        ":variables",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "collective_ops_benchmark",
    srcs = ["ops/collective_ops_benchmark.py"],
    main = "ops/collective_ops_benchmark.py",
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":collective_ops",
        ":platform",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "concat_benchmark",
    srcs = ["ops/concat_benchmark.py"],
    main = "ops/concat_benchmark.py",
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":control_flow_ops",
        ":gradients",
        ":platform",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "control_flow_ops_benchmark",
    srcs = ["ops/control_flow_ops_benchmark.py"],
    main = "ops/control_flow_ops_benchmark.py",
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":control_flow_ops",
        "//tensorflow/python/eager:function",
        "//tensorflow/python/framework:constant_op",
        "//tensorflow/python/framework:ops",
    ],
)

cuda_py_test(
    name = "conv2d_benchmark",
    size = "large",
    srcs = ["ops/conv2d_benchmark.py"],
    main = "ops/conv2d_benchmark.py",
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":control_flow_ops",
        ":nn_ops",
        ":platform",
        ":platform_benchmark",
        ":random_ops",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "split_benchmark",
    srcs = ["ops/split_benchmark.py"],
    main = "ops/split_benchmark.py",
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":control_flow_ops",
        ":platform",
        ":platform_benchmark",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "transpose_benchmark",
    size = "medium",
    srcs = ["ops/transpose_benchmark.py"],
    main = "ops/transpose_benchmark.py",
    python_version = "PY3",
    deps = [
        ":array_ops",
        ":client_testlib",
        ":control_flow_ops",
        ":platform",
        ":platform_benchmark",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "matmul_benchmark",
    size = "medium",
    srcs = ["ops/matmul_benchmark.py"],
    main = "ops/matmul_benchmark.py",
    python_version = "PY3",
    deps = [":matmul_benchmark_main_lib"],
)

py_library(
    name = "matmul_benchmark_main_lib",
    testonly = True,
    srcs = ["ops/matmul_benchmark.py"],
    srcs_version = "PY3",
    deps = [
        ":client_testlib",
        ":control_flow_ops",
        ":math_ops",
        ":platform",
        ":platform_benchmark",
        ":random_ops",
        ":variables",
        "//tensorflow/core:protos_all_py",
        "//tensorflow/python/client",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//tensorflow/python/framework:test_lib",
        "//third_party/py/numpy",
    ],
)

cuda_py_test(
    name = "nn_grad_test",
    size = "medium",
    srcs = ["ops/nn_grad_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
        ":nn_grad",
        ":nn_ops",
        "//tensorflow/python/framework:for_generated_wrappers",
        "//third_party/py/numpy",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "nccl_ops_gen",
    visibility = ["//tensorflow:internal"],
    deps = [
        "//tensorflow/core:nccl_ops_op_lib",
    ],
)

py_library(
    name = "nccl_ops",
    srcs = ["ops/nccl_ops.py"],
    srcs_version = "PY3",
    visibility = visibility + [
        "//learning/deepmind/tensorflow:__subpackages__",
        "//third_party/car/deep_nets/tensorflow:__subpackages__",
    ],
    deps = [
        ":nccl_ops_gen",
        "//tensorflow/python/eager:context",
        "//tensorflow/python/eager:def_function",
        "//tensorflow/python/framework:for_generated_wrappers",
    ],
)

cuda_py_test(
    name = "nccl_ops_test",
    size = "small",
    srcs = ["ops/nccl_ops_test.py"],
    python_version = "PY3",
    # Disabled on jenkins until errors finding nvmlShutdown are found.
    tags = [
        "manual",
        "multi_gpu",
        "no_oss",
        "noguitar",
        "notap",
    ],
    deps = [
        ":array_ops",
        ":client_testlib",
        ":nccl_ops",
        ":platform_test",
        "//tensorflow/python/framework:test_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "decode_proto_ops_gen",
    deps = [
        "//tensorflow/core:decode_proto_ops_op_lib",
    ],
)

tf_gen_op_wrapper_private_py(
    name = "encode_proto_ops_gen",
    deps = [
        "//tensorflow/core:encode_proto_ops_op_lib",
    ],
)

py_library(
    name = "proto_ops",
    srcs = ["ops/proto_ops.py"],
    srcs_version = "PY3",
    deps = [
        ":decode_proto_ops_gen",
        ":encode_proto_ops_gen",
        "//tensorflow/python/framework:ops",
    ],
)

py_library(
    name = "pywrap_mlir",
    srcs = ["pywrap_mlir.py"],
    srcs_version = "PY3",
    visibility = ["//visibility:public"],
    deps = [
        ":_pywrap_mlir",
        ":pywrap_tensorflow",
    ],
)

tf_python_pybind_extension(
    name = "_pywrap_mlir",
    srcs = ["mlir_wrapper.cc"],
    hdrs = [
        "//tensorflow/c:headers",
        "//tensorflow/c/eager:headers",
        "//tensorflow/compiler/mlir/python:pywrap_mlir_hdrs",
        "//tensorflow/python/lib/core:safe_ptr_hdr",
    ],
    module_name = "_pywrap_mlir",
    deps = [
        "//tensorflow/core:protos_all_cc",
        "//tensorflow/core/platform:status",
        "//tensorflow/python/lib/core:pybind11_lib",
        "//tensorflow/python/lib/core:pybind11_status",
        "//tensorflow/python/lib/core:safe_pyobject_ptr",
        "//third_party/python_runtime:headers",
        "@com_google_absl//absl/strings",
        "@pybind11",
    ],
)

py_library(
    name = "pywrap_sanitizers",
    srcs = ["pywrap_sanitizers.py"],
    srcs_version = "PY3",
    visibility = ["//visibility:public"],
    deps = [
        ":_pywrap_sanitizers",
        ":pywrap_tensorflow",
    ],
)

tf_python_pybind_extension(
    name = "_pywrap_sanitizers",
    srcs = ["sanitizers_wrapper.cc"],
    module_name = "_pywrap_sanitizers",
    deps = [
        "@pybind11",
    ],
)

cc_library(
    name = "unified_api_pywrap_required_headers",
    textual_hdrs = [
        "//tensorflow/python/lib/core:basic_hdrs",
        "//tensorflow/c:headers",
        "//tensorflow/c/eager:headers",
        "//tensorflow/c/eager:pywrap_required_hdrs",
        "//tensorflow/c/experimental/ops:pywrap_required_hdrs",
        "//tensorflow/c/experimental/gradients:pywrap_required_hdrs",
        "//tensorflow/c/experimental/gradients/tape:pywrap_required_hdrs",
        "//tensorflow/core/common_runtime/eager:pywrap_required_hdrs",
        "//tensorflow/python/eager:pywrap_required_hdrs",
        "//tensorflow/core/common_runtime:core_cpu_lib_headers",
        "//tensorflow/core/public:session.h",
        "//tensorflow/core/public:session_options.h",
    ],
    visibility = ["//tensorflow/python/framework/experimental:__pkg__"],
    deps = [
        "//tensorflow/c:pywrap_required_hdrs",
        "//tensorflow/core/framework:pywrap_required_hdrs",
        "//third_party/py/numpy:headers",
        "//third_party/python_runtime:headers",
    ],
)

py_library(
    name = "pywrap_tfe",
    srcs = ["pywrap_tfe.py"],
    srcs_version = "PY3",
    visibility = ["//visibility:public"],
    deps = [
        ":_pywrap_tfe",
        ":pywrap_tensorflow",
    ],
)

tf_python_pybind_extension(
    name = "_pywrap_tfe",
    srcs = ["tfe_wrapper.cc"],
    hdrs = [
        "//tensorflow/c:headers",
        "//tensorflow/c/eager:headers",
        "//tensorflow/c/eager:pywrap_required_hdrs",
        "//tensorflow/c/experimental/ops:pywrap_required_hdrs",
        "//tensorflow/core/common_runtime/eager:pywrap_required_hdrs",
        "//tensorflow/core/distributed_runtime:pywrap_required_hdrs",
        "//tensorflow/core/distributed_runtime/coordination:pywrap_required_hdrs",
        "//tensorflow/core/distributed_runtime/eager:pywrap_required_hdrs",
        "//tensorflow/python/eager:pywrap_required_hdrs",
        "//tensorflow/python/lib/core:numpy_hdr",
        "//tensorflow/python/lib/core:py_exception_registry_hdr",
        "//tensorflow/python/lib/core:safe_ptr_hdr",
        "//tensorflow/python/util:util_hdr",
    ],
    module_name = "_pywrap_tfe",
    # Only include TensorFlow header-only targets here.
    # If a cc_library needs to depend on TensorFlow .cc files through srcs or
    # deps, then you can use cc_header_only_library to keep only headers.
    deps = [
        "//tensorflow/python/lib/core:safe_pyobject_ptr",
        "//tensorflow/python/lib/core:pybind11_lib",
        "//third_party/py/numpy:headers",
        "//tensorflow/python/lib/core:pybind11_status",
        "//tensorflow/core/framework:pywrap_required_hdrs",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/hash",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:optional",
        "//tensorflow/c:pywrap_required_hdrs",
        "@pybind11",
        "//third_party/python_runtime:headers",
        "//tensorflow/compiler/jit:flags_headers_only",
        "//tensorflow/compiler/jit:get_compiler_ir_hdrs_only",
        "//tensorflow/c/eager:tfe_tensorhandle_internal_hdrs_only",
        "//tensorflow/core/common_runtime:core_cpu_headers_lib",
        "//tensorflow/core:framework_headers_lib",
        "//tensorflow/core:lib_headers_for_pybind",
        "//tensorflow/core:protos_all_cc",
        "//tensorflow/core/platform",
        "//tensorflow/core/lib/llvm_rtti",
    ] + if_static(
        extra_deps = [
            "//tensorflow/core/protobuf:eager_service_proto_cc",
            "//tensorflow/core/protobuf:master_proto_cc",
            "//tensorflow/core/protobuf:worker_proto_cc",
        ],
        otherwise = [
            "//tensorflow/core/protobuf:eager_service_proto_cc_headers_only",
            "//tensorflow/core/protobuf:master_proto_cc_headers_only",
            "//tensorflow/core/protobuf:worker_proto_cc_headers_only",
        ],
    ),
)

tf_python_pybind_extension(
    name = "_pywrap_parallel_device",
    srcs = [
        "//tensorflow/c:headers",
        "//tensorflow/c/eager:headers",
        "//tensorflow/c/eager/parallel_device:headers",
        "//tensorflow/c/eager/parallel_device:sources",
        "//tensorflow/python/distribute/parallel_device:pywrap_parallel_device.cc",
        "//tensorflow/python/lib/core:safe_ptr_hdr",
    ],
    module_name = "_pywrap_parallel_device",
    visibility = ["//tensorflow/python/distribute/parallel_device:__pkg__"],
    deps = [
        "//tensorflow/c:pywrap_required_hdrs",
        "//tensorflow/c/eager:tfe_cancellationmanager_internal_hdrs_only",
        "//tensorflow/c/eager:tfe_tensorhandle_internal_hdrs_only",
        "//tensorflow/core:framework_headers_lib",
        "//tensorflow/core:lib_headers_for_pybind",
        "//tensorflow/core:protos_all_cc",
        "//tensorflow/python/lib/core:pybind11_lib",
        "//tensorflow/python/lib/core:pybind11_status",
        "//tensorflow/python/lib/core:safe_pyobject_ptr",
        "//third_party/python_runtime:headers",
        "@pybind11",
    ],
)

py_library(
    name = "tf2",
    srcs = ["tf2.py"],
    srcs_version = "PY3",
    deps = [
        "//tensorflow/python/platform:_pywrap_tf2",
        "//tensorflow/python/util:tf_export",
    ],
)

cuda_py_test(
    name = "raw_ops_test",
    srcs = ["ops/raw_ops_test.py"],
    python_version = "PY3",
    deps = [
        ":client_testlib",
    ],
)

alias(
    name = "platform_benchmark",
    actual = "//tensorflow/python/platform:benchmark",
)

alias(
    name = "platform_analytics",
    actual = "//tensorflow/python/platform:analytics",
)

py_library(
    name = "platform_test",
    srcs_version = "PY3",
    deps = ["//tensorflow/python/platform:test"],
)

alias(
    name = "platform",
    actual = "//tensorflow/python/platform:platform",
    visibility = ["//visibility:public"],
)

alias(
    name = "client_testlib",
    actual = "//tensorflow/python/platform:client_testlib",
)

alias(
    name = "pybind11_absl",
    actual = "//tensorflow/python/lib/core:pybind11_absl",
)

alias(
    name = "pybind11_proto",
    actual = "//tensorflow/python/lib/core:pybind11_proto",
)

alias(
    name = "py_func_lib",
    actual = "//tensorflow/python/lib/core:py_func_lib",
)

alias(
    name = "py_seq_tensor",
    actual = "//tensorflow/python/lib/core:py_seq_tensor",
)

alias(
    name = "py_util",
    actual = "//tensorflow/python/lib/core:py_util",
)

alias(
    name = "py_record_reader_lib",
    actual = "//tensorflow/python/lib/io:py_record_reader_lib",
)

alias(
    name = "numpy_lib",
    actual = "//tensorflow/python/lib/core:numpy_lib",
)

alias(
    name = "py_exception_registry",
    actual = "//tensorflow/python/lib/core:py_exception_registry",
)

alias(
    name = "pybind11_lib",
    actual = "//tensorflow/python/lib/core:pybind11_lib",
)

alias(
    name = "pybind11_status_headers",
    actual = "//tensorflow/python/lib/core:pybind11_status_headers",
)

alias(
    name = "pybind11_status",
    actual = "//tensorflow/python/lib/core:pybind11_status",
)

alias(
    name = "lib",
    actual = "//tensorflow/python/lib/io:lib",
)

alias(
    name = "safe_ptr",
    actual = "//tensorflow/python/lib/core:safe_ptr",
)

alias(
    name = "ndarray_tensor",
    actual = "//tensorflow/python/lib/core:ndarray_tensor",
)

alias(
    name = "ndarray_tensor_bridge",
    actual = "//tensorflow/python/lib/core:ndarray_tensor_bridge",
)

alias(
    name = "ndarray_tensor_headers",
    actual = "//tensorflow/python/lib/core:ndarray_tensor_headers",
)

alias(
    name = "python_op_gen_main",
    actual = "//tensorflow/python/framework:python_op_gen_main",
    visibility = ["//visibility:public"],
)

alias(
    name = "framework",
    actual = "//tensorflow/python/framework",
)

alias(
    name = "c_api_util",
    actual = "//tensorflow/python/framework:c_api_util",
)

alias(
    name = "constant_op",
    actual = "//tensorflow/python/framework:constant_op",
)

alias(
    name = "device_spec",
    actual = "//tensorflow/python/framework:device_spec",
)

alias(
    name = "device",
    actual = "//tensorflow/python/framework:device",
)

alias(
    name = "_dtypes",
    actual = "//tensorflow/python/framework:_dtypes",
)

alias(
    name = "dtypes",
    actual = "//tensorflow/python/framework:dtypes",
)

alias(
    name = "errors",
    actual = "//tensorflow/python/framework:errors",
)

alias(
    name = "error_interpolation",
    actual = "//tensorflow/python/framework:error_interpolation",
)

alias(
    name = "function",
    actual = "//tensorflow/python/framework:function",
)

alias(
    name = "graph_to_function_def",
    actual = "//tensorflow/python/framework:graph_to_function_def",
)

alias(
    name = "function_def_to_graph",
    actual = "//tensorflow/python/framework:function_def_to_graph",
    visibility = visibility + ["//waymo/ml:__subpackages__"],
)

alias(
    name = "graph_util",
    actual = "//tensorflow/python/framework:graph_util",
)

alias(
    name = "convert_to_constants",
    actual = "//tensorflow/python/framework:convert_to_constants",
    visibility = visibility + ["//waymo/ml:__subpackages__"],
)

alias(
    name = "kernels",
    actual = "//tensorflow/python/framework:kernels",
)

alias(
    name = "op_def_registry",
    actual = "//tensorflow/python/framework:op_def_registry",
)

alias(
    name = "framework_ops",
    actual = "//tensorflow/python/framework:ops",
)

alias(
    name = "framework_for_generated_wrappers",
    actual = "//tensorflow/python/framework:for_generated_wrappers",
    visibility = ["//visibility:public"],
)

alias(
    name = "framework_for_generated_wrappers_v2",
    actual = "//tensorflow/python/framework:for_generated_wrappers_v2",
    visibility = ["//visibility:public"],
)

alias(
    name = "op_callbacks",
    actual = "//tensorflow/python/framework:op_callbacks",
)

alias(
    name = "indexed_slices",
    actual = "//tensorflow/python/framework:indexed_slices",
)

alias(
    name = "func_graph",
    actual = "//tensorflow/python/framework:func_graph",
)

alias(
    name = "auto_control_deps",
    actual = "//tensorflow/python/framework:auto_control_deps",
)

alias(
    name = "config",
    actual = "//tensorflow/python/framework:config",
)

alias(
    name = "random_seed",
    actual = "//tensorflow/python/framework:random_seed",
)

alias(
    name = "smart_cond",
    actual = "//tensorflow/python/framework:smart_cond",
)

alias(
    name = "sparse_tensor",
    actual = "//tensorflow/python/framework:sparse_tensor",
)

alias(
    name = "composite_tensor",
    actual = "//tensorflow/python/framework:composite_tensor",
    visibility = visibility,
)

alias(
    name = "graph_building_benchmark",
    actual = "//tensorflow/python/framework:graph_building_benchmark",
)

alias(
    name = "tensor_shape",
    actual = "//tensorflow/python/framework:tensor_shape",
)

alias(
    name = "type_spec",
    actual = "//tensorflow/python/framework:type_spec",
    visibility = visibility,
)

alias(
    name = "tensor_spec",
    actual = "//tensorflow/python/framework:tensor_spec",
)

alias(
    name = "tensor_util",
    actual = "//tensorflow/python/framework:tensor_util",
)

alias(
    name = "versions",
    actual = "//tensorflow/python/framework:versions",
)

alias(
    name = "framework_test_lib",
    actual = "//tensorflow/python/framework:test_lib",
    visibility = visibility + [
        "//tensorflow_estimator/python/estimator:__subpackages__",
    ],
)

alias(
    name = "is_mlir_bridge_test_true",
    actual = "//tensorflow/python/framework:is_mlir_bridge_test_true",
    visibility = visibility + ["//tensorflow/compiler/tests:friends"],
)

alias(
    name = "is_tfrt_test_true",
    actual = "//tensorflow/python/framework:is_tfrt_test_true",
)

alias(
    name = "tfrt_utils",
    actual = "//tensorflow/python/framework:tfrt_utils",
)

alias(
    name = "framework_combinations",
    actual = "//tensorflow/python/framework:combinations",
)

alias(
    name = "framework_importer_test",
    actual = "//tensorflow/python/framework:importer_test",
)

alias(
    name = "framework_test_combinations_lib",
    actual = "//tensorflow/python/framework:test_combinations_lib",
)

alias(
    name = "framework_kernels_test",
    actual = "//tensorflow/python/framework:kernels_test",
)

alias(
    name = "framework_ops_test",
    actual = "//tensorflow/python/framework:ops_test",
)

alias(
    name = "framework_test_util_test",
    actual = "//tensorflow/python/framework:test_util_test",
)

alias(
    name = "function_def_to_graph_test",
    actual = "//tensorflow/python/framework:function_def_to_graph_test",
)

alias(
    name = "op_def_library_test",
    actual = "//tensorflow/python/framework:op_def_library_test",
)

alias(
    name = "config_test",
    actual = "//tensorflow/python/framework:config_test",
)

alias(
    name = "is_mlir_bridge_test_false",
    actual = "//tensorflow/python/framework:is_mlir_bridge_test_false",
    visibility = visibility + ["//tensorflow/compiler/tests:friends"],
)

alias(
    name = "memory_checker",
    actual = "//tensorflow/python/framework:memory_checker",
)

alias(
    name = "test_ops",
    actual = "//tensorflow/python/framework:test_ops",
)

alias(
    name = "test_ops_kernels",
    actual = "//tensorflow/python/framework:test_ops_kernels",
)

alias(
    name = "basic_session_run_hooks",
    actual = "//tensorflow/python/training:basic_session_run_hooks",
)

alias(
    name = "checkpoint_management",
    actual = "//tensorflow/python/training:checkpoint_management",
)

alias(
    name = "distribute",
    actual = "//tensorflow/python/training:distribute",
)

alias(
    name = "py_checkpoint_reader",
    actual = "//tensorflow/python/training:py_checkpoint_reader",
)

alias(
    name = "saver",
    actual = "//tensorflow/python/training:saver",
)

alias(
    name = "session_run_hook",
    actual = "//tensorflow/python/training:session_run_hook",
)

alias(
    name = "training",
    actual = "//tensorflow/python/training:training",
)

alias(
    name = "training_lib",
    actual = "//tensorflow/python/training:training_lib",
)

alias(
    name = "training_server_lib",
    actual = "//tensorflow/python/training:server_lib",
)

alias(
    name = "training_util",
    actual = "//tensorflow/python/training:training_util",
)

alias(
    name = "loss_scale",
    actual = "//tensorflow/python/training/experimental:loss_scale",
)

alias(
    name = "loss_scale_optimizer",
    actual = "//tensorflow/python/training/experimental:loss_scale_optimizer",
)

alias(
    name = "mixed_precision",
    actual = "//tensorflow/python/training/experimental:mixed_precision",
)

alias(
    name = "mixed_precision_global_state",
    actual = "//tensorflow/python/training/experimental:mixed_precision_global_state",
)

alias(
    name = "loss_scaling_gradient_tape",
    actual = "//tensorflow/python/training/experimental:loss_scaling_gradient_tape",
)

alias(
    name = "tf_optimizer",
    actual = "//tensorflow/python/grappler:tf_optimizer",
    visibility = ["//visibility:public"],
)

alias(
    name = "ops",
    actual = "//tensorflow/python/user_ops:ops",
)

alias(
    name = "layers_base",
    actual = "//tensorflow/python/layers:layers_base",
)

alias(
    name = "layers_util",
    actual = "//tensorflow/python/layers:layers_util",
)

alias(
    name = "layers",
    actual = "//tensorflow/python/layers:layers",
)

py_library(
    name = "learning_rate_decay",
    # This rule depends on a target that only python:__pkg__ has visibility for.
    srcs = ["//tensorflow/python/training:learning_rate_decay.py"],
    srcs_version = "PY3",
    deps = ["//tensorflow/python/keras/optimizer_v2:legacy_learning_rate_decay"],
)

# copybara:uncomment_begin(google-only)
# py_proto_library(
#     name = "protos_all_py_pb2",
#     has_services = 0,
#     api_version = 2,
#     deps = [":protos_all"],
# )
# copybara:uncomment_end
