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 2019/10/21 23:40:55 UTC

[GitHub] [incubator-mxnet] eric-haibin-lin commented on a change in pull request #16532: fix dropout gpu seed

eric-haibin-lin commented on a change in pull request #16532: fix dropout gpu seed
URL: https://github.com/apache/incubator-mxnet/pull/16532#discussion_r337286514
 
 

 ##########
 File path: src/operator/nn/dropout-inl.h
 ##########
 @@ -253,7 +253,16 @@ class DropoutOp {
                            const TBlob &mask,
                            const TBlob &out) {
       Stream<xpu> *s = ctx.get_stream<xpu>();
-
+      Random<xpu, unsigned> *prnd = ctx.requested[1].get_random<xpu, unsigned>(s);
+      Tensor<xpu, 1, char> workspace =
+        ctx.requested[2].get_space_typed<xpu, 1, char>(Shape1(1), s);
+      // slice workspace
+      char *workspace_ptr = workspace.dptr_;
+      Tensor<xpu, 1, unsigned> random_number =
+        Tensor<xpu, 1, unsigned>(reinterpret_cast<unsigned *>(workspace_ptr),
+                                 Shape1(1), s);
+      prnd->GetRandInt(random_number);
+      uint64_t seed_ = 17 + static_cast<uint64_t>(random_number[0]) % 4096;
 
 Review comment:
   The tensor is on GPU, we need to explicitly copy it back to CPU using cudaMemCopy. You might get garbage value if you just access data on GPU mem address directly 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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