From 79ba08ec5870dae1a30e235a3bc2eb546d610341 Mon Sep 17 00:00:00 2001 From: Canberk Pitirli Date: Thu, 1 Oct 2026 16:50:32 +0300 Subject: [PATCH] update rand to 0.10 and rand_distr to 0.6 --- Cargo.toml | 4 ++-- src/rng.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a3bc1b4..c3536a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ name = "fastnn" path = "src/lib.rs" [dependencies] -rand = "0.8" # weight init, dropout masks, shuffling -rand_distr = "0.4" # normal distribution +rand = "0.10" # weight init, dropout masks, shuffling +rand_distr = "0.6" # normal distribution rayon = "1.8" # data parallelism on the CPU paths libm = "0.2" # erff, for exact GELU ureq = "2.9" # dataset download diff --git a/src/rng.rs b/src/rng.rs index 8045a55..844fa1c 100644 --- a/src/rng.rs +++ b/src/rng.rs @@ -6,11 +6,11 @@ use std::cell::RefCell; use rand::rngs::StdRng; -use rand::{Rng, SeedableRng}; +use rand::{RngExt, SeedableRng}; use rand_distr::StandardNormal; thread_local! { - static RNG: RefCell = RefCell::new(StdRng::from_entropy()); + static RNG: RefCell = RefCell::new(rand::make_rng()); } /// Reseed this thread's generator so a run reproduces exactly. @@ -25,7 +25,7 @@ pub fn with_rng(f: impl FnOnce(&mut StdRng) -> T) -> T { /// `n` samples from the uniform distribution on `[lo, hi)`. pub fn uniform(n: usize, lo: f32, hi: f32) -> Vec { - with_rng(|rng| (0..n).map(|_| rng.gen_range(lo..hi)).collect()) + with_rng(|rng| (0..n).map(|_| rng.random_range(lo..hi)).collect()) } /// `n` samples from the standard normal distribution. @@ -35,7 +35,7 @@ pub fn normal(n: usize) -> Vec { /// `n` draws from Bernoulli(`p`), as a bitmask of `true` = kept. pub fn bernoulli(n: usize, p: f32) -> Vec { - with_rng(|rng| (0..n).map(|_| rng.gen::() < p).collect()) + with_rng(|rng| (0..n).map(|_| rng.random::() < p).collect()) } /// Shuffle in place, using this thread's generator so `manual_seed` covers it.