You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

random_state.h 523 B

1234567891011121314151617181920212223
  1. #pragma once
  2. #include <random>
  3. namespace megdnn {
  4. namespace test {
  5. class RandomState {
  6. public:
  7. static std::mt19937& generator() { return instance()->m_generator; }
  8. static void reset() { instance()->m_generator.seed(m_seed); }
  9. private:
  10. RandomState() : m_generator(m_seed) {}
  11. std::mt19937 m_generator;
  12. const static int m_seed = 42;
  13. static RandomState* instance() { return &m_instance; }
  14. static RandomState m_instance;
  15. };
  16. } // namespace test
  17. } // namespace megdnn
  18. // vim: syntax=cpp.doxygen