| 831 | } // end namespace |
| 832 | |
| 833 | bool FunctionDefsEqual(const FunctionDef& f1, const FunctionDef& f2) { |
| 834 | if (!OpDefEqual(f1.signature(), f2.signature())) return false; |
| 835 | |
| 836 | std::map<string, AttrValue> f1_attrs = GetSetAttrs(f1); |
| 837 | std::map<string, AttrValue> f2_attrs = GetSetAttrs(f2); |
| 838 | if (f1_attrs.size() != f2_attrs.size()) return false; |
| 839 | for (auto iter1 : f1_attrs) { |
| 840 | auto iter2 = f2_attrs.find(iter1.first); |
| 841 | if (iter2 == f2_attrs.end()) return false; |
| 842 | if (!AreAttrValuesEqual(iter1.second, iter2->second)) return false; |
| 843 | } |
| 844 | |
| 845 | if (!EqualRepeatedNodeDef(f1.node_def(), f2.node_def(), nullptr)) { |
| 846 | return false; |
| 847 | } |
| 848 | |
| 849 | std::map<string, string> ret1(f1.ret().begin(), f1.ret().end()); |
| 850 | std::map<string, string> ret2(f2.ret().begin(), f2.ret().end()); |
| 851 | if (ret1 != ret2) return false; |
| 852 | |
| 853 | std::map<string, string> control_ret1(f1.control_ret().begin(), |
| 854 | f1.control_ret().end()); |
| 855 | std::map<string, string> control_ret2(f2.control_ret().begin(), |
| 856 | f2.control_ret().end()); |
| 857 | if (control_ret1 != control_ret2) return false; |
| 858 | |
| 859 | return true; |
| 860 | } |
| 861 | |
| 862 | uint64 FunctionDefHash(const FunctionDef& fdef) { |
| 863 | // signature |