From e545d87911d6b37c12f22a50024dd0871c880935 Mon Sep 17 00:00:00 2001 From: Shanqing Cai Date: Wed, 30 Dec 2020 09:45:55 -0800 Subject: [PATCH] [DebuggerV2] Enable debug_v2_ops_test & debug_events_writer_test on Windows - A test in debug_v2_ops_test previously called `np.power(2, 53)` without specifying dtype. As a result, the output had the int32 dtype on Windows and caused overflowing. This apparently does not happen on Linux or Mac. - This CL fixes that by explicitly specifying `dtype=np.int64` in the call. - In debug_events_write.cc, check for whether the DebugEventsWriter instance is initialized and return early if not so. - This resolves a directory-not-empty test failure in debug_events_writer_test on Windows This is a step towards fixing #43608 PiperOrigin-RevId: 349569528 Change-Id: I8112f8faebe662542e80c03d5d95e8e089446fe8 --- tensorflow/core/util/BUILD | 1 - tensorflow/core/util/debug_events_writer.cc | 7 +++++++ tensorflow/python/debug/BUILD | 3 --- tensorflow/python/debug/lib/debug_v2_ops_test.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tensorflow/core/util/BUILD b/tensorflow/core/util/BUILD index 601416d0500..654601c915d 100644 --- a/tensorflow/core/util/BUILD +++ b/tensorflow/core/util/BUILD @@ -783,7 +783,6 @@ tf_cc_test( "//conditions:default": [], }), linkstatic = tf_kernel_tests_linkstatic(), - tags = ["no_windows"], # b/150411480 deps = [ "//tensorflow/core:framework", "//tensorflow/core:lib", diff --git a/tensorflow/core/util/debug_events_writer.cc b/tensorflow/core/util/debug_events_writer.cc index 8ee42959131..ec8ecc1902c 100644 --- a/tensorflow/core/util/debug_events_writer.cc +++ b/tensorflow/core/util/debug_events_writer.cc @@ -403,6 +403,13 @@ string DebugEventsWriter::FileName(DebugEventFileType type) { } Status DebugEventsWriter::Close() { + { + mutex_lock l(initialization_mu_); + if (!is_initialized_) { + return Status::OK(); + } + } + std::vector failed_to_close_files; if (metadata_writer_ != nullptr) { diff --git a/tensorflow/python/debug/BUILD b/tensorflow/python/debug/BUILD index b4a6ce60f8b..cbfffc1f32d 100644 --- a/tensorflow/python/debug/BUILD +++ b/tensorflow/python/debug/BUILD @@ -776,9 +776,6 @@ cuda_py_test( size = "medium", srcs = ["lib/debug_v2_ops_test.py"], python_version = "PY3", - tags = [ - "no_windows", # b/142475891 - ], deps = [ ":debug_events_reader", ":debug_events_writer", diff --git a/tensorflow/python/debug/lib/debug_v2_ops_test.py b/tensorflow/python/debug/lib/debug_v2_ops_test.py index a3054ad9e27..c05109fbaa1 100644 --- a/tensorflow/python/debug/lib/debug_v2_ops_test.py +++ b/tensorflow/python/debug/lib/debug_v2_ops_test.py @@ -339,7 +339,7 @@ class DebugNumericSummaryV2Test(test_util.TensorFlowTestCase): debug_event_pb2.TensorDebugMode.SHAPE, ] # Maximum allowed tensor_id - tensor_id = np.power(2, 53) + tensor_id = np.power(2, 53, dtype=np.int64) for mode in modes: self.evaluate( gen_debug_ops.debug_numeric_summary_v2(