MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / HashNodeDef

Function HashNodeDef

tensorflow/tools/graph_transforms/transform_utils.cc:120–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120uint64 HashNodeDef(const NodeDef& node) {
121 uint64 hash = Hash64String(node.op());
122 hash = Hash64Combine(hash, Hash64String(node.name()));
123 for (const string& input : node.input()) {
124 hash = Hash64Combine(hash, Hash64String(CanonicalInputName(input)));
125 }
126 hash = Hash64Combine(hash, Hash64String(node.device()));
127 std::vector<string> attr_names;
128 attr_names.reserve(node.attr().size());
129 for (const auto& attr : node.attr()) {
130 attr_names.push_back(attr.first);
131 }
132 std::sort(attr_names.begin(), attr_names.end());
133 string attr_serialized;
134 for (const string& attr_name : attr_names) {
135 auto attr = node.attr().at(attr_name);
136 attr.SerializeToString(&attr_serialized);
137 hash = Hash64Combine(hash, Hash64String(attr_serialized));
138 }
139 return hash;
140}
141
142void AddNodeInput(const string& input_name, NodeDef* node) {
143 *(node->mutable_input()->Add()) = input_name;

Callers 2

MergeDuplicateNodesFunction · 0.85
TestHashNodeDefMethod · 0.85

Calls 15

Hash64StringFunction · 0.85
Hash64CombineFunction · 0.85
CanonicalInputNameFunction · 0.85
sortFunction · 0.85
attrMethod · 0.80
nameMethod · 0.65
opMethod · 0.45
inputMethod · 0.45
deviceMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 1

TestHashNodeDefMethod · 0.68