aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/debug
diff options
context:
space:
mode:
authorGravatar Shanqing Cai <cais@google.com>2017-06-15 10:38:27 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-06-15 10:45:34 -0700
commit525b0f05839779e40d0ca9cc2967a3886b6a0f4d (patch)
treeca3b4f12b37aa08a42b4afb20b86f5b497e5d06b /tensorflow/core/debug
parent6b56b5e4b904eb7fb5e9a95cd3046069e029caa4 (diff)
tfdbg: fix race condition in picking graph file names
by adding a hash to the _tfdbg_graph_* files PiperOrigin-RevId: 159122097
Diffstat (limited to 'tensorflow/core/debug')
-rw-r--r--tensorflow/core/debug/debug_io_utils.cc9
-rw-r--r--tensorflow/core/debug/debug_io_utils.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/tensorflow/core/debug/debug_io_utils.cc b/tensorflow/core/debug/debug_io_utils.cc
index 54366ce249..88dffb934c 100644
--- a/tensorflow/core/debug/debug_io_utils.cc
+++ b/tensorflow/core/debug/debug_io_utils.cc
@@ -131,6 +131,9 @@ const char* const DebugIO::kDeviceTag = "device_";
// static
const char* const DebugIO::kGraphTag = "graph_";
+// static
+const char* const DebugIO::kHashTag = "hash";
+
DebugNodeKey::DebugNodeKey(const string& device_name, const string& node_name,
const int32 output_slot, const string& debug_op)
: device_name(device_name),
@@ -351,8 +354,10 @@ Status DebugIO::PublishGraph(const Graph& graph, const string& device_name,
const string dump_root_dir =
io::JoinPath(debug_url.substr(strlen(kFileURLScheme)),
DebugNodeKey::DeviceNameToDevicePath(device_name));
- const string file_name = strings::StrCat(DebugIO::kMetadataFilePrefix,
- DebugIO::kGraphTag, now_micros);
+ const uint64 graph_hash = ::tensorflow::Hash64(buf);
+ const string file_name =
+ strings::StrCat(DebugIO::kMetadataFilePrefix, DebugIO::kGraphTag,
+ DebugIO::kHashTag, graph_hash, "_", now_micros);
status.Update(
DebugFileIO::DumpEventProtoToFile(event, dump_root_dir, file_name));
diff --git a/tensorflow/core/debug/debug_io_utils.h b/tensorflow/core/debug/debug_io_utils.h
index 69d8c7bd4e..4caa4b5e04 100644
--- a/tensorflow/core/debug/debug_io_utils.h
+++ b/tensorflow/core/debug/debug_io_utils.h
@@ -143,6 +143,7 @@ class DebugIO {
static const char* const kCoreMetadataTag;
static const char* const kDeviceTag;
static const char* const kGraphTag;
+ static const char* const kHashTag;
static const char* const kFileURLScheme;
static const char* const kGrpcURLScheme;