mirror of
https://github.com/huggingface/candle.git
synced 2025-06-15 18:28:24 +00:00
Fix for clippy 1.86. (#2864)
* Fix for clippy 1.86. * More clippy fixes. * More fixes.
This commit is contained in:
@ -21,7 +21,7 @@ impl Config {
|
||||
}
|
||||
|
||||
fn dt_rank(&self) -> usize {
|
||||
(self.d_model + 15) / 16
|
||||
self.d_model.div_ceil(16)
|
||||
}
|
||||
|
||||
fn d_conv(&self) -> usize {
|
||||
|
@ -104,7 +104,7 @@ impl EncoderBlock {
|
||||
let snake1 = Snake1d::new(dim / 2, vb.pp(3))?;
|
||||
let cfg1 = Conv1dConfig {
|
||||
stride,
|
||||
padding: (stride + 1) / 2,
|
||||
padding: stride.div_ceil(2),
|
||||
..Default::default()
|
||||
};
|
||||
let conv1 = encodec::conv1d_weight_norm(dim / 2, dim, 2 * stride, cfg1, vb.pp(4))?;
|
||||
@ -196,7 +196,7 @@ impl DecoderBlock {
|
||||
let snake1 = Snake1d::new(in_dim, vb.pp(0))?;
|
||||
let cfg = ConvTranspose1dConfig {
|
||||
stride,
|
||||
padding: (stride + 1) / 2,
|
||||
padding: stride.div_ceil(2),
|
||||
..Default::default()
|
||||
};
|
||||
let conv_tr1 = encodec::conv_transpose1d_weight_norm(
|
||||
|
@ -6,8 +6,8 @@ pub fn get_noise(
|
||||
width: usize,
|
||||
device: &Device,
|
||||
) -> Result<Tensor> {
|
||||
let height = (height + 15) / 16 * 2;
|
||||
let width = (width + 15) / 16 * 2;
|
||||
let height = height.div_ceil(16) * 2;
|
||||
let width = width.div_ceil(16) * 2;
|
||||
Tensor::randn(0f32, 1., (num_samples, 16, height, width), device)
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ pub fn get_schedule(num_steps: usize, shift: Option<(usize, f64, f64)>) -> Vec<f
|
||||
|
||||
pub fn unpack(xs: &Tensor, height: usize, width: usize) -> Result<Tensor> {
|
||||
let (b, _h_w, c_ph_pw) = xs.dims3()?;
|
||||
let height = (height + 15) / 16;
|
||||
let width = (width + 15) / 16;
|
||||
let height = height.div_ceil(16);
|
||||
let width = width.div_ceil(16);
|
||||
xs.reshape((b, height, width, c_ph_pw / 4, 2, 2))? // (b, h, w, c, ph, pw)
|
||||
.permute((0, 3, 1, 4, 2, 5))? // (b, c, h, ph, w, pw)
|
||||
.reshape((b, c_ph_pw / 4, height * 2, width * 2))
|
||||
|
@ -27,7 +27,7 @@ impl Config {
|
||||
}
|
||||
|
||||
fn dt_rank(&self) -> usize {
|
||||
(self.d_model + 15) / 16
|
||||
self.d_model.div_ceil(16)
|
||||
}
|
||||
|
||||
fn d_inner(&self) -> usize {
|
||||
|
@ -716,7 +716,7 @@ pub mod transformer {
|
||||
None => {
|
||||
let hidden_dim = self.dim * 4;
|
||||
let n_hidden = ((2 * hidden_dim) as f64 / 3.) as usize;
|
||||
(n_hidden + 255) / 256 * 256
|
||||
n_hidden.div_ceil(256) * 256
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ pub fn log_mel_spectrogram_<T: Float>(
|
||||
let samples = {
|
||||
let mut samples_padded = samples.to_vec();
|
||||
let to_add = n_len * fft_step - samples.len();
|
||||
samples_padded.extend(std::iter::repeat(zero).take(to_add));
|
||||
samples_padded.extend(std::iter::repeat_n(zero, to_add));
|
||||
samples_padded
|
||||
};
|
||||
|
||||
|
@ -177,7 +177,7 @@ fn log_mel_spectrogram_<T: Float + std::fmt::Display>(
|
||||
let samples = {
|
||||
let mut samples_padded = samples.to_vec();
|
||||
let to_add = n_len * fft_step - samples.len();
|
||||
samples_padded.extend(std::iter::repeat(zero).take(to_add));
|
||||
samples_padded.extend(std::iter::repeat_n(zero, to_add));
|
||||
samples_padded
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user