yzhliu edited a comment on issue #13574: Replaced rand_r with std:: random 
generation
URL: https://github.com/apache/incubator-mxnet/pull/13574#issuecomment-463932903
 
 
   Usually using `thread_local` rand generator is not a good idea, not only in 
the sense of system design, but it could be invalid.
   
   Say if you use 4 threads to fill an array A[4], each Gaussian random 
generator fills one entry with its head element - `A[0] = gen1[0], A[1] = 
gen2[0], A[2] = gen3[0], A[3] = gen4[0]` - this array in fact does not 
necessarily follow Gaussian distribution (sometimes with specific implement it 
does, but no guarantee). Pseudorandom sequence has to be long enough in order 
to satisfy the distribution property. Such "bug" is rare but will be extremely 
hard to debug once occurs (which I met before).
   
   Also it will be great to let users set their global seed, as some (maybe 
not-well-designed) algorithms are sensitive to seed number. This means all 
random generators within the system should take same input seed as their 
constructor argument. (I know currently this rule is not well followed in mxnet 
though.)
   
   This is why `RandGenerator` is implemented so complicated.

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


With regards,
Apache Git Services

Reply via email to