12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef TENSORFLOW_CORE_UTIL_GUARDED_PHILOX_RANDOM_H_
- #define TENSORFLOW_CORE_UTIL_GUARDED_PHILOX_RANDOM_H_
- #include "philox_random.h"
- #include "tensorflow/core/platform/macros.h"
- #include "tensorflow/core/platform/types.h"
- namespace tensorflow {
- class GuardedPhiloxRandom {
- public:
-
- GuardedPhiloxRandom() : initialized_(false) {}
-
-
-
-
- void Init(int64 seed, int64 seed2);
- void Init(random::PhiloxRandom::ResultType counter, random::PhiloxRandom::Key key);
-
-
-
- random::PhiloxRandom ReserveSamples128(int64 samples);
-
- random::PhiloxRandom ReserveSamples32(int64 samples) {
- return ReserveSamples128((samples + 3) / 4);
- }
-
- random::PhiloxRandom ReserveRandomOutputs(int64 output_count, int multiplier) {
- int64 conservative_sample_count = output_count * multiplier;
- return ReserveSamples128(conservative_sample_count);
- }
- private:
-
- random::PhiloxRandom generator_;
- bool initialized_;
- TF_DISALLOW_COPY_AND_ASSIGN(GuardedPhiloxRandom);
- };
- }
- #endif
|