upgrade half library to fix rand (#2806)

fix lints
This commit is contained in:
Mike Seddon
2025-03-14 19:01:54 +11:00
committed by GitHub
parent 111edbc4ea
commit c930ab7e1a
9 changed files with 38 additions and 37 deletions

View File

@ -16,7 +16,7 @@ use candle_transformers::models::quantized_metavoice::transformer as qtransforme
use candle::{DType, IndexOp, Tensor};
use candle_nn::VarBuilder;
use hf_hub::api::sync::Api;
use rand::{distributions::Distribution, SeedableRng};
use rand::{distr::Distribution, SeedableRng};
pub const ENCODEC_NTOKENS: u32 = 1024;
@ -250,7 +250,7 @@ fn main() -> Result<()> {
let logits = logits.i(step)?.to_dtype(DType::F32)?;
let logits = &(&logits / 1.0)?;
let prs = candle_nn::ops::softmax_last_dim(logits)?.to_vec1::<f32>()?;
let distr = rand::distributions::WeightedIndex::new(prs.as_slice())?;
let distr = rand::distr::weighted::WeightedIndex::new(prs.as_slice())?;
let sample = distr.sample(&mut rng) as u32;
codes_.push(sample)
}

View File

@ -617,7 +617,7 @@ fn run(args: Args) -> Result<()> {
let mut scheduler = sd_config.build_scheduler(n_steps)?;
let device = candle_examples::device(cpu)?;
// If a seed is not given, generate a random seed and print it
let seed = seed.unwrap_or(rand::thread_rng().gen_range(0u64..u64::MAX));
let seed = seed.unwrap_or(rand::rng().random_range(0u64..u64::MAX));
println!("Using seed {seed}");
device.set_seed(seed)?;
let use_guide_scale = guidance_scale > 1.0;