// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "random_seed.h" #include "random_generator.h" #include #include namespace onnxruntime { namespace utils { static std::atomic& GetGlobalRandomSeed() { static std::atomic g_random_seed( std::chrono::system_clock::now().time_since_epoch().count()); return g_random_seed; } int64_t GetRandomSeed() { return GetGlobalRandomSeed().load(); } void SetRandomSeed(int64_t seed) { GetGlobalRandomSeed().store(seed); // Reset default generators. RandomGenerator::Default().SetSeed(seed); PhiloxGenerator::Default().SetSeed(static_cast(seed)); } } // namespace utils } // namespace onnxruntime