| 860 | } |
| 861 | |
| 862 | uint64 FunctionDefHash(const FunctionDef& fdef) { |
| 863 | // signature |
| 864 | uint64 h = OpDefHash(fdef.signature()); |
| 865 | |
| 866 | // attrs |
| 867 | std::map<string, AttrValue> attrs = GetSetAttrs(fdef); |
| 868 | for (const auto& p : attrs) { |
| 869 | h = Hash64(p.first.data(), p.first.size(), h); |
| 870 | h = Hash64Combine(AttrValueHash(p.second), h); |
| 871 | } |
| 872 | |
| 873 | // node defs |
| 874 | h = Hash64Combine(RepeatedNodeDefHash(fdef.node_def()), h); |
| 875 | |
| 876 | // output names |
| 877 | std::map<string, string> ret(fdef.ret().begin(), fdef.ret().end()); |
| 878 | for (const auto& p : ret) { |
| 879 | h = Hash64(p.first.data(), p.first.size(), h); |
| 880 | h = Hash64(p.second.data(), p.second.size(), h); |
| 881 | } |
| 882 | |
| 883 | // control output names |
| 884 | std::map<string, string> control_ret(fdef.control_ret().begin(), |
| 885 | fdef.control_ret().end()); |
| 886 | for (const auto& p : control_ret) { |
| 887 | h = Hash64(p.first.data(), p.first.size(), h); |
| 888 | h = Hash64(p.second.data(), p.second.size(), h); |
| 889 | } |
| 890 | |
| 891 | return h; |
| 892 | } |
| 893 | |
| 894 | static constexpr const char* const kExecutorAttr = "_executor"; |
| 895 | |