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

 ##########
 File path: src/operator/nn/dropout-inl.h
 ##########
 @@ -253,7 +253,18 @@ class DropoutOp {
                            const TBlob &mask,
                            const TBlob &out) {
       Stream<xpu> *s = ctx.get_stream<xpu>();
-
+      // get a random seed from mxnet random on cpu
+      Stream<cpu> *stream = ctx.get_stream<cpu>();
+      Random<cpu, unsigned> *prnd = ctx.requested[1].get_random<cpu, 
unsigned>(stream);
+      Tensor<cpu, 1, char> workspace =
+        ctx.requested[2].get_space_typed<cpu, 1, char>(Shape1(1), stream);
+      // slice workspace
+      char *workspace_ptr = workspace.dptr_;
+      Tensor<cpu, 1, unsigned> random_number =
+        Tensor<cpu, 1, unsigned>(reinterpret_cast<unsigned *>(workspace_ptr),
+                                 Shape1(1), stream);
+      prnd->GetRandInt(random_number);
+      uint64_t seed_ = 17 + reinterpret_cast<uint64_t>(&random_number) % 4096; 
 // NOLINT(runtime/threadsafe_fn)
 
 Review comment:
   Why is it `&random_number` ?

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