11use bit_set:: BitSet ;
2+ use fastrand:: Rng ;
23use num_traits:: { AsPrimitive , Bounded , PrimInt } ;
34use ordered_float:: OrderedFloat ;
45use pyo3:: prelude:: * ;
5- use rand:: Rng ;
6- use rand:: SeedableRng ;
76use rustc_hash:: FxHashMap ;
87use std:: collections:: { BTreeSet , BinaryHeap , HashSet } ;
98use std:: f32;
@@ -466,8 +465,8 @@ impl<Ix: IndexType, Node: NodeType> ContractionProcessor<Ix, Node> {
466465
467466 let mut rng = if coeff_t != 0.0 {
468467 Some ( match seed {
469- Some ( seed) => rand :: rngs :: StdRng :: seed_from_u64 ( seed) ,
470- None => rand :: rngs :: StdRng :: from_os_rng ( ) ,
468+ Some ( seed) => Rng :: with_seed ( seed) ,
469+ None => Rng :: new ( ) ,
471470 } )
472471 } else {
473472 // zero temp - no need for rng
@@ -476,7 +475,7 @@ impl<Ix: IndexType, Node: NodeType> ContractionProcessor<Ix, Node> {
476475
477476 let mut local_score = |sa : Score , sb : Score , sab : Score | -> Score {
478477 let gumbel = if let Some ( rng) = & mut rng {
479- coeff_t * -f32:: ln ( -f32:: ln ( rng. random ( ) ) )
478+ coeff_t * -f32:: ln ( -f32:: ln ( rng. f32 ( ) ) )
480479 } else {
481480 0.0 as f32
482481 } ;
@@ -1034,7 +1033,7 @@ fn run_random_greedy_optimization<Ix: IndexType, Node: NodeType>(
10341033 log_temp_diff : f32 ,
10351034 is_const_temp : bool ,
10361035 max_neighbors : Option < usize > ,
1037- rng : & mut rand :: rngs :: StdRng ,
1036+ rng : & mut Rng ,
10381037) -> ( SSAPath , Score ) {
10391038 let mut cp0: ContractionProcessor < Ix , Node > =
10401039 ContractionProcessor :: new ( inputs, output, size_dict, true ) ;
@@ -1057,13 +1056,13 @@ fn run_random_greedy_optimization<Ix: IndexType, Node: NodeType>(
10571056 let costmod = if is_const_costmod {
10581057 costmod_min
10591058 } else {
1060- costmod_min + rng. random :: < f32 > ( ) * costmod_diff
1059+ costmod_min + rng. f32 ( ) * costmod_diff
10611060 } ;
10621061
10631062 let temperature = if is_const_temp {
10641063 temp_min
10651064 } else {
1066- f32:: exp ( log_temp_min + rng. random :: < f32 > ( ) * log_temp_diff)
1065+ f32:: exp ( log_temp_min + rng. f32 ( ) * log_temp_diff)
10671066 } ;
10681067
10691068 let success =
@@ -1401,10 +1400,10 @@ fn optimize_random_greedy_track_flops(
14011400 let is_const_temp = log_temp_diff < Score :: EPSILON ;
14021401
14031402 let mut rng = match seed {
1404- Some ( seed) => rand :: rngs :: StdRng :: seed_from_u64 ( seed) ,
1405- None => rand :: rngs :: StdRng :: from_os_rng ( ) ,
1403+ Some ( seed) => Rng :: with_seed ( seed) ,
1404+ None => Rng :: new ( ) ,
14061405 } ;
1407- let seeds = ( 0 ..ntrials) . map ( |_| rng. random ( ) ) . collect :: < Vec < u64 > > ( ) ;
1406+ let seeds = ( 0 ..ntrials) . map ( |_| rng. u64 ( .. ) ) . collect :: < Vec < u64 > > ( ) ;
14081407
14091408 let num_indices = size_dict. len ( ) ;
14101409 let max_nodes = 2 * n;
0 commit comments