You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the intrinsics randSetSeed and randIntU have a somewhat peculiar semantics. Specifically, the first occurrence of randIntU randomly initializes the seed of the pseudo-random number generator (Random.self_init in boot), unless you call randSetSeed before this first occurence. This caused some unexpected behavior in combination with externalSetSeed that, in addition to setting the standard OCaml Random library seed, also initializes random number generators for Owl. For example, the call to randIntU below randomly initializes the seed even though we call externalSetSeed.
externalSetSeed 0 -- Calls Random.init 0 internally
let x = randIntU 0 10 in -- Calls Random.self_init internally
...
I fixed this for my use cases by constructing a function setSeed that internally calls both externalSetSeed and randSetSeed:
setSeed 0 -- Calls externalSetSeed and randSetSeed internally
let x = randIntU 0 10 in -- Does _not_ call Random.self_init internally
...
However, I think that we should change the current randSetSeed and randIntU semantics to one of the following:
Simply do not call Random.self_init in randIntU. The result is that the seed is set to a standard value in each execution. If we want random seed initialization, we can add another intrinsic randSeedSelfInit or similar.
Call Random.self_init once, in the very beginning of the program, and not in conjunction with randIntU.
The text was updated successfully, but these errors were encountered:
Yes, that would probably be the best long-term solution. I think there are some limitations with externals currently? For example, they don't work in boot (but maybe that's fine).
It might be worth checking if the uses of randIntU in the stdlib can be replaced by externals, then. If they're not part of the first pass of bootstrapping it should work, right?
Currently, the intrinsics
randSetSeed
andrandIntU
have a somewhat peculiar semantics. Specifically, the first occurrence ofrandIntU
randomly initializes the seed of the pseudo-random number generator (Random.self_init
in boot), unless you callrandSetSeed
before this first occurence. This caused some unexpected behavior in combination withexternalSetSeed
that, in addition to setting the standard OCamlRandom
library seed, also initializes random number generators for Owl. For example, the call torandIntU
below randomly initializes the seed even though we callexternalSetSeed
.I fixed this for my use cases by constructing a function
setSeed
that internally calls bothexternalSetSeed
andrandSetSeed
:However, I think that we should change the current
randSetSeed
andrandIntU
semantics to one of the following:Random.self_init
inrandIntU
. The result is that the seed is set to a standard value in each execution. If we want random seed initialization, we can add another intrinsicrandSeedSelfInit
or similar.Random.self_init
once, in the very beginning of the program, and not in conjunction withrandIntU
.The text was updated successfully, but these errors were encountered: