• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #include "tensorflow/core/debug/debug_node_key.h"
17 
18 #include "tensorflow/core/lib/strings/str_util.h"
19 #include "tensorflow/core/lib/strings/strcat.h"
20 
21 namespace tensorflow {
22 
23 const char* const DebugNodeKey::kMetadataFilePrefix = "_tfdbg_";
24 
25 const char* const DebugNodeKey::kDeviceTag = "device_";
26 
DebugNodeKey(const string & device_name,const string & node_name,const int32 output_slot,const string & debug_op)27 DebugNodeKey::DebugNodeKey(const string& device_name, const string& node_name,
28                            const int32 output_slot, const string& debug_op)
29     : device_name(device_name),
30       node_name(node_name),
31       output_slot(output_slot),
32       debug_op(debug_op),
33       debug_node_name(
34           strings::StrCat(node_name, ":", output_slot, ":", debug_op)),
35       device_path(DeviceNameToDevicePath(device_name)) {}
36 
operator ==(const DebugNodeKey & other) const37 bool DebugNodeKey::operator==(const DebugNodeKey& other) const {
38   return (device_name == other.device_name && node_name == other.node_name &&
39           output_slot == other.output_slot && debug_op == other.debug_op);
40 }
41 
operator !=(const DebugNodeKey & other) const42 bool DebugNodeKey::operator!=(const DebugNodeKey& other) const {
43   return !((*this) == other);
44 }
45 
DeviceNameToDevicePath(const string & device_name)46 const string DebugNodeKey::DeviceNameToDevicePath(const string& device_name) {
47   return strings::StrCat(
48       kMetadataFilePrefix, kDeviceTag,
49       str_util::StringReplace(
50           str_util::StringReplace(device_name, ":", "_", true), "/", ",",
51           true));
52 }
53 
54 }  // namespace tensorflow
55