From 6134134080ae9b596d0a43206a6157c5739ecca3 Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Sat, 27 Apr 2024 20:37:12 -0400 Subject: [PATCH] use std::chrono::system_clock::now() for random seed --- common/sampling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/sampling.cpp b/common/sampling.cpp index f24665501..f77dad5b3 100644 --- a/common/sampling.cpp +++ b/common/sampling.cpp @@ -1,5 +1,6 @@ #define LLAMA_API_INTERNAL #include "sampling.h" +#include #include struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_params & params) { @@ -68,7 +69,7 @@ void llama_sampling_reset(llama_sampling_context * ctx) { void llama_sampling_set_rng_seed(struct llama_sampling_context * ctx, uint32_t seed) { if (seed == LLAMA_DEFAULT_SEED) { - seed = time(NULL); + seed = static_cast(std::chrono::system_clock::now().time_since_epoch().count()); } ctx->rng.seed(seed); }