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/02/13 17:00:49 UTC

[GitHub] lebeg commented on a change in pull request #13574: Replaced rand_r with std:: random generation

lebeg commented on a change in pull request #13574: Replaced rand_r with std:: random generation
URL: https://github.com/apache/incubator-mxnet/pull/13574#discussion_r256492598
 
 

 ##########
 File path: src/operator/rnn_impl.h
 ##########
 @@ -176,13 +176,17 @@ void LstmForwardTraining(DType* ws,
       if (dropout > 0.0f) {
         #pragma omp parallel for num_threads(omp_threads)
         for (int j = 0; j < T * N * H * D; j++) {
-          int rand_data = rand_r(&seed_);
+          static thread_local std::random_device device;
 
 Review comment:
   @eric-haibin-lin In general, I don't see why a thread local variable is an issue - there is a separate generator for every thread and nothing needs to be done additionally to ensure thread safety. Otherwise locking needs to be in place.
   
   I could add a generate random number function to the framework API, but wouldn't change the implementation. What do you think?

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