From 0b24f7f0a41d369942bfcadac3a3cf494167f8a6 Mon Sep 17 00:00:00 2001 From: Benjamin Beurdouche Date: Sun, 16 Mar 2025 19:14:55 +0100 Subject: [PATCH] Fix for whisper example. rand::distribution is now rand::distr (#2811) --- candle-examples/examples/whisper/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/candle-examples/examples/whisper/main.rs b/candle-examples/examples/whisper/main.rs index 84aa8b74..9872d494 100644 --- a/candle-examples/examples/whisper/main.rs +++ b/candle-examples/examples/whisper/main.rs @@ -14,7 +14,9 @@ use candle::{Device, IndexOp, Tensor}; use candle_nn::{ops::softmax, VarBuilder}; use clap::{Parser, ValueEnum}; use hf_hub::{api::sync::Api, Repo, RepoType}; -use rand::{distributions::Distribution, SeedableRng}; +use rand::distr::weighted::WeightedIndex; +use rand::distr::Distribution; +use rand::SeedableRng; use tokenizers::Tokenizer; mod multilingual; @@ -208,7 +210,7 @@ impl Decoder { let next_token = if t > 0f64 { let prs = softmax(&(&logits / t)?, 0)?; let logits_v: Vec = prs.to_vec1()?; - let distr = rand::distributions::WeightedIndex::new(&logits_v)?; + let distr = WeightedIndex::new(&logits_v)?; distr.sample(&mut self.rng) as u32 } else { let logits_v: Vec = logits.to_vec1()?;