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/01 18:00:41 UTC

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

piiswrong 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_r185288458
 
 

 ##########
 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:
   How about using dmlc::HashCombine?
   like this https://github.com/apache/incubator-mxnet/blob/b59943e9ca9dd4d603ffd8b2464d431dbd1d9bdb/src/operator/nn/cudnn/cudnn_algoreg-inl.h#L160

----------------------------------------------------------------
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