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

Method ComputeTopoHash

tensorflow/core/grappler/graph_analyzer/sig_node.cc:104–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104void SigNode::ComputeTopoHash(int distance) {
105 // The new starting point.
106 next_hashed_nodes_ = last_hashed_nodes_;
107 if (debug) {
108 LOG(INFO) << "DEBUG node " << name() << " mask=" << std::hex
109 << next_hashed_nodes_;
110 }
111
112 if (hash_is_final_) {
113 return;
114 }
115
116 CHECK(topo_hash_.size() == distance);
117
118 int prev = distance - 1;
119
120 // Start with own's local topology hash. This value is stable, so
121 // if the hashes of the surrounding nodes don't change on the following
122 // distances, the hash of this node won't change either.
123 size_t hval = topo_hash_[0];
124
125 if (!hashed_peers_.empty()) {
126 size_t last_link_hash = hashed_peers_[0].link_hash;
127 size_t comm_hash = 0;
128
129 for (const auto& entry : hashed_peers_) {
130 if (entry.link_hash != last_link_hash) {
131 CombineHash(last_link_hash, &hval);
132 CombineHash(comm_hash, &hval);
133 comm_hash = 0;
134 last_link_hash = entry.link_hash;
135 }
136
137 // The links in the same vector are commutative, so combine their
138 // hashes in a commutative way.
139 CombineHashCommutative(entry.peer->GetTopoHash(prev), &comm_hash);
140 next_hashed_nodes_ |= entry.peer->last_hashed_nodes_;
141 if (debug) {
142 LOG(INFO) << "DEBUG node " << name() << " += " << entry.peer->name()
143 << " mask=" << std::hex << next_hashed_nodes_;
144 }
145 }
146
147 // The last commutative group.
148 CombineHash(last_link_hash, &hval);
149 CombineHash(comm_hash, &hval);
150 }
151
152 topo_hash_.push_back(hval);
153}
154
155size_t SigNode::GetTopoHash(int distance) const {
156 CHECK(!topo_hash_.empty());

Callers 1

ComputeOneRoundMethod · 0.45

Calls 8

nameFunction · 0.85
CombineHashFunction · 0.85
CombineHashCommutativeFunction · 0.85
nameMethod · 0.65
sizeMethod · 0.45
emptyMethod · 0.45
GetTopoHashMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected