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

Function NodeDefHash

tensorflow/core/util/equal_graph_def.cc:236–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236uint64 NodeDefHash(const NodeDef& ndef, const EqualGraphDefOptions& options) {
237 uint64 h = Hash64(ndef.name());
238 h = Hash64(ndef.op().data(), ndef.op().size(), h);
239 h = Hash64(ndef.device().data(), ndef.device().size(), h);
240
241 // Normal inputs. Order important.
242 int first_control_input = ndef.input_size();
243 for (int i = 0; i < ndef.input_size(); ++i) {
244 if (absl::StartsWith(ndef.input(i), "^")) {
245 first_control_input = i;
246 break;
247 }
248 h = Hash64(ndef.input(i).data(), ndef.input(i).size(), h);
249 }
250
251 // Control inputs. Order irrelevant.
252 std::set<string> ndef_control;
253 for (int i = first_control_input; i < ndef.input_size(); ++i) {
254 ndef_control.insert(ndef.input(i));
255 }
256 for (const string& s : ndef_control) {
257 h = Hash64(s.data(), s.size(), h);
258 }
259
260 // Attributes
261 std::map<string, AttrValue> ndef_attr;
262 for (const auto& a : ndef.attr()) {
263 if (options.ignore_internal_attrs && !a.first.empty() &&
264 a.first[0] == '_') {
265 continue;
266 }
267 ndef_attr[a.first] = a.second;
268 }
269 for (const auto& a : ndef_attr) {
270 h = Hash64(a.first.data(), a.first.size(), h);
271 h = Hash64Combine(AttrValueHash(a.second), h);
272 }
273
274 return h;
275}
276
277} // namespace tensorflow

Callers 1

RepeatedNodeDefHashFunction · 0.85

Calls 14

StartsWithFunction · 0.85
Hash64CombineFunction · 0.85
AttrValueHashFunction · 0.85
attrMethod · 0.80
nameMethod · 0.65
Hash64Function · 0.50
dataMethod · 0.45
opMethod · 0.45
sizeMethod · 0.45
deviceMethod · 0.45
input_sizeMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected