-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reflection for std::unordered_map to support hashing global circular buffers #15797
Conversation
ee9faa4
to
a5e4724
Compare
a5e4724
to
7210be5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. definitely needs metal team review.
tt_metal/tt_stl/reflection.hpp
Outdated
// Combine using xor so that the hash is order invariant | ||
// Alternative could be to sort the keys before hashing | ||
for (const auto& [key, value] : object) { | ||
hash ^= hash_objects(seed, key, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be a bit worried by this, possibly introduces some extra hash collisions. I would prefer to sort them instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I will change to sort instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sminakov-tt I've updated to sort first then hash the same way as std::map. Let me know if this looks okay now.
7210be5
to
d4109d1
Compare
Ticket
Link to Github Issue
Problem description
Need to support hashing the GlobalCircularBuffer object in order to be consumed by ops, which has an unordered_map.
What's changed
Add hashing support for std::map and std::unordered_map.
Checklist