26 #ifndef TVM_SUPPORT_RANDOM_ENGINE_H_ 27 #define TVM_SUPPORT_RANDOM_ENGINE_H_ 29 #include <tvm/runtime/logging.h> 87 (*rand_state_ptr_) = ((*rand_state_ptr_) * multiplier +
increment) % modulus;
88 return *rand_state_ptr_;
99 else if (rand_state < 0)
101 ICHECK(rand_state_ptr_ !=
nullptr);
102 *rand_state_ptr_ = rand_state;
112 return ((*
this)() * 32767) % 1999999973;
123 rand_state_ptr_ = rand_state_ptr;
133 #endif // TVM_SUPPORT_RANDOM_ENGINE_H_ static constexpr TRandState modulus
The modulus.
Definition: random_engine.h:62
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
static constexpr TRandState multiplier
The multiplier.
Definition: random_engine.h:56
int64_t TRandState
Definition: random_engine.h:53
LinearCongruentialEngine(TRandState *rand_state_ptr)
Construct a random number generator with a random state pointer.
Definition: random_engine.h:122
This linear congruential engine is a drop-in replacement for std::minstd_rand. It strictly correspond...
Definition: random_engine.h:46
uint64_t result_type
The result type is defined as uint64_t here to avoid overflow.
Definition: random_engine.h:52
TRandState ForkSeed()
Fork a new seed for another RNG from current random state.
Definition: random_engine.h:109
void Seed(TRandState rand_state=1)
Change the start random state of RNG with the seed of a new random state value.
Definition: random_engine.h:95
static constexpr TRandState increment
The increment.
Definition: random_engine.h:59
result_type operator()()
Operator to move the random state to the next and return the new random state. According to definitio...
Definition: random_engine.h:86
static constexpr result_type max()
The maximum possible value of random state here.
Definition: random_engine.h:74
static constexpr result_type min()
The minimum possible value of random state here.
Definition: random_engine.h:68