Produces a hash of a attribute from an op or a function. Since attributes may refer to functions present in the graph, we may need to hash the function referred to by the attribute, and thus we need the FunctionDefLibrary.
| 172 | // may refer to functions present in the graph, we may need to hash the function |
| 173 | // referred to by the attribute, and thus we need the FunctionDefLibrary. |
| 174 | uint64 HashAttr(const FunctionDefLibrary& library, const std::string& attr_key, |
| 175 | const AttrValue& attr_value, std::vector<std::string>* visited, |
| 176 | absl::flat_hash_map<std::string, uint64>* cache) { |
| 177 | uint64 attr_hash = 0; |
| 178 | if (attr_value.has_func()) { |
| 179 | for (const auto& func : library.function()) { |
| 180 | if (func.signature().name() == attr_value.func().name()) { |
| 181 | attr_hash = Hash64CombineUnordered( |
| 182 | attr_hash, |
| 183 | Hash64(absl::StrCat( |
| 184 | attr_key, "=", |
| 185 | HashSubgraphFunctionImpl(library, &func, visited, cache)))); |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | } else { |
| 190 | attr_hash = Hash64CombineUnordered( |
| 191 | attr_hash, Hash64(absl::StrCat(attr_key, "=", |
| 192 | DeterministicProtoHash64(attr_value)))); |
| 193 | } |
| 194 | |
| 195 | return attr_hash; |
| 196 | } |
| 197 | |
| 198 | // This function hashes a subgraph (rooted at node) by traversing all possible |
| 199 | // dependency paths from that node. |
no test coverage detected