| 795 | } |
| 796 | |
| 797 | bool RepeatedAttrDefEqual( |
| 798 | const protobuf::RepeatedPtrField<OpDef::AttrDef>& a1, |
| 799 | const protobuf::RepeatedPtrField<OpDef::AttrDef>& a2) { |
| 800 | std::unordered_map<string, const OpDef::AttrDef*> a1_set; |
| 801 | for (const OpDef::AttrDef& def : a1) { |
| 802 | if (a1_set.find(def.name()) != a1_set.end()) { |
| 803 | LOG(ERROR) << "AttrDef names must be unique, but '" << def.name() |
| 804 | << "' appears more than once"; |
| 805 | } |
| 806 | a1_set[def.name()] = &def; |
| 807 | } |
| 808 | for (const OpDef::AttrDef& def : a2) { |
| 809 | auto iter = a1_set.find(def.name()); |
| 810 | if (iter == a1_set.end()) return false; |
| 811 | if (!AttrDefEqual(*iter->second, def)) return false; |
| 812 | a1_set.erase(iter); |
| 813 | } |
| 814 | if (!a1_set.empty()) return false; |
| 815 | return true; |
| 816 | } |
| 817 | |
| 818 | uint64 RepeatedAttrDefHash( |
| 819 | const protobuf::RepeatedPtrField<OpDef::AttrDef>& a) { |