You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/02 13:17:53 UTC

[GitHub] larroy commented on a change in pull request #10746: [MXNET-368] Fix mxnet::Context hash for 32 bit architectures, where size_t is 32 …

larroy commented on a change in pull request #10746: [MXNET-368] Fix mxnet::Context hash for 32 bit architectures, where size_t is 32 …
URL: https://github.com/apache/incubator-mxnet/pull/10746#discussion_r185491811
 
 

 ##########
 File path: include/mxnet/base.h
 ##########
 @@ -365,7 +365,9 @@ constexpr size_t kMKLDNNAlign = 64;
 namespace std {
 template<> struct hash<mxnet::Context> {
   size_t operator()(const mxnet::Context& ctx) const {
-    return (static_cast<size_t>(ctx.dev_type) << 32) | ctx.dev_id;
+    size_t dev_type = static_cast<size_t>(ctx.dev_type);
+    size_t dev_id = static_cast<size_t>(ctx.dev_id);
+    return (dev_id << 3) ^ dev_type ^ (dev_id >> 29);
 
 Review comment:
   I find that the number of collisions is quite high, more than 3% as you can see in the test case. I'm not sure if this is a good hash function. Anyways done using your suggestion.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services