forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDict.cpp
29 lines (26 loc) · 742 Bytes
/
Dict.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <ATen/core/Dict.h>
namespace c10 {
namespace detail {
bool operator==(const DictImpl& lhs, const DictImpl& rhs) {
bool isEqualFastChecks =
*lhs.elementTypes.keyType == *rhs.elementTypes.keyType &&
*lhs.elementTypes.valueType == *rhs.elementTypes.valueType &&
lhs.dict.size() == rhs.dict.size();
if (!isEqualFastChecks) {
return false;
}
// Dict equality should not care about ordering.
for (const auto& pr : lhs.dict) {
auto it = rhs.dict.find(pr.first);
if (it == rhs.dict.cend()) {
return false;
}
// see: [container equality]
if (!_fastEqualsForContainer(it->second, pr.second)) {
return false;
}
}
return true;
}
} // namespace detail
} // namespace c10