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

 ##########
 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 + reinterpret_cast<uint64_t>(&random_number[0]) % 
4096;
 
 Review comment:
   Why does it need the modulus operator `%` ? the modulus operator makes the 
`seed_` between 0+17~4096+17

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to