Split tensorflow/python/debug targets
PiperOrigin-RevId: 374918018
Change-Id: I60a8668f1e450067c75afaccab86f7a5c0951861
diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD
index d0ac738..0f7f198 100644
--- a/tensorflow/python/BUILD
+++ b/tensorflow/python/BUILD
@@ -74,7 +74,7 @@
"//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/cli:__pkg__", # TODO(b/34059704): remove when fixed
+ "//tensorflow/python/debug:__pkg__", # TODO(b/34059704): remove when fixed
"//tensorflow/python/tools:__pkg__", # TODO(b/34059704): remove when fixed
"//tensorflow/tools/quantization:__pkg__", # TODO(b/34059704): remove when fixed
],
@@ -656,7 +656,7 @@
tf_gen_op_wrapper_private_py(
name = "debug_ops_gen",
out = "ops/gen_debug_ops.py",
- visibility = ["//tensorflow/python/debug/lib:__pkg__"],
+ visibility = ["//tensorflow/python/debug:__pkg__"],
deps = ["//tensorflow/core:debug_ops_op_lib"],
)
@@ -3008,6 +3008,7 @@
":array_ops",
":client_testlib",
":math_ops",
+ "//tensorflow/python/debug:check_numerics_callback",
"//tensorflow/python/eager:backprop",
"//tensorflow/python/eager:context",
"//tensorflow/python/framework:for_generated_wrappers",
diff --git a/tensorflow/python/debug/BUILD b/tensorflow/python/debug/BUILD
index 579bc5f..613f1f8 100644
--- a/tensorflow/python/debug/BUILD
+++ b/tensorflow/python/debug/BUILD
@@ -3,11 +3,14 @@
#
# Public target(s):
#
-# "//tensorflow/python/debug:debug_py": Public Python methods and classes of tfdbg.
+# ":debug_py": Public Python methods and classes of tfdbg.
# For API documentation, see https://www.tensorflow.org/api_docs/python/tfdbg
# For a user interface walkthrough, see https://www.tensorflow.org/guide/debugger
# ":grpc_debug_server": Server interface for grpc:// debug URLs.
+load("//tensorflow:tensorflow.bzl", "cuda_py_test")
+load("//tensorflow:tensorflow.bzl", "if_not_v2", "if_not_windows", "py_binary", "py_test")
+
package(
default_visibility = ["//tensorflow:internal"],
licenses = ["notice"],
@@ -19,38 +22,1440 @@
srcs_version = "PY3",
visibility = ["//visibility:public"],
deps = [
+ ":check_numerics_callback",
+ ":debug_data",
+ ":debug_events_monitors",
+ ":debug_events_reader",
+ ":debug_events_writer",
+ ":debug_gradients",
+ ":debug_graphs",
+ ":debug_utils",
+ ":dumping_callback",
+ ":dumping_callback_test_lib",
+ ":grpc_debug_server",
+ ":grpc_debug_test_server",
+ ":hooks",
+ ":local_cli_wrapper",
+ "//tensorflow/python:debug_ops_gen",
"//tensorflow/python:util",
- "//tensorflow/python/debug/lib:check_numerics_callback",
- "//tensorflow/python/debug/lib:debug_data",
- "//tensorflow/python/debug/lib:debug_events_monitors",
- "//tensorflow/python/debug/lib:debug_events_reader",
- "//tensorflow/python/debug/lib:debug_gradients",
- "//tensorflow/python/debug/lib:debug_graphs",
- "//tensorflow/python/debug/lib:debug_utils",
- "//tensorflow/python/debug/lib:dumping_callback",
- "//tensorflow/python/debug/lib:dumping_callback_test_lib",
- "//tensorflow/python/debug/lib:grpc_debug_server",
- "//tensorflow/python/debug/lib:grpc_debug_test_server",
- "//tensorflow/python/debug/wrappers:dumping_wrapper",
- "//tensorflow/python/debug/wrappers:framework",
- "//tensorflow/python/debug/wrappers:grpc_wrapper",
- "//tensorflow/python/debug/wrappers:hooks",
- "//tensorflow/python/debug/wrappers:local_cli_wrapper",
],
)
# Transitive dependencies of this target will be included in the pip package.
py_library(
name = "debug_pip",
- data = ["//tensorflow/python/debug/lib:grpc_tensorflow_server"],
+ data = [":grpc_tensorflow_server"],
srcs_version = "PY3",
deps = [
- "//tensorflow/python/debug:debug_py",
- "//tensorflow/python/debug/cli:cli_test_utils",
- "//tensorflow/python/debug/cli:offline_analyzer_lib",
- "//tensorflow/python/debug/lib:grpc_debug_test_server",
- "//tensorflow/python/debug/lib:grpc_tensorflow_server_lib",
- "//tensorflow/python/debug/lib:session_debug_testlib",
- "//tensorflow/python/debug/lib:source_remote",
+ ":cli_test_utils",
+ ":debug_py",
+ ":grpc_debug_test_server",
+ ":grpc_tensorflow_server_lib",
+ ":offline_analyzer_lib",
+ ":session_debug_testlib",
+ ":source_remote",
+ ] + if_not_windows([
+ ":debug_examples_v1",
+ ":debug_examples_v2",
+ ]),
+)
+
+py_library(
+ name = "op_callbacks_common",
+ srcs = ["lib/op_callbacks_common.py"],
+ srcs_version = "PY3",
+)
+
+py_library(
+ name = "check_numerics_callback",
+ srcs = ["lib/check_numerics_callback.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":op_callbacks_common",
+ ":source_utils",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:debug_ops_gen",
+ "//tensorflow/python:op_callbacks",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "dumping_callback",
+ srcs = ["lib/dumping_callback.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_events_writer",
+ ":op_callbacks_common",
+ ":source_utils",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:debug_ops_gen",
+ "//tensorflow/python:op_callbacks",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "dumping_callback_test_lib",
+ srcs = ["lib/dumping_callback_test_lib.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":check_numerics_callback",
+ ":debug_events_reader",
+ ":dumping_callback",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "common",
+ srcs = ["lib/common.py"],
+ srcs_version = "PY3",
+)
+
+py_library(
+ name = "debug_events_reader",
+ srcs = ["lib/debug_events_reader.py"],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:lib",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "debug_events_monitors",
+ srcs = ["lib/debug_events_monitors.py"],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:lib",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "debug_events_writer",
+ srcs = ["lib/debug_events_writer.py"],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework",
+ ],
+)
+
+py_library(
+ name = "debug_graphs",
+ srcs = ["lib/debug_graphs.py"],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:op_def_registry",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:tensor_util",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "debug_data",
+ srcs = ["lib/debug_data.py"],
+ srcs_version = "PY3",
+ visibility = [
+ "//tensorflow:internal",
+ "//third_party/py/tf_slim:__subpackages__",
+ ],
+ deps = [
+ ":debug_graphs",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:op_def_registry",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:tensor_util",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "debug_gradients",
+ srcs = ["lib/debug_gradients.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_data",
+ ":debug_graphs",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:platform",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "debug_utils",
+ srcs = ["lib/debug_utils.py"],
+ srcs_version = "PY3",
+)
+
+py_binary(
+ name = "grpc_tensorflow_server",
+ srcs = ["lib/grpc_tensorflow_server.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":grpc_tensorflow_server_lib"],
+)
+
+py_library(
+ name = "grpc_tensorflow_server_lib",
+ srcs = [
+ "lib/grpc_tensorflow_server.py",
+ ],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:training",
+ ],
+)
+
+py_library(
+ name = "source_utils",
+ srcs = ["lib/source_utils.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":profiling",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "source_remote",
+ srcs = ["lib/source_remote.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":common",
+ ":debug_service_pb2_grpc",
+ "//tensorflow/core/debug:debug_service_proto_py",
+ "//tensorflow/python/profiler:tfprof_logger",
+ ],
+)
+
+py_library(
+ name = "framework",
+ srcs = ["wrappers/framework.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_utils",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:framework_ops",
+ "//tensorflow/python:training",
+ ],
+)
+
+py_library(
+ name = "debugger_cli_common",
+ srcs = ["cli/debugger_cli_common.py"],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/python:platform",
+ "//tensorflow/python:pywrap_tf_session",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "cli_config",
+ srcs = ["cli/cli_config.py"],
+ srcs_version = "PY3",
+ deps = [":debugger_cli_common"],
+)
+
+py_library(
+ name = "command_parser",
+ srcs = ["cli/command_parser.py"],
+ srcs_version = "PY3",
+)
+
+py_library(
+ name = "tensor_format",
+ srcs = ["cli/tensor_format.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_data",
+ ":debugger_cli_common",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "cli_shared",
+ srcs = ["cli/cli_shared.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":command_parser",
+ ":common",
+ ":debugger_cli_common",
+ ":tensor_format",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "evaluator",
+ srcs = ["cli/evaluator.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_data",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "analyzer_cli",
+ srcs = ["cli/analyzer_cli.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":cli_config",
+ ":cli_shared",
+ ":command_parser",
+ ":debug_graphs",
+ ":debugger_cli_common",
+ ":evaluator",
+ ":source_utils",
+ ":ui_factory",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "profiling",
+ srcs = ["lib/profiling.py"],
+ srcs_version = "PY3",
+)
+
+py_library(
+ name = "profile_analyzer_cli",
+ srcs = ["cli/profile_analyzer_cli.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":cli_shared",
+ ":command_parser",
+ ":debugger_cli_common",
+ ":profiling",
+ ":source_utils",
+ ":ui_factory",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "base_ui",
+ srcs = ["cli/base_ui.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":cli_config",
+ ":command_parser",
+ ":debugger_cli_common",
+ ],
+)
+
+py_library(
+ name = "curses_widgets",
+ srcs = ["cli/curses_widgets.py"],
+ srcs_version = "PY3",
+ deps = [":debugger_cli_common"],
+)
+
+py_library(
+ name = "curses_ui",
+ srcs = ["cli/curses_ui.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":base_ui",
+ ":cli_shared",
+ ":command_parser",
+ ":curses_widgets",
+ ":debugger_cli_common",
+ ":tensor_format",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "readline_ui",
+ srcs = ["cli/readline_ui.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":base_ui",
+ ":debugger_cli_common",
+ ],
+)
+
+py_library(
+ name = "ui_factory",
+ srcs = ["cli/ui_factory.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":curses_ui",
+ ":readline_ui",
+ ],
+)
+
+py_library(
+ name = "dumping_wrapper",
+ srcs = ["wrappers/dumping_wrapper.py"],
+ srcs_version = "PY3",
+ visibility = [
+ "//tensorflow:internal",
+ "//third_party/py/tf_slim:__subpackages__",
+ ],
+ deps = [
+ ":debug_data",
+ ":framework",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:platform",
+ ],
+)
+
+py_library(
+ name = "grpc_wrapper",
+ srcs = ["wrappers/grpc_wrapper.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":common",
+ ":framework",
+ ":source_remote",
+ ],
+)
+
+py_library(
+ name = "local_cli_wrapper",
+ srcs = ["wrappers/local_cli_wrapper.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":analyzer_cli",
+ ":cli_shared",
+ ":command_parser",
+ ":common",
+ ":debug_data",
+ ":debugger_cli_common",
+ ":framework",
+ ":profile_analyzer_cli",
+ ":tensor_format",
+ ":ui_factory",
+ ],
+)
+
+py_library(
+ name = "hooks",
+ srcs = ["wrappers/hooks.py"],
+ srcs_version = "PY3",
+ visibility = [
+ "//tensorflow:internal",
+ "//third_party/py/tf_slim:__subpackages__",
+ ],
+ deps = [
+ ":debug_utils",
+ ":dumping_wrapper",
+ ":framework",
+ ":grpc_wrapper",
+ ":local_cli_wrapper",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:training",
+ ],
+)
+
+py_binary(
+ name = "offline_analyzer",
+ srcs = ["cli/offline_analyzer.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":offline_analyzer_lib"],
+)
+
+py_library(
+ name = "offline_analyzer_lib",
+ srcs = ["cli/offline_analyzer.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":analyzer_cli",
+ ":debug_data",
+ "//tensorflow/python", # TODO(b/34059704): remove when fixed
+ "//tensorflow/python:platform",
+ ],
+)
+
+py_library(
+ name = "debug_examples_v1",
+ srcs_version = "PY3",
+ deps = [
+ ":debug_errors_lib",
+ ":debug_fibonacci_lib",
+ ":debug_keras_lib",
+ ] + if_not_v2([
+ ":debug_mnist_lib",
+ ":debug_tflearn_iris_lib",
+ ]),
+)
+
+py_library(
+ name = "debug_examples_v2",
+ srcs_version = "PY3",
+ deps = [
+ ":debug_fibonacci_lib",
+ ":debug_mnist_lib",
+ ],
+)
+
+py_binary(
+ name = "debug_fibonacci",
+ srcs = ["examples/v1/debug_fibonacci.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_fibonacci_lib"],
+)
+
+py_binary(
+ name = "debug_fibonacci_v2",
+ srcs = ["examples/v2/debug_fibonacci_v2.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_fibonacci_lib"],
+)
+
+py_library(
+ name = "debug_fibonacci_lib",
+ srcs = [
+ "examples/v1/debug_fibonacci.py",
+ "examples/v2/debug_fibonacci_v2.py",
+ ],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_py",
+ "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_binary(
+ name = "debug_errors",
+ srcs = ["examples/v1/debug_errors.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_errors_lib"],
+)
+
+py_library(
+ name = "debug_errors_lib",
+ srcs = ["examples/v1/debug_errors.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_py",
+ "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_binary(
+ name = "debug_mnist",
+ srcs = ["examples/debug_mnist.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_mnist_lib"],
+)
+
+py_binary(
+ name = "debug_mnist_v1",
+ srcs = ["examples/v1/debug_mnist_v1.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_mnist_lib"],
+)
+
+py_binary(
+ name = "debug_mnist_v2",
+ srcs = ["examples/v2/debug_mnist_v2.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_mnist_lib"],
+)
+
+py_library(
+ name = "debug_mnist_lib",
+ srcs = [
+ "examples/debug_mnist.py",
+ "examples/v1/debug_mnist_v1.py",
+ "examples/v2/debug_mnist_v2.py",
+ ],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_py",
+ "//tensorflow:tensorflow_py",
+ ],
+)
+
+py_binary(
+ name = "debug_tflearn_iris",
+ srcs = ["examples/v1/debug_tflearn_iris.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_tflearn_iris_lib"],
+)
+
+py_library(
+ name = "debug_tflearn_iris_lib",
+ srcs = ["examples/v1/debug_tflearn_iris.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_py",
+ "//tensorflow:tensorflow_py",
+ "@six_archive//:six",
+ ],
+)
+
+py_binary(
+ name = "debug_keras",
+ srcs = ["examples/v1/debug_keras.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [":debug_keras_lib"],
+)
+
+py_library(
+ name = "debug_keras_lib",
+ srcs = ["examples/v1/debug_keras.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_py",
+ "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "common_test",
+ size = "small",
+ srcs = ["lib/common_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":common",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:constant_op",
+ "//tensorflow/python:platform_test",
+ ],
+)
+
+py_test(
+ name = "debug_events_monitors_test",
+ size = "medium",
+ srcs = ["lib/debug_events_monitors_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = [
+ "no_windows", # b/142475891
+ ],
+ deps = [
+ ":debug_events_monitors",
+ ":debug_events_reader",
+ ":debug_events_writer",
+ ":dumping_callback",
+ ":dumping_callback_test_lib",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_test_lib",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "debug_events_writer_test",
+ size = "medium",
+ srcs = ["lib/debug_events_writer_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = [
+ "no_windows", # b/142475891
+ ],
+ deps = [
+ ":debug_events_reader",
+ ":debug_events_writer",
+ ":dumping_callback_test_lib",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_test_lib",
+ ],
+)
+
+py_test(
+ name = "debug_graphs_test",
+ size = "small",
+ srcs = ["lib/debug_graphs_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = ["no_windows"], # TODO(b/184424727): Enable this test on Windows.
+ deps = [
+ ":debug_graphs",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_test_lib",
+ ],
+)
+
+py_test(
+ name = "debug_data_test",
+ size = "small",
+ srcs = ["lib/debug_data_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = ["no_windows"], # TODO(b/184424727): Enable this test on Windows.
+ deps = [
+ ":debug_data",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:platform_test",
+ "//third_party/py/numpy",
+ ],
+)
+
+cuda_py_test(
+ name = "check_numerics_callback_test",
+ size = "medium",
+ srcs = ["lib/check_numerics_callback_test.py"],
+ python_version = "PY3",
+ tags = [
+ "no_mac", # TODO(b/175322370): Detected Infinity or NaN in output 0 of graph op "RealDiv"
+ "no_windows",
+ ],
+ deps = [
+ ":check_numerics_callback",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ ],
+)
+
+cuda_py_test(
+ name = "dumping_callback_test",
+ size = "medium",
+ srcs = ["lib/dumping_callback_test.py"],
+ python_version = "PY3",
+ shard_count = 4,
+ tags = [
+ "no_windows", # TODO(b/142475891): Enable this test on Windows.
+ ],
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_events_reader",
+ ":debug_events_writer",
+ ":dumping_callback",
+ ":dumping_callback_test_lib",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ ],
+)
+
+cuda_py_test(
+ name = "debug_v2_ops_test",
+ size = "medium",
+ srcs = ["lib/debug_v2_ops_test.py"],
+ python_version = "PY3",
+ tags = ["no_windows_gpu"],
+ deps = [
+ ":debug_events_reader",
+ ":debug_events_writer",
+ ":dumping_callback_test_lib",
+ "//tensorflow/python:debug_ops_gen",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:gradients",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ "//tensorflow/python/data/ops:dataset_ops",
+ "//third_party/py/numpy",
+ ],
+)
+
+cuda_py_test(
+ name = "debug_gradients_test",
+ size = "small",
+ srcs = ["lib/debug_gradients_test.py"],
+ python_version = "PY3",
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_data",
+ ":debug_gradients",
+ ":debug_utils",
+ "//tensorflow/python:client",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:gradients",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ ],
+)
+
+py_test(
+ name = "debug_utils_test",
+ size = "small",
+ srcs = ["lib/debug_utils_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":debug_utils",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:resource_variable_ops",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "source_utils_test",
+ size = "small",
+ srcs = ["lib/source_utils_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = [
+ "no_windows",
+ ],
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ ":source_utils",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client",
+ "//tensorflow/python:cond_v2",
+ "//tensorflow/python:constant_op",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:framework_ops",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:resource_variable_ops",
+ "//tensorflow/python:util",
+ "//tensorflow/python:variables",
+ "//tensorflow/python:while_v2",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "source_remote_test",
+ size = "small",
+ srcs = ["lib/source_remote_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = [
+ "no_windows",
+ "oss_serial",
+ ],
+ deps = [
+ ":grpc_debug_test_server",
+ ":source_remote",
+ ":source_utils",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_ops",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:resource_variable_ops",
+ "//tensorflow/python:util",
+ "//tensorflow/python:variables",
+ ],
+)
+
+py_test(
+ name = "framework_test",
+ size = "medium",
+ srcs = ["wrappers/framework_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = ["no_rocm"],
+ deps = [
+ ":debug_data",
+ ":framework",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:resource_variable_ops",
+ "//tensorflow/python:training",
+ "//tensorflow/python:util",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "profiling_test",
+ size = "small",
+ srcs = ["lib/profiling_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":profiling",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform_test",
+ ],
+)
+
+py_test(
+ name = "curses_ui_test",
+ size = "small",
+ srcs = ["cli/curses_ui_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = [
+ "no_windows",
+ ],
+ deps = [
+ ":cli_test_utils",
+ ":curses_ui",
+ ":debugger_cli_common",
+ ":tensor_format",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:platform_test",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "readline_ui_test",
+ size = "small",
+ srcs = ["cli/readline_ui_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":cli_config",
+ ":debugger_cli_common",
+ ":readline_ui",
+ ":ui_factory",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:platform_test",
+ ],
+)
+
+py_library(
+ name = "session_debug_testlib",
+ srcs = ["lib/session_debug_testlib.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_data",
+ ":debug_graphs",
+ ":debug_utils",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:data_flow_ops",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:parsing_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:rnn",
+ "//tensorflow/python:rnn_cell",
+ "//tensorflow/python:state_ops",
+ "//tensorflow/python:tensor_array_grad",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "debug_service_pb2_grpc",
+ srcs = ["lib/debug_service_pb2_grpc.py"],
+ srcs_version = "PY3",
+ deps = [
+ "//tensorflow/core/debug:debug_service_proto_py",
+ ],
+)
+
+py_library(
+ name = "grpc_debug_server",
+ srcs = ["lib/grpc_debug_server.py"],
+ srcs_version = "PY3",
+ visibility = ["//visibility:public"],
+ deps = [
+ ":debug_graphs",
+ ":debug_service_pb2_grpc",
+ "//tensorflow/core/debug:debug_service_proto_py",
+ "@six_archive//:six",
+ ],
+)
+
+py_library(
+ name = "grpc_debug_test_server",
+ srcs = ["lib/grpc_debug_test_server.py"],
+ srcs_version = "PY3",
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ ":grpc_debug_server",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client",
+ "//tensorflow/python:constant_op",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:variables",
+ ],
+)
+
+cuda_py_test(
+ name = "debug_grappler_test",
+ size = "small",
+ srcs = ["lib/debug_grappler_test.py"],
+ python_version = "PY3",
+ xla_enable_strict_auto_jit = False, # Tests TF:Classic implementation.
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ "//tensorflow/python:client",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ ],
+)
+
+cuda_py_test(
+ name = "session_debug_file_test",
+ size = "small",
+ srcs = ["lib/session_debug_file_test.py"],
+ python_version = "PY3",
+ tags = ["notsan"],
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ ":session_debug_testlib",
+ "//tensorflow/python:client",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ ],
+)
+
+cuda_py_test(
+ name = "debug_graph_reconstruction_test",
+ size = "small",
+ srcs = ["lib/debug_graph_reconstruction_test.py"],
+ python_version = "PY3",
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ ],
+)
+
+cuda_py_test(
+ name = "session_debug_multi_gpu_test",
+ size = "small",
+ srcs = ["lib/session_debug_multi_gpu_test.py"],
+ python_version = "PY3",
+ tags = ["no_windows_gpu"],
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ "//tensorflow/python:client",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ ],
+)
+
+py_test(
+ name = "debugger_cli_common_test",
+ size = "small",
+ srcs = ["cli/debugger_cli_common_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":debugger_cli_common",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:pywrap_tf_session",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "cli_config_test",
+ size = "small",
+ srcs = ["cli/cli_config_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":cli_config",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:platform_test",
+ ],
+)
+
+py_test(
+ name = "command_parser_test",
+ size = "small",
+ srcs = ["cli/command_parser_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":command_parser",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform_test",
+ ],
+)
+
+py_test(
+ name = "tensor_format_test",
+ size = "small",
+ srcs = ["cli/tensor_format_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":cli_test_utils",
+ ":debug_data",
+ ":tensor_format",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform_test",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_test(
+ name = "cli_shared_test",
+ size = "small",
+ srcs = ["cli/cli_shared_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":cli_shared",
+ ":debugger_cli_common",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:sparse_tensor",
+ "//tensorflow/python:variables",
+ ],
+)
+
+py_test(
+ name = "evaluator_test",
+ size = "small",
+ srcs = [
+ "cli/evaluator_test.py",
+ ],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ tags = ["no_windows"], # TODO(b/184424727): Enable this test on Windows.
+ deps = [
+ ":debug_data",
+ ":evaluator",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_test_lib",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_library(
+ name = "cli_test_utils",
+ srcs = ["cli/cli_test_utils.py"],
+ srcs_version = "PY3",
+)
+
+cuda_py_test(
+ name = "analyzer_cli_test",
+ size = "small",
+ srcs = ["cli/analyzer_cli_test.py"],
+ python_version = "PY3",
+ tags = ["no_windows"], # TODO: needs investigation on Windows
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":analyzer_cli",
+ ":cli_config",
+ ":cli_test_utils",
+ ":command_parser",
+ ":debug_data",
+ ":debug_utils",
+ ":debugger_cli_common",
+ ":source_utils",
+ "//tensorflow:tensorflow_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:util",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
+ ],
+)
+
+py_test(
+ name = "profile_analyzer_cli_test",
+ size = "small",
+ srcs = ["cli/profile_analyzer_cli_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":debugger_cli_common",
+ ":profile_analyzer_cli",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:session",
+ "//tensorflow/python:util",
+ ],
+)
+
+cuda_py_test(
+ name = "session_debug_grpc_test",
+ size = "medium",
+ srcs = ["lib/session_debug_grpc_test.py"],
+ python_version = "PY3",
+ tags = [
+ "no_oss", # Test flaky due to port collisions.
+ "no_windows",
+ "notap", # TODO(b/160925973): Test flaky due to port collisions.
+ "notsan",
+ "oss_serial",
+ ],
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ ":dumping_wrapper",
+ ":grpc_debug_test_server",
+ ":grpc_wrapper",
+ ":hooks",
+ ":session_debug_testlib",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ ],
+)
+
+cuda_py_test(
+ name = "grpc_large_data_test",
+ size = "medium",
+ srcs = ["lib/grpc_large_data_test.py"],
+ python_version = "PY3",
+ tags = [
+ "no_oss", # Test flaky due to port collisions.
+ "no_windows",
+ "noasan", # Times out due to size of test (b/73731462).
+ "notap", # TODO(b/153898535) flaky
+ "optonly", # Test flaky (b/80130873)
+ "oss_serial",
+ ],
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":dumping_wrapper",
+ ":grpc_debug_test_server",
+ ":grpc_wrapper",
+ ":session_debug_testlib",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ ],
+)
+
+# TODO(cais): Run the test in OSS, perhaps through a sh_test.
+cuda_py_test(
+ name = "dist_session_debug_grpc_test",
+ size = "medium",
+ srcs = ["lib/dist_session_debug_grpc_test.py"],
+ grpc_enabled = True,
+ python_version = "PY3",
+ tags = [
+ "no_oss", # Incompatible with bazel_pip.
+ "no_windows",
+ "notap", # TODO(b/160822489) flaky timeouts
+ "notsan",
+ ],
+ xla_enable_strict_auto_jit = False, # Node names are different with autojit
+ deps = [
+ ":debug_data",
+ ":debug_utils",
+ ":dumping_wrapper",
+ ":grpc_debug_test_server",
+ ":grpc_wrapper",
+ ":hooks",
+ "//tensorflow/python:client",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
+ ],
+)
+
+py_test(
+ name = "dumping_wrapper_test",
+ size = "small",
+ srcs = ["wrappers/dumping_wrapper_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":debug_data",
+ ":dumping_wrapper",
+ ":framework",
+ ":hooks",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:state_ops",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ ],
+)
+
+py_test(
+ name = "local_cli_wrapper_test",
+ size = "small",
+ srcs = ["wrappers/local_cli_wrapper_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":cli_shared",
+ ":debugger_cli_common",
+ ":local_cli_wrapper",
+ ":ui_factory",
+ "//tensorflow/core:protos_all_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:resource_variable_ops",
+ "//tensorflow/python:state_ops",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ "//third_party/py/numpy",
+ ],
+)
+
+py_test(
+ name = "disk_usage_test",
+ size = "small",
+ srcs = ["wrappers/disk_usage_test.py"],
+ python_version = "PY3",
+ srcs_version = "PY3",
+ deps = [
+ ":dumping_wrapper",
+ ":hooks",
+ "//tensorflow/python:client",
+ "//tensorflow/python:errors",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform_test",
+ "//tensorflow/python:training",
+ "//tensorflow/python:variables",
+ ],
+)
+
+sh_test(
+ name = "examples_v1_test",
+ size = "medium",
+ srcs = ["examples/v1/examples_v1_test.sh"],
+ data = [
+ ":debug_errors",
+ ":debug_fibonacci",
+ ":debug_keras",
+ ":debug_mnist_v1",
+ ":debug_tflearn_iris",
+ ":offline_analyzer",
+ ],
+ tags = [
+ "no_windows",
+ "noasan", # TODO(b/143150907)
+ "nomsan", # TODO(b/143150907)
+ "v1only",
+ ],
+)
+
+sh_test(
+ name = "examples_v2_test",
+ size = "medium",
+ srcs = ["examples/v2/examples_v2_test.sh"],
+ data = [
+ ":debug_fibonacci_v2",
+ ":debug_mnist_v2",
+ ],
+ tags = [
+ "no_windows",
],
)
diff --git a/tensorflow/python/debug/cli/BUILD b/tensorflow/python/debug/cli/BUILD
deleted file mode 100644
index 19008a1..0000000
--- a/tensorflow/python/debug/cli/BUILD
+++ /dev/null
@@ -1,381 +0,0 @@
-load("//tensorflow:tensorflow.bzl", "cuda_py_test")
-load("//tensorflow:tensorflow.bzl", "py_binary", "py_test")
-
-package(
- default_visibility = ["//tensorflow:internal"],
- licenses = ["notice"],
-)
-
-py_library(
- name = "profile_analyzer_cli",
- srcs = ["profile_analyzer_cli.py"],
- srcs_version = "PY3",
- deps = [
- ":cli_shared",
- ":command_parser",
- ":debugger_cli_common",
- ":ui_factory",
- "//tensorflow/python/debug/lib:profiling",
- "//tensorflow/python/debug/lib:source_utils",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "base_ui",
- srcs = ["base_ui.py"],
- srcs_version = "PY3",
- deps = [
- ":cli_config",
- ":command_parser",
- ":debugger_cli_common",
- ],
-)
-
-py_library(
- name = "curses_widgets",
- srcs = ["curses_widgets.py"],
- srcs_version = "PY3",
- deps = [":debugger_cli_common"],
-)
-
-py_library(
- name = "curses_ui",
- srcs = ["curses_ui.py"],
- srcs_version = "PY3",
- deps = [
- ":base_ui",
- ":cli_shared",
- ":command_parser",
- ":curses_widgets",
- ":debugger_cli_common",
- ":tensor_format",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "readline_ui",
- srcs = ["readline_ui.py"],
- srcs_version = "PY3",
- deps = [
- ":base_ui",
- ":debugger_cli_common",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "ui_factory",
- srcs = ["ui_factory.py"],
- srcs_version = "PY3",
- deps = [
- ":curses_ui",
- ":readline_ui",
- ],
-)
-
-py_library(
- name = "command_parser",
- srcs = ["command_parser.py"],
- srcs_version = "PY3",
-)
-
-py_library(
- name = "tensor_format",
- srcs = ["tensor_format.py"],
- srcs_version = "PY3",
- deps = [
- ":debugger_cli_common",
- "//tensorflow/python/debug/lib:debug_data",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "cli_shared",
- srcs = ["cli_shared.py"],
- srcs_version = "PY3",
- deps = [
- ":command_parser",
- ":debugger_cli_common",
- ":tensor_format",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:platform",
- "//tensorflow/python:variables",
- "//tensorflow/python/debug/lib:common",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "evaluator",
- srcs = ["evaluator.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/python/debug/lib:debug_data",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "analyzer_cli",
- srcs = ["analyzer_cli.py"],
- srcs_version = "PY3",
- deps = [
- ":cli_config",
- ":cli_shared",
- ":command_parser",
- ":debugger_cli_common",
- ":evaluator",
- ":ui_factory",
- "//tensorflow/python/debug/lib:debug_graphs",
- "//tensorflow/python/debug/lib:source_utils",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "cli_config",
- srcs = ["cli_config.py"],
- srcs_version = "PY3",
- deps = [
- ":debugger_cli_common",
- "//tensorflow/python/platform",
- ],
-)
-
-py_library(
- name = "debugger_cli_common",
- srcs = ["debugger_cli_common.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/python:platform",
- "//tensorflow/python:pywrap_tf_session",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_binary(
- name = "offline_analyzer",
- srcs = ["offline_analyzer.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [":offline_analyzer_lib"],
-)
-
-py_library(
- name = "offline_analyzer_lib",
- srcs = ["offline_analyzer.py"],
- srcs_version = "PY3",
- deps = [
- ":analyzer_cli",
- "//tensorflow/python", # TODO(b/34059704): remove when fixed
- "//tensorflow/python:platform",
- "//tensorflow/python/debug/lib:debug_data",
- ],
-)
-
-py_test(
- name = "curses_ui_test",
- size = "small",
- srcs = ["curses_ui_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = [
- "no_windows",
- ],
- deps = [
- ":cli_config",
- ":cli_test_utils",
- ":curses_ui",
- ":debugger_cli_common",
- ":tensor_format",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform",
- "//tensorflow/python:platform_test",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_test(
- name = "readline_ui_test",
- size = "small",
- srcs = ["readline_ui_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":cli_config",
- ":debugger_cli_common",
- ":readline_ui",
- ":ui_factory",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform",
- "//tensorflow/python:platform_test",
- ],
-)
-
-py_test(
- name = "debugger_cli_common_test",
- size = "small",
- srcs = ["debugger_cli_common_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":debugger_cli_common",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:pywrap_tf_session",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "cli_config_test",
- size = "small",
- srcs = ["cli_config_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":cli_config",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform",
- "//tensorflow/python:platform_test",
- "//tensorflow/python/lib/io:lib",
- ],
-)
-
-py_test(
- name = "command_parser_test",
- size = "small",
- srcs = ["command_parser_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":command_parser",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform_test",
- ],
-)
-
-py_test(
- name = "tensor_format_test",
- size = "small",
- srcs = ["tensor_format_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":cli_test_utils",
- ":tensor_format",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform_test",
- "//tensorflow/python/debug/lib:debug_data",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "cli_shared_test",
- size = "small",
- srcs = ["cli_shared_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":cli_shared",
- ":debugger_cli_common",
- "//tensorflow/python:errors",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:sparse_tensor",
- "//tensorflow/python:variables",
- "//tensorflow/python/framework:constant_op",
- ],
-)
-
-py_test(
- name = "evaluator_test",
- size = "small",
- srcs = [
- "evaluator_test.py",
- ],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = ["no_windows"], # TODO(b/184424727): Enable this test on Windows.
- deps = [
- ":evaluator",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python/debug/lib:debug_data",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "cli_test_utils",
- srcs = ["cli_test_utils.py"],
- srcs_version = "PY3",
- deps = ["//third_party/py/numpy"],
-)
-
-cuda_py_test(
- name = "analyzer_cli_test",
- size = "small",
- srcs = ["analyzer_cli_test.py"],
- python_version = "PY3",
- tags = ["no_windows"], # TODO: needs investigation on Windows
- xla_enable_strict_auto_jit = False, # Node names are different with autojit
- deps = [
- ":analyzer_cli",
- ":cli_config",
- ":cli_shared",
- ":cli_test_utils",
- ":command_parser",
- ":debugger_cli_common",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:control_flow_ops",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:session",
- "//tensorflow/python:util",
- "//tensorflow/python:variables",
- "//tensorflow/python/debug/lib:debug_data",
- "//tensorflow/python/debug/lib:debug_utils",
- "//tensorflow/python/debug/lib:source_utils",
- "//tensorflow/python/framework:constant_op",
- "//tensorflow/python/lib/io:lib",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_test(
- name = "profile_analyzer_cli_test",
- size = "small",
- srcs = ["profile_analyzer_cli_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":debugger_cli_common",
- ":profile_analyzer_cli",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:control_flow_ops",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:session",
- "//tensorflow/python:util",
- "//tensorflow/python/framework:constant_op",
- ],
-)
diff --git a/tensorflow/python/debug/examples/debug_mnist.py b/tensorflow/python/debug/examples/debug_mnist.py
new file mode 100644
index 0000000..c7e51d1e
--- /dev/null
+++ b/tensorflow/python/debug/examples/debug_mnist.py
@@ -0,0 +1,45 @@
+# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+"""Redirect script that points to corresponding example based on tf version."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import sys
+
+import absl
+import tensorflow
+
+import tensorflow.python.debug.examples.v1.debug_mnist_v1 as debug_mnist_v1
+import tensorflow.python.debug.examples.v2.debug_mnist_v2 as debug_mnist_v2
+
+tf = tensorflow.compat.v1
+
+
+def main():
+ if tf.__version__.startswith("1."):
+ flags, unparsed = debug_mnist_v1.parse_args()
+ debug_mnist_v1.FLAGS = flags
+
+ with tf.Graph().as_default():
+ tf.app.run(main=debug_mnist_v1.main, argv=[sys.argv[0]] + unparsed)
+ else:
+ flags, unparsed = debug_mnist_v2.parse_args()
+ debug_mnist_v2.FLAGS = flags
+ absl.app.run(main=debug_mnist_v2.main, argv=[sys.argv[0]] + unparsed)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tensorflow/python/debug/examples/v1/BUILD b/tensorflow/python/debug/examples/v1/BUILD
deleted file mode 100644
index fdbf80d..0000000
--- a/tensorflow/python/debug/examples/v1/BUILD
+++ /dev/null
@@ -1,85 +0,0 @@
-package(
- default_visibility = ["//tensorflow:internal"],
- licenses = ["notice"],
-)
-
-py_binary(
- name = "debug_fibonacci",
- srcs = ["debug_fibonacci.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-py_binary(
- name = "debug_errors",
- srcs = ["debug_errors.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-py_binary(
- name = "debug_tflearn_iris",
- srcs = ["debug_tflearn_iris.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-py_binary(
- name = "debug_keras",
- srcs = ["debug_keras.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-py_binary(
- name = "debug_mnist",
- srcs = ["debug_mnist_v1.py"],
- main = "debug_mnist_v1.py",
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-sh_test(
- name = "examples_v1_test",
- size = "medium",
- srcs = ["examples_v1_test.sh"],
- data = [
- ":debug_errors",
- ":debug_fibonacci",
- ":debug_keras",
- ":debug_mnist",
- ":debug_tflearn_iris",
- "//tensorflow/python/debug/cli:offline_analyzer",
- ],
- tags = [
- "no_windows",
- "noasan", # TODO(b/143150907)
- "nomsan", # TODO(b/143150907)
- "v1only",
- ],
-)
diff --git a/tensorflow/python/debug/examples/v1/examples_v1_test.sh b/tensorflow/python/debug/examples/v1/examples_v1_test.sh
index 99cf91f..e59b357 100755
--- a/tensorflow/python/debug/examples/v1/examples_v1_test.sh
+++ b/tensorflow/python/debug/examples/v1/examples_v1_test.sh
@@ -44,16 +44,16 @@
done
if [[ -z "${PYTHON_BIN_PATH}" ]]; then
- DEBUG_FIBONACCI_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v1/debug_fibonacci"
- DEBUG_ERRORS_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v1/debug_errors"
- DEBUG_MNIST_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v1/debug_mnist"
- DEBUG_TFLEARN_IRIS_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v1/debug_tflearn_iris"
- DEBUG_KERAS_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v1/debug_keras"
- OFFLINE_ANALYZER_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/cli/offline_analyzer"
+ DEBUG_FIBONACCI_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_fibonacci"
+ DEBUG_ERRORS_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_errors"
+ DEBUG_MNIST_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_mnist_v1"
+ DEBUG_TFLEARN_IRIS_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_tflearn_iris"
+ DEBUG_KERAS_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_keras"
+ OFFLINE_ANALYZER_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/offline_analyzer"
else
DEBUG_FIBONACCI_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v1.debug_fibonacci"
DEBUG_ERRORS_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v1.debug_errors"
- DEBUG_MNIST_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v1.debug_mnist"
+ DEBUG_MNIST_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v1.debug_mnist_v1"
DEBUG_TFLEARN_IRIS_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v1.debug_tflearn_iris"
DEBUG_KERAS_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v1.debug_keras"
OFFLINE_ANALYZER_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.cli.offline_analyzer"
diff --git a/tensorflow/python/debug/examples/v2/BUILD b/tensorflow/python/debug/examples/v2/BUILD
deleted file mode 100644
index f46a3c3..0000000
--- a/tensorflow/python/debug/examples/v2/BUILD
+++ /dev/null
@@ -1,45 +0,0 @@
-package(
- default_visibility = ["//tensorflow:internal"],
- licenses = ["notice"],
-)
-
-py_binary(
- name = "debug_fibonacci_v2",
- srcs = ["debug_fibonacci_v2.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-py_binary(
- name = "debug_mnist_v2",
- srcs = ["debug_mnist_v2.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//tensorflow:tensorflow_py",
- "//tensorflow/python/debug:debug_py",
- "//third_party/py/numpy",
- ],
-)
-
-sh_test(
- name = "examples_v2_test",
- size = "medium",
- srcs = ["examples_v2_test.sh"],
- data = [
- ":debug_fibonacci_v2",
- ":debug_mnist_v2",
- "//tensorflow/python/debug/cli:offline_analyzer",
- ],
- tags = [
- "no_windows",
- "noasan", # TODO(b/143150907)
- "nomsan", # TODO(b/143150907)
- "v2only",
- ],
-)
diff --git a/tensorflow/python/debug/examples/v2/examples_v2_test.sh b/tensorflow/python/debug/examples/v2/examples_v2_test.sh
index 3a3624b..8aebf79 100755
--- a/tensorflow/python/debug/examples/v2/examples_v2_test.sh
+++ b/tensorflow/python/debug/examples/v2/examples_v2_test.sh
@@ -44,8 +44,8 @@
done
if [[ -z "${PYTHON_BIN_PATH}" ]]; then
- DEBUG_FIBONACCI_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v2/debug_fibonacci_v2"
- DEBUG_MNIST_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/examples/v2/debug_mnist_v2"
+ DEBUG_FIBONACCI_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_fibonacci_v2"
+ DEBUG_MNIST_BIN="$TEST_SRCDIR/org_tensorflow/tensorflow/python/debug/debug_mnist_v2"
else
DEBUG_FIBONACCI_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v2.debug_fibonacci"
DEBUG_MNIST_BIN="${PYTHON_BIN_PATH} -m tensorflow.python.debug.examples.v2.debug_mnist"
diff --git a/tensorflow/python/debug/lib/BUILD b/tensorflow/python/debug/lib/BUILD
deleted file mode 100644
index db91623..0000000
--- a/tensorflow/python/debug/lib/BUILD
+++ /dev/null
@@ -1,603 +0,0 @@
-load("//tensorflow:tensorflow.bzl", "cuda_py_test")
-load("//tensorflow:tensorflow.bzl", "py_binary", "py_test")
-
-package(
- default_visibility = ["//tensorflow:internal"],
- licenses = ["notice"],
-)
-
-py_library(
- name = "op_callbacks_common",
- srcs = ["op_callbacks_common.py"],
- srcs_version = "PY3",
-)
-
-py_library(
- name = "check_numerics_callback",
- srcs = ["check_numerics_callback.py"],
- srcs_version = "PY3",
- deps = [
- ":op_callbacks_common",
- ":source_utils",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:debug_ops_gen",
- "//tensorflow/python:op_callbacks",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "dumping_callback",
- srcs = ["dumping_callback.py"],
- srcs_version = "PY3",
- deps = [
- ":debug_events_writer",
- ":op_callbacks_common",
- ":source_utils",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:debug_ops_gen",
- "//tensorflow/python:op_callbacks",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "dumping_callback_test_lib",
- srcs = ["dumping_callback_test_lib.py"],
- srcs_version = "PY3",
- deps = [
- ":check_numerics_callback",
- ":debug_events_reader",
- ":dumping_callback",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "common",
- srcs = ["common.py"],
- srcs_version = "PY3",
-)
-
-py_library(
- name = "debug_events_reader",
- srcs = ["debug_events_reader.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:framework",
- "//tensorflow/python:lib",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "debug_events_monitors",
- srcs = ["debug_events_monitors.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:framework",
- "//tensorflow/python:lib",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "debug_events_writer",
- srcs = ["debug_events_writer.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:framework",
- ],
-)
-
-py_library(
- name = "debug_graphs",
- srcs = ["debug_graphs.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:framework",
- "//tensorflow/python:op_def_registry",
- "//tensorflow/python:platform",
- "//tensorflow/python:tensor_util",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "debug_data",
- srcs = ["debug_data.py"],
- srcs_version = "PY3",
- visibility = [
- "//tensorflow:internal",
- "//third_party/py/tf_slim:__subpackages__",
- ],
- deps = [
- ":debug_graphs",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:framework",
- "//tensorflow/python:op_def_registry",
- "//tensorflow/python:platform",
- "//tensorflow/python:tensor_util",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "debug_gradients",
- srcs = ["debug_gradients.py"],
- srcs_version = "PY3",
- deps = [
- ":debug_data",
- ":debug_graphs",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:framework",
- "//tensorflow/python:platform",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "debug_utils",
- srcs = ["debug_utils.py"],
- srcs_version = "PY3",
-)
-
-py_binary(
- name = "grpc_tensorflow_server",
- srcs = ["grpc_tensorflow_server.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [":grpc_tensorflow_server_lib"],
-)
-
-py_library(
- name = "grpc_tensorflow_server_lib",
- srcs = [
- "grpc_tensorflow_server.py",
- ],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:platform",
- "//tensorflow/python:training",
- ],
-)
-
-py_library(
- name = "source_utils",
- srcs = ["source_utils.py"],
- srcs_version = "PY3",
- deps = [
- ":profiling",
- "//third_party/py/numpy",
- ],
-)
-
-py_library(
- name = "source_remote",
- srcs = ["source_remote.py"],
- srcs_version = "PY3",
- deps = [
- ":common",
- ":debug_service_pb2_grpc",
- "//tensorflow/core/debug:debug_service_proto_py",
- "//tensorflow/python/profiler:tfprof_logger",
- ],
-)
-
-py_library(
- name = "profiling",
- srcs = ["profiling.py"],
- srcs_version = "PY3",
-)
-
-py_test(
- name = "common_test",
- size = "small",
- srcs = ["common_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":common",
- "//tensorflow/python:client",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:constant_op",
- "//tensorflow/python:platform_test",
- ],
-)
-
-py_test(
- name = "debug_events_monitors_test",
- size = "medium",
- srcs = ["debug_events_monitors_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = [
- "no_windows", # b/142475891
- ],
- deps = [
- ":debug_events_monitors",
- ":debug_events_reader",
- ":debug_events_writer",
- ":dumping_callback",
- ":dumping_callback_test_lib",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:framework_test_lib",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "debug_events_writer_test",
- size = "medium",
- srcs = ["debug_events_writer_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = [
- "no_windows", # b/142475891
- ],
- deps = [
- ":debug_events_reader",
- ":debug_events_writer",
- ":dumping_callback_test_lib",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:framework_test_lib",
- ],
-)
-
-py_test(
- name = "debug_graphs_test",
- size = "small",
- srcs = ["debug_graphs_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = ["no_windows"], # TODO(b/184424727): Enable this test on Windows.
- deps = [
- ":debug_graphs",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:framework_test_lib",
- ],
-)
-
-py_test(
- name = "debug_data_test",
- size = "small",
- srcs = ["debug_data_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = ["no_windows"], # TODO(b/184424727): Enable this test on Windows.
- deps = [
- ":debug_data",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform",
- "//tensorflow/python:platform_test",
- "//third_party/py/numpy",
- ],
-)
-
-cuda_py_test(
- name = "check_numerics_callback_test",
- size = "medium",
- srcs = ["check_numerics_callback_test.py"],
- python_version = "PY3",
- tags = [
- "no_mac", # TODO(b/175322370): Detected Infinity or NaN in output 0 of graph op "RealDiv"
- "no_windows",
- ],
- deps = [
- ":check_numerics_callback",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:variables",
- "//third_party/py/numpy",
- ],
-)
-
-cuda_py_test(
- name = "dumping_callback_test",
- size = "medium",
- srcs = ["dumping_callback_test.py"],
- python_version = "PY3",
- shard_count = 4,
- tags = [
- "no_windows", # TODO(b/142475891): Enable this test on Windows.
- ],
- xla_enable_strict_auto_jit = False, # Node names are different with autojit
- deps = [
- ":debug_events_reader",
- ":debug_events_writer",
- ":dumping_callback",
- ":dumping_callback_test_lib",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:variables",
- "//third_party/py/numpy",
- ],
-)
-
-cuda_py_test(
- name = "debug_v2_ops_test",
- size = "medium",
- srcs = ["debug_v2_ops_test.py"],
- python_version = "PY3",
- tags = ["no_windows_gpu"],
- deps = [
- ":debug_events_reader",
- ":debug_events_writer",
- ":dumping_callback_test_lib",
- "//tensorflow/python:debug_ops_gen",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:gradients",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- "//tensorflow/python/data/ops:dataset_ops",
- "//third_party/py/numpy",
- ],
-)
-
-cuda_py_test(
- name = "debug_gradients_test",
- size = "small",
- srcs = ["debug_gradients_test.py"],
- python_version = "PY3",
- xla_enable_strict_auto_jit = False, # Node names are different with autojit
- deps = [
- ":debug_data",
- ":debug_gradients",
- ":debug_utils",
- "//tensorflow/python:client",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:gradients",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- ],
-)
-
-py_test(
- name = "debug_utils_test",
- size = "small",
- srcs = ["debug_utils_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":debug_utils",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:resource_variable_ops",
- "//tensorflow/python:variables",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "source_utils_test",
- size = "small",
- srcs = ["source_utils_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = [
- "no_windows",
- ],
- deps = [
- ":debug_data",
- ":debug_utils",
- ":source_utils",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client",
- "//tensorflow/python:cond_v2",
- "//tensorflow/python:constant_op",
- "//tensorflow/python:control_flow_ops",
- "//tensorflow/python:framework_ops",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:resource_variable_ops",
- "//tensorflow/python:util",
- "//tensorflow/python:variables",
- "//tensorflow/python:while_v2",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "source_remote_test",
- size = "small",
- srcs = ["source_remote_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = [
- "no_windows",
- "oss_serial",
- ],
- deps = [
- ":grpc_debug_test_server",
- ":source_remote",
- ":source_utils",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:framework_ops",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:resource_variable_ops",
- "//tensorflow/python:util",
- "//tensorflow/python:variables",
- ],
-)
-
-py_test(
- name = "profiling_test",
- size = "small",
- srcs = ["profiling_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":profiling",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform_test",
- ],
-)
-
-py_library(
- name = "session_debug_testlib",
- srcs = ["session_debug_testlib.py"],
- srcs_version = "PY3",
- deps = [
- ":debug_data",
- ":debug_graphs",
- ":debug_utils",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:client",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:control_flow_ops",
- "//tensorflow/python:data_flow_ops",
- "//tensorflow/python:errors",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:parsing_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:rnn",
- "//tensorflow/python:rnn_cell",
- "//tensorflow/python:state_ops",
- "//tensorflow/python:tensor_array_grad",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- "//third_party/py/numpy",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "debug_service_pb2_grpc",
- srcs = ["debug_service_pb2_grpc.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core/debug:debug_service_proto_py",
- ],
-)
-
-py_library(
- name = "grpc_debug_server",
- srcs = ["grpc_debug_server.py"],
- srcs_version = "PY3",
- visibility = ["//visibility:public"],
- deps = [
- ":debug_graphs",
- ":debug_service_pb2_grpc",
- "//tensorflow/core/debug:debug_service_proto_py",
- "@six_archive//:six",
- ],
-)
-
-py_library(
- name = "grpc_debug_test_server",
- srcs = ["grpc_debug_test_server.py"],
- srcs_version = "PY3",
- deps = [
- ":debug_data",
- ":debug_utils",
- ":grpc_debug_server",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client",
- "//tensorflow/python:constant_op",
- "//tensorflow/python:errors",
- "//tensorflow/python:variables",
- ],
-)
-
-cuda_py_test(
- name = "debug_grappler_test",
- size = "small",
- srcs = ["debug_grappler_test.py"],
- python_version = "PY3",
- xla_enable_strict_auto_jit = False, # Tests TF:Classic implementation.
- deps = [
- ":debug_data",
- ":debug_utils",
- "//tensorflow/python:client",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:variables",
- ],
-)
-
-cuda_py_test(
- name = "session_debug_file_test",
- size = "small",
- srcs = ["session_debug_file_test.py"],
- python_version = "PY3",
- tags = ["notsan"],
- xla_enable_strict_auto_jit = False, # Node names are different with autojit
- deps = [
- ":debug_data",
- ":debug_utils",
- ":session_debug_testlib",
- "//tensorflow/python:client",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:variables",
- ],
-)
-
-cuda_py_test(
- name = "debug_graph_reconstruction_test",
- size = "small",
- srcs = ["debug_graph_reconstruction_test.py"],
- python_version = "PY3",
- xla_enable_strict_auto_jit = False, # Node names are different with autojit
- deps = [
- ":debug_data",
- ":debug_utils",
- "//tensorflow/python:client",
- "//tensorflow/python:client_testlib",
- "//tensorflow/python:control_flow_ops",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- ],
-)
-
-cuda_py_test(
- name = "session_debug_multi_gpu_test",
- size = "small",
- srcs = ["session_debug_multi_gpu_test.py"],
- python_version = "PY3",
- tags = ["no_windows_gpu"],
- xla_enable_strict_auto_jit = False, # Node names are different with autojit
- deps = [
- ":debug_data",
- ":debug_utils",
- "//tensorflow/python:client",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:variables",
- ],
-)
diff --git a/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py b/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py
new file mode 100644
index 0000000..4b1d193
--- /dev/null
+++ b/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py
@@ -0,0 +1,233 @@
+# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+"""Tests for debugger functionalities in tf.compat.v1.Session with grpc:// URLs.
+
+This test focus on grpc:// debugging of distributed (gRPC) sessions.
+"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import json
+import subprocess
+import sys
+import time
+
+import portpicker
+from six.moves import xrange # pylint: disable=redefined-builtin
+
+from tensorflow.core.protobuf import config_pb2
+from tensorflow.python.client import session
+from tensorflow.python.debug.lib import debug_utils
+from tensorflow.python.debug.lib import grpc_debug_test_server
+from tensorflow.python.debug.wrappers import framework
+from tensorflow.python.debug.wrappers import grpc_wrapper
+from tensorflow.python.framework import ops
+from tensorflow.python.framework import test_util
+from tensorflow.python.ops import math_ops
+from tensorflow.python.ops import state_ops
+from tensorflow.python.ops import variables
+from tensorflow.python.platform import googletest
+from tensorflow.python.platform import test
+from tensorflow.python.platform import tf_logging
+
+
+@test_util.run_v1_only("b/120545219")
+class DistributedSessionDebugTest(test_util.TensorFlowTestCase):
+ """Test the debugging of distributed sessions."""
+
+ PER_PROC_GPU_MEMORY_FRACTION = 0.1
+ POLLING_INTERVAL_SEC = 0.025
+
+ @classmethod
+ def setUpClass(cls):
+ gpu_memory_fraction_opt = (
+ "--gpu_memory_fraction=%f" % cls.PER_PROC_GPU_MEMORY_FRACTION)
+
+ worker_port = portpicker.pick_unused_port()
+ cluster_spec = "worker|localhost:%d" % worker_port
+ tf_logging.info("cluster_spec: %s", cluster_spec)
+
+ server_bin = test.test_src_dir_path(
+ "python/debug/grpc_tensorflow_server.par")
+
+ cls.server_target = "grpc://localhost:%d" % worker_port
+
+ cls.server_procs = {}
+ cls.server_procs["worker"] = subprocess.Popen(
+ [
+ server_bin,
+ "--logtostderr",
+ "--cluster_spec=%s" % cluster_spec,
+ "--job_name=worker",
+ "--task_id=0",
+ gpu_memory_fraction_opt,
+ ],
+ stdout=sys.stdout,
+ stderr=sys.stderr)
+
+ # Start debug server in-process, on separate thread.
+ (cls.debug_server_port, cls.debug_server_url, _, cls.debug_server_thread,
+ cls.debug_server
+ ) = grpc_debug_test_server.start_server_on_separate_thread(
+ dump_to_filesystem=False)
+ tf_logging.info("debug server url: %s", cls.debug_server_url)
+
+ cls.session_config = config_pb2.ConfigProto(
+ gpu_options=config_pb2.GPUOptions(
+ per_process_gpu_memory_fraction=cls.PER_PROC_GPU_MEMORY_FRACTION))
+
+ @classmethod
+ def tearDownClass(cls):
+ for key in cls.server_procs:
+ cls.server_procs[key].terminate()
+ try:
+ cls.debug_server.stop_server().wait()
+ except ValueError:
+ pass
+ cls.debug_server_thread.join()
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ self.debug_server.clear_data()
+
+ def _pollingAssertDebugTensorValuesAllClose(self, expected_values,
+ debug_tensor_name):
+ """Poll debug_server till tensor appears and matches expected values."""
+ while (debug_tensor_name not in self.debug_server.debug_tensor_values or
+ len(self.debug_server.debug_tensor_values) < len(expected_values)):
+ time.sleep(self.POLLING_INTERVAL_SEC)
+ self.assertAllClose(
+ expected_values,
+ self.debug_server.debug_tensor_values[debug_tensor_name])
+
+ def _createGraph(self):
+ """Create graph for testing.
+
+ Returns:
+ Python Graph object.
+ """
+ with ops.Graph().as_default() as graph:
+ with ops.device("/job:worker/task:0/cpu:0"):
+ self.a = variables.VariableV1(10.0, name="a")
+ self.b = variables.VariableV1(100.0, name="b")
+ self.inc_a = state_ops.assign_add(self.a, 2.0, name="inc_a")
+ self.dec_b = state_ops.assign_add(self.b, -5.0, name="dec_b")
+ self.p = math_ops.multiply(self.inc_a, self.dec_b, name="p")
+ self.q = math_ops.negative(self.p, name="q")
+ return graph
+
+ def testDistributedRunWithGatedGrpcCommunicatesWithDebugServerCorrectly(self):
+ graph = self._createGraph()
+ with session.Session(
+ config=self.session_config, graph=graph,
+ target=self.server_target) as sess:
+ sess.run(self.a.initializer)
+ sess.run(self.b.initializer)
+
+ run_options = config_pb2.RunOptions()
+ debug_utils.watch_graph(
+ run_options,
+ sess.graph,
+ node_name_regex_allowlist=r"a",
+ debug_ops=["DebugIdentity"],
+ debug_urls=[self.debug_server_url])
+
+ # Test gated_grpc for an op located on the worker, i.e., on the same
+ # host as where MasterSession is.
+ # TODO(cais): gRPC gating of debug ops does not work on partition graphs
+ # not located on MasterSession hosts (e.g., parameter servers) yet. Make
+ # it work.
+ debug_utils.watch_graph(
+ run_options,
+ sess.graph,
+ node_name_regex_allowlist=r"p",
+ debug_ops=["DebugIdentity(gated_grpc=True)"],
+ debug_urls=[self.debug_server_url])
+
+ for i in xrange(4):
+ if i % 2 == 0:
+ self.debug_server.request_watch("p", 0, "DebugIdentity")
+ else:
+ self.debug_server.request_unwatch("p", 0, "DebugIdentity")
+
+ expected_p = (10.0 + 2.0 * (i + 1)) * (100.0 - 5.0 * (i + 1))
+ self.assertAllClose(-expected_p, sess.run(self.q, options=run_options))
+
+ self.assertEqual(1, len(self.debug_server.core_metadata_json_strings))
+ core_metadata = json.loads(
+ self.debug_server.core_metadata_json_strings[0])
+ self.assertEqual([], core_metadata["input_names"])
+ self.assertEqual(["q:0"], core_metadata["output_names"])
+ self.assertEqual(i, core_metadata["executor_step_index"])
+
+ if i == 0:
+ self.assertEqual(1, len(self.debug_server.partition_graph_defs))
+
+ # Tensor "a" is from a PS. It may take longer to arrive due to the fact
+ # that the stream connection between the PS and the debug server is
+ # persistent and not torn down at the end of each Session.run()
+ self._pollingAssertDebugTensorValuesAllClose([10.0 + 2.0 * i],
+ "a:0:DebugIdentity")
+
+ # Due to the gRPC gating of the debug op for "p", the debug tensor
+ # should be available on odd-indexed runs.
+ if i % 2 == 0:
+ self.assertAllClose(
+ [expected_p],
+ self.debug_server.debug_tensor_values["p:0:DebugIdentity"])
+ else:
+ self.assertNotIn("p:0:DebugIdentity",
+ self.debug_server.debug_tensor_values)
+
+ self.assertNotIn("b:0:DebugIdentity",
+ self.debug_server.debug_tensor_values)
+ self.debug_server.clear_data()
+
+ def testDistributedRunWithGrpcDebugWrapperWorks(self):
+ graph = self._createGraph()
+ with session.Session(
+ config=self.session_config, graph=graph,
+ target=self.server_target) as sess:
+ sess.run(self.a.initializer)
+ sess.run(self.b.initializer)
+
+ def watch_fn(feeds, fetch_keys):
+ del feeds, fetch_keys
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"], node_name_regex_allowlist=r"p")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+
+ for i in xrange(4):
+ expected_p = (10.0 + 2.0 * (i + 1)) * (100.0 - 5.0 * (i + 1))
+ self.assertAllClose(-expected_p, sess.run(self.q))
+
+ if i == 0:
+ self.assertEqual(1, len(self.debug_server.partition_graph_defs))
+
+ self.assertAllClose(
+ [expected_p],
+ self.debug_server.debug_tensor_values["p:0:DebugIdentity"])
+ self.assertNotIn("b:0:DebugIdentity",
+ self.debug_server.debug_tensor_values)
+ self.debug_server.clear_data()
+
+
+if __name__ == "__main__":
+ googletest.main()
diff --git a/tensorflow/python/debug/lib/grpc_large_data_test.py b/tensorflow/python/debug/lib/grpc_large_data_test.py
new file mode 100644
index 0000000..7748c39
--- /dev/null
+++ b/tensorflow/python/debug/lib/grpc_large_data_test.py
@@ -0,0 +1,217 @@
+# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+"""Tests for sending large-size data through tfdbg grpc channels.
+
+"Large-size data" includes large GraphDef protos and large Tensor protos.
+"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import numpy as np
+from six.moves import xrange # pylint: disable=redefined-builtin
+
+from tensorflow.python.debug.lib import grpc_debug_test_server
+from tensorflow.python.debug.lib import session_debug_testlib
+from tensorflow.python.debug.wrappers import framework
+from tensorflow.python.debug.wrappers import grpc_wrapper
+from tensorflow.python.framework import constant_op
+from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import ops
+from tensorflow.python.framework import test_util
+from tensorflow.python.ops import array_ops
+from tensorflow.python.ops import variables
+from tensorflow.python.platform import googletest
+from tensorflow.python.platform import test
+from tensorflow.python.platform import tf_logging
+
+
+class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ (cls.debug_server_port, cls.debug_server_url, _, cls.debug_server_thread,
+ cls.debug_server
+ ) = grpc_debug_test_server.start_server_on_separate_thread(
+ dump_to_filesystem=False)
+ tf_logging.info("debug server url: %s", cls.debug_server_url)
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.debug_server.stop_server().wait()
+ cls.debug_server_thread.join()
+
+ def tearDown(self):
+ ops.reset_default_graph()
+ self.debug_server.clear_data()
+
+ @test_util.run_v1_only("currently failing on v2")
+ def testSendingLargeGraphDefsWorks(self):
+ with self.session(
+ use_gpu=True,
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ u = variables.VariableV1(42.0, name="original_u")
+ for _ in xrange(50 * 1000):
+ u = array_ops.identity(u)
+ sess.run(variables.global_variables_initializer())
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"],
+ node_name_regex_allowlist=r"original_u")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+ self.assertAllClose(42.0, sess.run(u))
+
+ self.assertAllClose(
+ [42.0],
+ self.debug_server.debug_tensor_values["original_u:0:DebugIdentity"])
+ self.assertEqual(2 if test.is_gpu_available() else 1,
+ len(self.debug_server.partition_graph_defs))
+ max_graph_def_size = max([
+ len(graph_def.SerializeToString())
+ for graph_def in self.debug_server.partition_graph_defs])
+ self.assertGreater(max_graph_def_size, 4 * 1024 * 1024)
+
+ @test_util.run_v1_only("currently failing on v2")
+ def testSendingLargeFloatTensorWorks(self):
+ with self.session(
+ use_gpu=True,
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ u_init_val_array = list(xrange(1200 * 1024))
+ # Size: 4 * 1200 * 1024 = 4800k > 4M
+
+ u_init = constant_op.constant(
+ u_init_val_array, dtype=dtypes.float32, name="u_init")
+ u = variables.VariableV1(u_init, name="u")
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds # Unused by this watch_fn.
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"], node_name_regex_allowlist=r"u_init")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+ sess.run(u.initializer)
+
+ self.assertAllEqual(
+ u_init_val_array,
+ self.debug_server.debug_tensor_values["u_init:0:DebugIdentity"][0])
+
+ @test_util.run_v1_only("currently failing on v2")
+ def testSendingStringTensorWithAlmostTooLargeStringsWorks(self):
+ with self.session(
+ use_gpu=True,
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ u_init_val = [
+ b"", b"spam", b"A" * 2500 * 1024, b"B" * 2500 * 1024, b"egg", b""]
+ u_init = constant_op.constant(
+ u_init_val, dtype=dtypes.string, name="u_init")
+ u = variables.VariableV1(u_init, name="u")
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"], node_name_regex_allowlist=r"u_init")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+ sess.run(u.initializer)
+
+ self.assertAllEqual(
+ u_init_val,
+ self.debug_server.debug_tensor_values["u_init:0:DebugIdentity"][0])
+
+ @test_util.run_v1_only("currently failing on v2")
+ def testSendingLargeStringTensorWorks(self):
+ with self.session(
+ use_gpu=True,
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ strs_total_size_threshold = 5000 * 1024
+ cum_size = 0
+ u_init_val_array = []
+ while cum_size < strs_total_size_threshold:
+ strlen = np.random.randint(200)
+ u_init_val_array.append(b"A" * strlen)
+ cum_size += strlen
+
+ u_init = constant_op.constant(
+ u_init_val_array, dtype=dtypes.string, name="u_init")
+ u = variables.VariableV1(u_init, name="u")
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"], node_name_regex_allowlist=r"u_init")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+ sess.run(u.initializer)
+
+ self.assertAllEqual(
+ u_init_val_array,
+ self.debug_server.debug_tensor_values["u_init:0:DebugIdentity"][0])
+
+ @test_util.run_v1_only("currently failing on v2")
+ def testSendingEmptyFloatTensorWorks(self):
+ with self.session(
+ use_gpu=True,
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ u_init = constant_op.constant(
+ [], dtype=dtypes.float32, shape=[0], name="u_init")
+ u = variables.VariableV1(u_init, name="u")
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"], node_name_regex_allowlist=r"u_init")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+ sess.run(u.initializer)
+
+ u_init_value = self.debug_server.debug_tensor_values[
+ "u_init:0:DebugIdentity"][0]
+ self.assertEqual(np.float32, u_init_value.dtype)
+ self.assertEqual(0, len(u_init_value))
+
+ @test_util.run_v1_only("currently failing on v2")
+ def testSendingEmptyStringTensorWorks(self):
+ with self.session(
+ use_gpu=True,
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ u_init = constant_op.constant(
+ [], dtype=dtypes.string, shape=[0], name="u_init")
+ u = variables.VariableV1(u_init, name="u")
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity"], node_name_regex_allowlist=r"u_init")
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self.debug_server_port, watch_fn=watch_fn)
+ sess.run(u.initializer)
+
+ u_init_value = self.debug_server.debug_tensor_values[
+ "u_init:0:DebugIdentity"][0]
+ self.assertEqual(np.object, u_init_value.dtype)
+ self.assertEqual(0, len(u_init_value))
+
+
+if __name__ == "__main__":
+ googletest.main()
diff --git a/tensorflow/python/debug/lib/session_debug_grpc_test.py b/tensorflow/python/debug/lib/session_debug_grpc_test.py
new file mode 100644
index 0000000..b8baf3a
--- /dev/null
+++ b/tensorflow/python/debug/lib/session_debug_grpc_test.py
@@ -0,0 +1,766 @@
+# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+"""Tests for debugger functionalities in tf.compat.v1.Session with grpc:// URLs.
+
+This test file focuses on the grpc:// debugging of local (non-distributed)
+tf.Sessions.
+"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import os
+
+from six.moves import xrange # pylint: disable=redefined-builtin
+
+from tensorflow.core.protobuf import config_pb2
+from tensorflow.python.client import session
+from tensorflow.python.debug.lib import debug_data
+from tensorflow.python.debug.lib import debug_utils
+from tensorflow.python.debug.lib import grpc_debug_test_server
+from tensorflow.python.debug.lib import session_debug_testlib
+from tensorflow.python.debug.wrappers import framework
+from tensorflow.python.debug.wrappers import grpc_wrapper
+from tensorflow.python.debug.wrappers import hooks
+from tensorflow.python.framework import constant_op
+from tensorflow.python.framework import ops
+from tensorflow.python.framework import test_util
+from tensorflow.python.lib.io import file_io
+from tensorflow.python.ops import math_ops
+from tensorflow.python.ops import state_ops
+from tensorflow.python.ops import variables
+from tensorflow.python.platform import googletest
+from tensorflow.python.training import monitored_session
+
+
+class GrpcDebugServerTest(test_util.TensorFlowTestCase):
+
+ def testRepeatedRunServerRaisesException(self):
+ (_, _, _, server_thread,
+ server) = grpc_debug_test_server.start_server_on_separate_thread(
+ poll_server=True)
+ # The server is started asynchronously. It needs to be polled till its state
+ # has become started.
+
+ with self.assertRaisesRegex(ValueError,
+ "Server has already started running"):
+ server.run_server()
+
+ server.stop_server().wait()
+ server_thread.join()
+
+ def testRepeatedStopServerRaisesException(self):
+ (_, _, _, server_thread,
+ server) = grpc_debug_test_server.start_server_on_separate_thread(
+ poll_server=True)
+ server.stop_server().wait()
+ server_thread.join()
+
+ with self.assertRaisesRegex(ValueError, "Server has already stopped"):
+ server.stop_server().wait()
+
+ def testRunServerAfterStopRaisesException(self):
+ (_, _, _, server_thread,
+ server) = grpc_debug_test_server.start_server_on_separate_thread(
+ poll_server=True)
+ server.stop_server().wait()
+ server_thread.join()
+
+ with self.assertRaisesRegex(ValueError, "Server has already stopped"):
+ server.run_server()
+
+ def testStartServerWithoutBlocking(self):
+ (_, _, _, server_thread,
+ server) = grpc_debug_test_server.start_server_on_separate_thread(
+ poll_server=True, blocking=False)
+ # The thread that starts the server shouldn't block, so we should be able to
+ # join it before stopping the server.
+ server_thread.join()
+ server.stop_server().wait()
+
+
+@test_util.run_v1_only(
+ "GrpcDebugWrapperSession and GrpcDebugHookare are for tf.Session only")
+class SessionDebugGrpcTest(session_debug_testlib.SessionDebugTestBase):
+
+ @classmethod
+ def setUpClass(cls):
+ session_debug_testlib.SessionDebugTestBase.setUpClass()
+ (cls._server_port, cls._debug_server_url, cls._server_dump_dir,
+ cls._server_thread,
+ cls._server) = grpc_debug_test_server.start_server_on_separate_thread()
+
+ @classmethod
+ def tearDownClass(cls):
+ # Stop the test server and join the thread.
+ cls._server.stop_server().wait()
+ cls._server_thread.join()
+
+ session_debug_testlib.SessionDebugTestBase.tearDownClass()
+
+ def setUp(self):
+ # Override the dump root as the test server's dump directory.
+ self._dump_root = self._server_dump_dir
+
+ def tearDown(self):
+ if os.path.isdir(self._server_dump_dir):
+ file_io.delete_recursively(self._server_dump_dir)
+ session_debug_testlib.SessionDebugTestBase.tearDown(self)
+
+ def _debug_urls(self, run_number=None):
+ return ["grpc://localhost:%d" % self._server_port]
+
+ def _debug_dump_dir(self, run_number=None):
+ if run_number is None:
+ return self._dump_root
+ else:
+ return os.path.join(self._dump_root, "run_%d" % run_number)
+
+ def testConstructGrpcDebugWrapperSessionWithInvalidTypeRaisesException(self):
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ with self.assertRaisesRegex(
+ TypeError, "Expected type str or list in grpc_debug_server_addresses"):
+ grpc_wrapper.GrpcDebugWrapperSession(sess, 1337)
+
+ def testConstructGrpcDebugWrapperSessionWithInvalidTypeRaisesException2(self):
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ with self.assertRaisesRegex(
+ TypeError, "Expected type str in list grpc_debug_server_addresses"):
+ grpc_wrapper.GrpcDebugWrapperSession(sess, ["localhost:1337", 1338])
+
+ def testUseInvalidWatchFnTypeWithGrpcDebugWrapperSessionRaisesException(self):
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ with self.assertRaises(TypeError):
+ grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self._server_port, watch_fn="foo")
+
+ def testGrpcDebugWrapperSessionWithoutWatchFnWorks(self):
+ u = variables.VariableV1(2.1, name="u")
+ v = variables.VariableV1(20.0, name="v")
+ w = math_ops.multiply(u, v, name="w")
+
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ sess.run(u.initializer)
+ sess.run(v.initializer)
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self._server_port)
+ w_result = sess.run(w)
+ self.assertAllClose(42.0, w_result)
+
+ dump = debug_data.DebugDumpDir(self._dump_root)
+ self.assertLessEqual(5, dump.size)
+ self.assertAllClose([2.1], dump.get_tensors("u", 0, "DebugIdentity"))
+ self.assertAllClose([2.1], dump.get_tensors("u/read", 0, "DebugIdentity"))
+ self.assertAllClose([20.0], dump.get_tensors("v", 0, "DebugIdentity"))
+ self.assertAllClose([20.0], dump.get_tensors("v/read", 0, "DebugIdentity"))
+ self.assertAllClose([42.0], dump.get_tensors("w", 0, "DebugIdentity"))
+
+ def testGrpcDebugWrapperSessionWithWatchFnWorks(self):
+ def watch_fn(feeds, fetch_keys):
+ del feeds, fetch_keys
+ return ["DebugIdentity", "DebugNumericSummary"], r".*/read", None
+
+ u = variables.VariableV1(2.1, name="u")
+ v = variables.VariableV1(20.0, name="v")
+ w = math_ops.multiply(u, v, name="w")
+
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ sess.run(u.initializer)
+ sess.run(v.initializer)
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % self._server_port, watch_fn=watch_fn)
+ w_result = sess.run(w)
+ self.assertAllClose(42.0, w_result)
+
+ dump = debug_data.DebugDumpDir(self._dump_root)
+ self.assertEqual(4, dump.size)
+ self.assertAllClose([2.1], dump.get_tensors("u/read", 0, "DebugIdentity"))
+ self.assertEqual(
+ 14, len(dump.get_tensors("u/read", 0, "DebugNumericSummary")[0]))
+ self.assertAllClose([20.0], dump.get_tensors("v/read", 0, "DebugIdentity"))
+ self.assertEqual(
+ 14, len(dump.get_tensors("v/read", 0, "DebugNumericSummary")[0]))
+
+ def testGrpcDebugHookWithStatelessWatchFnWorks(self):
+ # Perform some set up. Specifically, construct a simple TensorFlow graph and
+ # create a watch function for certain ops.
+ def watch_fn(feeds, fetch_keys):
+ del feeds, fetch_keys
+ return framework.WatchOptions(
+ debug_ops=["DebugIdentity", "DebugNumericSummary"],
+ node_name_regex_allowlist=r".*/read",
+ op_type_regex_allowlist=None,
+ tolerate_debug_op_creation_failures=True)
+
+ u = variables.VariableV1(2.1, name="u")
+ v = variables.VariableV1(20.0, name="v")
+ w = math_ops.multiply(u, v, name="w")
+
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ sess.run(u.initializer)
+ sess.run(v.initializer)
+
+ # Create a hook. One could use this hook with say a tflearn Estimator.
+ # However, we use a HookedSession in this test to avoid depending on the
+ # internal implementation of Estimators.
+ grpc_debug_hook = hooks.GrpcDebugHook(
+ ["localhost:%d" % self._server_port], watch_fn=watch_fn)
+ sess = monitored_session._HookedSession(sess, [grpc_debug_hook])
+
+ # Run the hooked session. This should stream tensor data to the GRPC
+ # endpoints.
+ w_result = sess.run(w)
+
+ # Verify that the hook monitored the correct tensors.
+ self.assertAllClose(42.0, w_result)
+ dump = debug_data.DebugDumpDir(self._dump_root)
+ self.assertEqual(4, dump.size)
+ self.assertAllClose([2.1], dump.get_tensors("u/read", 0, "DebugIdentity"))
+ self.assertEqual(
+ 14, len(dump.get_tensors("u/read", 0, "DebugNumericSummary")[0]))
+ self.assertAllClose([20.0], dump.get_tensors("v/read", 0, "DebugIdentity"))
+ self.assertEqual(
+ 14, len(dump.get_tensors("v/read", 0, "DebugNumericSummary")[0]))
+
+ def testTensorBoardDebugHookWorks(self):
+ u = variables.VariableV1(2.1, name="u")
+ v = variables.VariableV1(20.0, name="v")
+ w = math_ops.multiply(u, v, name="w")
+
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ sess.run(u.initializer)
+ sess.run(v.initializer)
+
+ grpc_debug_hook = hooks.TensorBoardDebugHook(
+ ["localhost:%d" % self._server_port])
+ sess = monitored_session._HookedSession(sess, [grpc_debug_hook])
+
+ # Activate watch point on a tensor before calling sess.run().
+ self._server.request_watch("u/read", 0, "DebugIdentity")
+ self.assertAllClose(42.0, sess.run(w))
+
+ # self.assertAllClose(42.0, sess.run(w))
+ dump = debug_data.DebugDumpDir(self._dump_root)
+ self.assertAllClose([2.1], dump.get_tensors("u/read", 0, "DebugIdentity"))
+
+ # Check that the server has received the stack trace.
+ self.assertTrue(self._server.query_op_traceback("u"))
+ self.assertTrue(self._server.query_op_traceback("u/read"))
+ self.assertTrue(self._server.query_op_traceback("v"))
+ self.assertTrue(self._server.query_op_traceback("v/read"))
+ self.assertTrue(self._server.query_op_traceback("w"))
+
+ # Check that the server has received the python file content.
+ # Query an arbitrary line to make sure that is the case.
+ with open(__file__, "rt") as this_source_file:
+ first_line = this_source_file.readline().strip()
+ self.assertEqual(
+ first_line, self._server.query_source_file_line(__file__, 1))
+
+ self._server.clear_data()
+ # Call sess.run() again, and verify that this time the traceback and source
+ # code is not sent, because the graph version is not newer.
+ self.assertAllClose(42.0, sess.run(w))
+ with self.assertRaises(ValueError):
+ self._server.query_op_traceback("delta_1")
+ with self.assertRaises(ValueError):
+ self._server.query_source_file_line(__file__, 1)
+
+ def testTensorBoardDebugHookDisablingTracebackSourceCodeSendingWorks(self):
+ u = variables.VariableV1(2.1, name="u")
+ v = variables.VariableV1(20.0, name="v")
+ w = math_ops.multiply(u, v, name="w")
+
+ sess = session.Session(
+ config=session_debug_testlib.no_rewrite_session_config())
+ sess.run(variables.global_variables_initializer())
+
+ grpc_debug_hook = hooks.TensorBoardDebugHook(
+ ["localhost:%d" % self._server_port],
+ send_traceback_and_source_code=False)
+ sess = monitored_session._HookedSession(sess, [grpc_debug_hook])
+
+ # Activate watch point on a tensor before calling sess.run().
+ self._server.request_watch("u/read", 0, "DebugIdentity")
+ self.assertAllClose(42.0, sess.run(w))
+
+ # Check that the server has _not_ received any tracebacks, as a result of
+ # the disabling above.
+ with self.assertRaisesRegex(ValueError, r"Op .*u/read.* does not exist"):
+ self.assertTrue(self._server.query_op_traceback("u/read"))
+ with self.assertRaisesRegex(ValueError,
+ r".* has not received any source file"):
+ self._server.query_source_file_line(__file__, 1)
+
+ def testConstructGrpcDebugHookWithOrWithouGrpcInUrlWorks(self):
+ hooks.GrpcDebugHook(["grpc://foo:42424"])
+ hooks.GrpcDebugHook(["foo:42424"])
+
+
+class SessionDebugConcurrentTest(
+ session_debug_testlib.DebugConcurrentRunCallsTest):
+
+ @classmethod
+ def setUpClass(cls):
+ session_debug_testlib.SessionDebugTestBase.setUpClass()
+ (cls._server_port, cls._debug_server_url, cls._server_dump_dir,
+ cls._server_thread,
+ cls._server) = grpc_debug_test_server.start_server_on_separate_thread()
+
+ @classmethod
+ def tearDownClass(cls):
+ # Stop the test server and join the thread.
+ cls._server.stop_server().wait()
+ cls._server_thread.join()
+ session_debug_testlib.SessionDebugTestBase.tearDownClass()
+
+ def setUp(self):
+ self._num_concurrent_runs = 3
+ self._dump_roots = []
+ for i in range(self._num_concurrent_runs):
+ self._dump_roots.append(
+ os.path.join(self._server_dump_dir, "thread%d" % i))
+
+ def tearDown(self):
+ ops.reset_default_graph()
+ if os.path.isdir(self._server_dump_dir):
+ file_io.delete_recursively(self._server_dump_dir)
+
+ def _get_concurrent_debug_urls(self):
+ urls = []
+ for i in range(self._num_concurrent_runs):
+ urls.append(self._debug_server_url + "/thread%d" % i)
+ return urls
+
+
+@test_util.run_v1_only("GrpcDebugWrapperSession is for tf.Session only")
+class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase):
+ """Test server gating of debug ops."""
+
+ @classmethod
+ def setUpClass(cls):
+ (cls._server_port_1, cls._debug_server_url_1, _, cls._server_thread_1,
+ cls._server_1) = grpc_debug_test_server.start_server_on_separate_thread(
+ dump_to_filesystem=False)
+ (cls._server_port_2, cls._debug_server_url_2, _, cls._server_thread_2,
+ cls._server_2) = grpc_debug_test_server.start_server_on_separate_thread(
+ dump_to_filesystem=False)
+ cls._servers_and_threads = [(cls._server_1, cls._server_thread_1),
+ (cls._server_2, cls._server_thread_2)]
+
+ @classmethod
+ def tearDownClass(cls):
+ for server, thread in cls._servers_and_threads:
+ server.stop_server().wait()
+ thread.join()
+
+ def tearDown(self):
+ ops.reset_default_graph()
+ self._server_1.clear_data()
+ self._server_2.clear_data()
+
+ def testToggleEnableTwoDebugWatchesNoCrosstalkBetweenDebugNodes(self):
+ with session.Session(
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ v_1 = variables.VariableV1(50.0, name="v_1")
+ v_2 = variables.VariableV1(-50.0, name="v_1")
+ delta_1 = constant_op.constant(5.0, name="delta_1")
+ delta_2 = constant_op.constant(-5.0, name="delta_2")
+ inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1")
+ inc_v_2 = state_ops.assign_add(v_2, delta_2, name="inc_v_2")
+
+ sess.run([v_1.initializer, v_2.initializer])
+
+ run_metadata = config_pb2.RunMetadata()
+ run_options = config_pb2.RunOptions(output_partition_graphs=True)
+ debug_utils.watch_graph(
+ run_options,
+ sess.graph,
+ debug_ops=["DebugIdentity(gated_grpc=true)",
+ "DebugNumericSummary(gated_grpc=true)"],
+ debug_urls=[self._debug_server_url_1])
+
+ for i in xrange(4):
+ self._server_1.clear_data()
+
+ if i % 2 == 0:
+ self._server_1.request_watch("delta_1", 0, "DebugIdentity")
+ self._server_1.request_watch("delta_2", 0, "DebugIdentity")
+ self._server_1.request_unwatch("delta_1", 0, "DebugNumericSummary")
+ self._server_1.request_unwatch("delta_2", 0, "DebugNumericSummary")
+ else:
+ self._server_1.request_unwatch("delta_1", 0, "DebugIdentity")
+ self._server_1.request_unwatch("delta_2", 0, "DebugIdentity")
+ self._server_1.request_watch("delta_1", 0, "DebugNumericSummary")
+ self._server_1.request_watch("delta_2", 0, "DebugNumericSummary")
+
+ sess.run([inc_v_1, inc_v_2],
+ options=run_options, run_metadata=run_metadata)
+
+ # Watched debug tensors are:
+ # Run 0: delta_[1,2]:0:DebugIdentity
+ # Run 1: delta_[1,2]:0:DebugNumericSummary
+ # Run 2: delta_[1,2]:0:DebugIdentity
+ # Run 3: delta_[1,2]:0:DebugNumericSummary
+ self.assertEqual(2, len(self._server_1.debug_tensor_values))
+ if i % 2 == 0:
+ self.assertAllClose(
+ [5.0],
+ self._server_1.debug_tensor_values["delta_1:0:DebugIdentity"])
+ self.assertAllClose(
+ [-5.0],
+ self._server_1.debug_tensor_values["delta_2:0:DebugIdentity"])
+ else:
+ self.assertAllClose(
+ [[1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 5.0, 5.0, 5.0,
+ 0.0, 1.0, 0.0]],
+ self._server_1.debug_tensor_values[
+ "delta_1:0:DebugNumericSummary"])
+ self.assertAllClose(
+ [[1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -5.0, -5.0, -5.0,
+ 0.0, 1.0, 0.0]],
+ self._server_1.debug_tensor_values[
+ "delta_2:0:DebugNumericSummary"])
+
+ def testToggleWatchesOnCoreMetadata(self):
+ (_, debug_server_url, _, server_thread,
+ server) = grpc_debug_test_server.start_server_on_separate_thread(
+ dump_to_filesystem=False,
+ toggle_watch_on_core_metadata=[("toggled_1", 0, "DebugIdentity"),
+ ("toggled_2", 0, "DebugIdentity")])
+ self._servers_and_threads.append((server, server_thread))
+
+ with session.Session(
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ v_1 = variables.VariableV1(50.0, name="v_1")
+ v_2 = variables.VariableV1(-50.0, name="v_1")
+ # These two nodes have names that match those in the
+ # toggle_watch_on_core_metadata argument used when calling
+ # start_server_on_separate_thread().
+ toggled_1 = constant_op.constant(5.0, name="toggled_1")
+ toggled_2 = constant_op.constant(-5.0, name="toggled_2")
+ inc_v_1 = state_ops.assign_add(v_1, toggled_1, name="inc_v_1")
+ inc_v_2 = state_ops.assign_add(v_2, toggled_2, name="inc_v_2")
+
+ sess.run([v_1.initializer, v_2.initializer])
+
+ run_metadata = config_pb2.RunMetadata()
+ run_options = config_pb2.RunOptions(output_partition_graphs=True)
+ debug_utils.watch_graph(
+ run_options,
+ sess.graph,
+ debug_ops=["DebugIdentity(gated_grpc=true)"],
+ debug_urls=[debug_server_url])
+
+ for i in xrange(4):
+ server.clear_data()
+
+ sess.run([inc_v_1, inc_v_2],
+ options=run_options, run_metadata=run_metadata)
+
+ if i % 2 == 0:
+ self.assertEqual(2, len(server.debug_tensor_values))
+ self.assertAllClose(
+ [5.0],
+ server.debug_tensor_values["toggled_1:0:DebugIdentity"])
+ self.assertAllClose(
+ [-5.0],
+ server.debug_tensor_values["toggled_2:0:DebugIdentity"])
+ else:
+ self.assertEqual(0, len(server.debug_tensor_values))
+
+ def testToggleEnableTwoDebugWatchesNoCrosstalkBetweenServers(self):
+ with session.Session(
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ v = variables.VariableV1(50.0, name="v")
+ delta = constant_op.constant(5.0, name="delta")
+ inc_v = state_ops.assign_add(v, delta, name="inc_v")
+
+ sess.run(v.initializer)
+
+ run_metadata = config_pb2.RunMetadata()
+ run_options = config_pb2.RunOptions(output_partition_graphs=True)
+ debug_utils.watch_graph(
+ run_options,
+ sess.graph,
+ debug_ops=["DebugIdentity(gated_grpc=true)"],
+ debug_urls=[self._debug_server_url_1, self._debug_server_url_2])
+
+ for i in xrange(4):
+ self._server_1.clear_data()
+ self._server_2.clear_data()
+
+ if i % 2 == 0:
+ self._server_1.request_watch("delta", 0, "DebugIdentity")
+ self._server_2.request_watch("v", 0, "DebugIdentity")
+ else:
+ self._server_1.request_unwatch("delta", 0, "DebugIdentity")
+ self._server_2.request_unwatch("v", 0, "DebugIdentity")
+
+ sess.run(inc_v, options=run_options, run_metadata=run_metadata)
+
+ if i % 2 == 0:
+ self.assertEqual(1, len(self._server_1.debug_tensor_values))
+ self.assertEqual(1, len(self._server_2.debug_tensor_values))
+ self.assertAllClose(
+ [5.0],
+ self._server_1.debug_tensor_values["delta:0:DebugIdentity"])
+ self.assertAllClose(
+ [50 + 5.0 * i],
+ self._server_2.debug_tensor_values["v:0:DebugIdentity"])
+ else:
+ self.assertEqual(0, len(self._server_1.debug_tensor_values))
+ self.assertEqual(0, len(self._server_2.debug_tensor_values))
+
+ def testToggleBreakpointsWorks(self):
+ with session.Session(
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ v_1 = variables.VariableV1(50.0, name="v_1")
+ v_2 = variables.VariableV1(-50.0, name="v_2")
+ delta_1 = constant_op.constant(5.0, name="delta_1")
+ delta_2 = constant_op.constant(-5.0, name="delta_2")
+ inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1")
+ inc_v_2 = state_ops.assign_add(v_2, delta_2, name="inc_v_2")
+
+ sess.run([v_1.initializer, v_2.initializer])
+
+ run_metadata = config_pb2.RunMetadata()
+ run_options = config_pb2.RunOptions(output_partition_graphs=True)
+ debug_utils.watch_graph(
+ run_options,
+ sess.graph,
+ debug_ops=["DebugIdentity(gated_grpc=true)"],
+ debug_urls=[self._debug_server_url_1])
+
+ for i in xrange(4):
+ self._server_1.clear_data()
+
+ if i in (0, 2):
+ # Enable breakpoint at delta_[1,2]:0:DebugIdentity in runs 0 and 2.
+ self._server_1.request_watch(
+ "delta_1", 0, "DebugIdentity", breakpoint=True)
+ self._server_1.request_watch(
+ "delta_2", 0, "DebugIdentity", breakpoint=True)
+ else:
+ # Disable the breakpoint in runs 1 and 3.
+ self._server_1.request_unwatch("delta_1", 0, "DebugIdentity")
+ self._server_1.request_unwatch("delta_2", 0, "DebugIdentity")
+
+ output = sess.run([inc_v_1, inc_v_2],
+ options=run_options, run_metadata=run_metadata)
+ self.assertAllClose([50.0 + 5.0 * (i + 1), -50 - 5.0 * (i + 1)], output)
+
+ if i in (0, 2):
+ # During runs 0 and 2, the server should have received the published
+ # debug tensor delta:0:DebugIdentity. The breakpoint should have been
+ # unblocked by EventReply responses from the server.
+ self.assertAllClose(
+ [5.0],
+ self._server_1.debug_tensor_values["delta_1:0:DebugIdentity"])
+ self.assertAllClose(
+ [-5.0],
+ self._server_1.debug_tensor_values["delta_2:0:DebugIdentity"])
+ # After the runs, the server should have properly registered the
+ # breakpoints due to the request_unwatch calls.
+ self.assertSetEqual({("delta_1", 0, "DebugIdentity"),
+ ("delta_2", 0, "DebugIdentity")},
+ self._server_1.breakpoints)
+ else:
+ # After the end of runs 1 and 3, the server has received the requests
+ # to disable the breakpoint at delta:0:DebugIdentity.
+ self.assertSetEqual(set(), self._server_1.breakpoints)
+
+ def testTensorBoardDebuggerWrapperToggleBreakpointsWorks(self):
+ with session.Session(
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ v_1 = variables.VariableV1(50.0, name="v_1")
+ v_2 = variables.VariableV1(-50.0, name="v_2")
+ delta_1 = constant_op.constant(5.0, name="delta_1")
+ delta_2 = constant_op.constant(-5.0, name="delta_2")
+ inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1")
+ inc_v_2 = state_ops.assign_add(v_2, delta_2, name="inc_v_2")
+
+ sess.run([v_1.initializer, v_2.initializer])
+
+ # The TensorBoardDebugWrapperSession should add a DebugIdentity debug op
+ # with attribute gated_grpc=True for every tensor in the graph.
+ sess = grpc_wrapper.TensorBoardDebugWrapperSession(
+ sess, self._debug_server_url_1)
+
+ for i in xrange(4):
+ self._server_1.clear_data()
+
+ if i in (0, 2):
+ # Enable breakpoint at delta_[1,2]:0:DebugIdentity in runs 0 and 2.
+ self._server_1.request_watch(
+ "delta_1", 0, "DebugIdentity", breakpoint=True)
+ self._server_1.request_watch(
+ "delta_2", 0, "DebugIdentity", breakpoint=True)
+ else:
+ # Disable the breakpoint in runs 1 and 3.
+ self._server_1.request_unwatch("delta_1", 0, "DebugIdentity")
+ self._server_1.request_unwatch("delta_2", 0, "DebugIdentity")
+
+ output = sess.run([inc_v_1, inc_v_2])
+ self.assertAllClose([50.0 + 5.0 * (i + 1), -50 - 5.0 * (i + 1)], output)
+
+ if i in (0, 2):
+ # During runs 0 and 2, the server should have received the published
+ # debug tensor delta:0:DebugIdentity. The breakpoint should have been
+ # unblocked by EventReply responses from the server.
+ self.assertAllClose(
+ [5.0],
+ self._server_1.debug_tensor_values["delta_1:0:DebugIdentity"])
+ self.assertAllClose(
+ [-5.0],
+ self._server_1.debug_tensor_values["delta_2:0:DebugIdentity"])
+ # After the runs, the server should have properly registered the
+ # breakpoints.
+ else:
+ # After the end of runs 1 and 3, the server has received the requests
+ # to disable the breakpoint at delta:0:DebugIdentity.
+ self.assertSetEqual(set(), self._server_1.breakpoints)
+
+ if i == 0:
+ # Check that the server has received the stack trace.
+ self.assertTrue(self._server_1.query_op_traceback("delta_1"))
+ self.assertTrue(self._server_1.query_op_traceback("delta_2"))
+ self.assertTrue(self._server_1.query_op_traceback("inc_v_1"))
+ self.assertTrue(self._server_1.query_op_traceback("inc_v_2"))
+ # Check that the server has received the python file content.
+ # Query an arbitrary line to make sure that is the case.
+ with open(__file__, "rt") as this_source_file:
+ first_line = this_source_file.readline().strip()
+ self.assertEqual(
+ first_line, self._server_1.query_source_file_line(__file__, 1))
+ else:
+ # In later Session.run() calls, the traceback shouldn't have been sent
+ # because it is already sent in the 1st call. So calling
+ # query_op_traceback() should lead to an exception, because the test
+ # debug server clears the data at the beginning of every iteration.
+ with self.assertRaises(ValueError):
+ self._server_1.query_op_traceback("delta_1")
+ with self.assertRaises(ValueError):
+ self._server_1.query_source_file_line(__file__, 1)
+
+ def testTensorBoardDebuggerWrapperDisablingTracebackSourceSendingWorks(self):
+ with session.Session(
+ config=session_debug_testlib.no_rewrite_session_config()) as sess:
+ v_1 = variables.VariableV1(50.0, name="v_1")
+ v_2 = variables.VariableV1(-50.0, name="v_2")
+ delta_1 = constant_op.constant(5.0, name="delta_1")
+ delta_2 = constant_op.constant(-5.0, name="delta_2")
+ inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1")
+ inc_v_2 = state_ops.assign_add(v_2, delta_2, name="inc_v_2")
+
+ sess.run(variables.global_variables_initializer())
+
+ # Disable the sending of traceback and source code.
+ sess = grpc_wrapper.TensorBoardDebugWrapperSession(
+ sess, self._debug_server_url_1, send_traceback_and_source_code=False)
+
+ for i in xrange(4):
+ self._server_1.clear_data()
+
+ if i == 0:
+ self._server_1.request_watch(
+ "delta_1", 0, "DebugIdentity", breakpoint=True)
+
+ output = sess.run([inc_v_1, inc_v_2])
+ self.assertAllClose([50.0 + 5.0 * (i + 1), -50 - 5.0 * (i + 1)], output)
+
+ # No op traceback or source code should have been received by the debug
+ # server due to the disabling above.
+ with self.assertRaisesRegex(ValueError,
+ r"Op .*delta_1.* does not exist"):
+ self.assertTrue(self._server_1.query_op_traceback("delta_1"))
+ with self.assertRaisesRegex(ValueError,
+ r".* has not received any source file"):
+ self._server_1.query_source_file_line(__file__, 1)
+
+ def testGetGrpcDebugWatchesReturnsCorrectAnswer(self):
+ with session.Session() as sess:
+ v = variables.VariableV1(50.0, name="v")
+ delta = constant_op.constant(5.0, name="delta")
+ inc_v = state_ops.assign_add(v, delta, name="inc_v")
+
+ sess.run(v.initializer)
+
+ # Before any debugged runs, the server should be aware of no debug
+ # watches.
+ self.assertEqual([], self._server_1.gated_grpc_debug_watches())
+
+ run_metadata = config_pb2.RunMetadata()
+ run_options = config_pb2.RunOptions(output_partition_graphs=True)
+ debug_utils.add_debug_tensor_watch(
+ run_options, "delta", output_slot=0,
+ debug_ops=["DebugNumericSummary(gated_grpc=true)"],
+ debug_urls=[self._debug_server_url_1])
+ debug_utils.add_debug_tensor_watch(
+ run_options, "v", output_slot=0,
+ debug_ops=["DebugIdentity"],
+ debug_urls=[self._debug_server_url_1])
+ sess.run(inc_v, options=run_options, run_metadata=run_metadata)
+
+ # After the first run, the server should have noted the debug watches
+ # for which gated_grpc == True, but not the ones with gated_grpc == False.
+ self.assertEqual(1, len(self._server_1.gated_grpc_debug_watches()))
+ debug_watch = self._server_1.gated_grpc_debug_watches()[0]
+ self.assertEqual("delta", debug_watch.node_name)
+ self.assertEqual(0, debug_watch.output_slot)
+ self.assertEqual("DebugNumericSummary", debug_watch.debug_op)
+
+
+@test_util.run_v1_only("GrpcDebugWrapperSession is for tf.Session only")
+class DelayedDebugServerTest(test_util.TensorFlowTestCase):
+
+ def testDebuggedSessionRunWorksWithDelayedDebugServerStartup(self):
+ """Test debugged Session.run() tolerates delayed debug server startup."""
+ ops.reset_default_graph()
+
+ # Start a debug server asynchronously, with a certain amount of delay.
+ (debug_server_port, _, _, server_thread,
+ debug_server) = grpc_debug_test_server.start_server_on_separate_thread(
+ server_start_delay_sec=2.0, dump_to_filesystem=False)
+
+ with self.cached_session() as sess:
+ a_init = constant_op.constant(42.0, name="a_init")
+ a = variables.VariableV1(a_init, name="a")
+
+ def watch_fn(fetches, feeds):
+ del fetches, feeds
+ return framework.WatchOptions(debug_ops=["DebugIdentity"])
+
+ sess = grpc_wrapper.GrpcDebugWrapperSession(
+ sess, "localhost:%d" % debug_server_port, watch_fn=watch_fn)
+ sess.run(a.initializer)
+ self.assertAllClose(
+ [42.0], debug_server.debug_tensor_values["a_init:0:DebugIdentity"])
+
+ debug_server.stop_server().wait()
+ server_thread.join()
+
+
+if __name__ == "__main__":
+ googletest.main()
diff --git a/tensorflow/python/debug/wrappers/BUILD b/tensorflow/python/debug/wrappers/BUILD
deleted file mode 100644
index ed184d4..0000000
--- a/tensorflow/python/debug/wrappers/BUILD
+++ /dev/null
@@ -1,177 +0,0 @@
-package(
- default_visibility = ["//tensorflow:internal"],
- licenses = ["notice"],
-)
-
-py_library(
- name = "framework",
- srcs = ["framework.py"],
- srcs_version = "PY3",
- deps = [
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:client",
- "//tensorflow/python:errors",
- "//tensorflow/python:framework_ops",
- "//tensorflow/python:training",
- "//tensorflow/python/debug/lib:debug_utils",
- ],
-)
-
-py_library(
- name = "dumping_wrapper",
- srcs = ["dumping_wrapper.py"],
- srcs_version = "PY3",
- visibility = [
- "//tensorflow:internal",
- "//third_party/py/tf_slim:__subpackages__",
- ],
- deps = [
- ":framework",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:platform",
- "//tensorflow/python/debug/lib:debug_data",
- ],
-)
-
-py_library(
- name = "grpc_wrapper",
- srcs = ["grpc_wrapper.py"],
- srcs_version = "PY3",
- deps = [
- ":framework",
- "//tensorflow/python/debug/lib:common",
- "//tensorflow/python/debug/lib:source_remote",
- ],
-)
-
-py_library(
- name = "local_cli_wrapper",
- srcs = ["local_cli_wrapper.py"],
- srcs_version = "PY3",
- deps = [
- ":framework",
- "//tensorflow/python/debug/cli:analyzer_cli",
- "//tensorflow/python/debug/cli:cli_shared",
- "//tensorflow/python/debug/cli:command_parser",
- "//tensorflow/python/debug/cli:debugger_cli_common",
- "//tensorflow/python/debug/cli:profile_analyzer_cli",
- "//tensorflow/python/debug/cli:tensor_format",
- "//tensorflow/python/debug/cli:ui_factory",
- "//tensorflow/python/debug/lib:common",
- "//tensorflow/python/debug/lib:debug_data",
- ],
-)
-
-py_library(
- name = "hooks",
- srcs = ["hooks.py"],
- srcs_version = "PY3",
- visibility = [
- "//tensorflow:internal",
- "//third_party/py/tf_slim:__subpackages__",
- ],
- deps = [
- ":dumping_wrapper",
- ":framework",
- ":grpc_wrapper",
- ":local_cli_wrapper",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:training",
- "//tensorflow/python/debug/lib:debug_utils",
- ],
-)
-
-py_test(
- name = "framework_test",
- size = "medium",
- srcs = ["framework_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- tags = ["no_rocm"],
- deps = [
- ":framework",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:client",
- "//tensorflow/python:errors",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:resource_variable_ops",
- "//tensorflow/python:training",
- "//tensorflow/python:util",
- "//tensorflow/python:variables",
- "//tensorflow/python/debug/lib:debug_data",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "dumping_wrapper_test",
- size = "small",
- srcs = ["dumping_wrapper_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":dumping_wrapper",
- ":framework",
- ":hooks",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:client",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:state_ops",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- "//tensorflow/python/debug/lib:debug_data",
- ],
-)
-
-py_test(
- name = "local_cli_wrapper_test",
- size = "small",
- srcs = ["local_cli_wrapper_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":local_cli_wrapper",
- "//tensorflow/core:protos_all_py",
- "//tensorflow/python:array_ops",
- "//tensorflow/python:client",
- "//tensorflow/python:control_flow_ops",
- "//tensorflow/python:errors",
- "//tensorflow/python:framework_for_generated_wrappers",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:math_ops",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:resource_variable_ops",
- "//tensorflow/python:state_ops",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- "//tensorflow/python/debug/cli:cli_shared",
- "//tensorflow/python/debug/cli:debugger_cli_common",
- "//tensorflow/python/debug/cli:ui_factory",
- "//third_party/py/numpy",
- ],
-)
-
-py_test(
- name = "disk_usage_test",
- size = "small",
- srcs = ["disk_usage_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- ":dumping_wrapper",
- ":hooks",
- "//tensorflow/python:client",
- "//tensorflow/python:errors",
- "//tensorflow/python:framework_test_lib",
- "//tensorflow/python:platform_test",
- "//tensorflow/python:training",
- "//tensorflow/python:variables",
- ],
-)
diff --git a/tensorflow/python/ops/math_grad_test.py b/tensorflow/python/ops/math_grad_test.py
index 1815fae..773084c 100644
--- a/tensorflow/python/ops/math_grad_test.py
+++ b/tensorflow/python/ops/math_grad_test.py
@@ -20,6 +20,7 @@
import numpy as np
+from tensorflow.python.debug.lib import check_numerics_callback
from tensorflow.python.eager import backprop
from tensorflow.python.eager import context
from tensorflow.python.framework import constant_op
@@ -635,12 +636,16 @@
self.assertAllClose([-2., 0., 2.], g)
def test_zero_grad_tape(self):
- x = constant_op.constant([-1, 0., 1.])
- with backprop.GradientTape() as tape:
- tape.watch(x)
- g = tape.gradient(math_ops.pow(x, 2), x)
- g = self.evaluate(g)
- self.assertAllClose([-2., 0., 2.], g)
+ try:
+ check_numerics_callback.enable_check_numerics()
+ x = constant_op.constant([-1, 0., 1.])
+ with backprop.GradientTape() as tape:
+ tape.watch(x)
+ g = tape.gradient(math_ops.pow(x, 2), x)
+ g = self.evaluate(g)
+ self.assertAllClose([-2., 0., 2.], g)
+ finally:
+ check_numerics_callback.disable_check_numerics()
@test_util.run_all_in_graph_and_eager_modes
diff --git a/tensorflow/python/tools/BUILD b/tensorflow/python/tools/BUILD
index a1b89fb..17ebc47 100644
--- a/tensorflow/python/tools/BUILD
+++ b/tensorflow/python/tools/BUILD
@@ -330,7 +330,7 @@
":saved_model_aot_compile",
":saved_model_utils",
"//tensorflow/python",
- "//tensorflow/python/debug/wrappers:local_cli_wrapper",
+ "//tensorflow/python/debug:local_cli_wrapper",
],
)