Skip to content

Commit 3934653

Browse files
Merge pull request #954 from LaurentMazare/clippy-1.87
Fixes for clippy 1.87.
2 parents d96bb45 + b553118 commit 3934653

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

examples/stable-diffusion/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ impl DDIMScheduler {
24232423

24242424
// https://github.com/huggingface/diffusers/blob/6e099e2c8ce4c4f5c7318e970a8c093dc5c7046e/src/diffusers/schedulers/scheduling_ddim.py#L195
24252425
fn step(&self, model_output: &Tensor, timestep: usize, sample: &Tensor) -> Tensor {
2426-
let prev_timestep = if timestep > self.step_ratio { timestep - self.step_ratio } else { 0 };
2426+
let prev_timestep = timestep.saturating_sub(self.step_ratio);
24272427

24282428
let alpha_prod_t = self.alphas_cumprod[timestep];
24292429
let alpha_prod_t_prev = self.alphas_cumprod[prev_timestep];

src/vision/mnist.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ fn read_u32<T: Read>(reader: &mut T) -> Result<u32> {
1818
fn check_magic_number<T: Read>(reader: &mut T, expected: u32) -> Result<()> {
1919
let magic_number = read_u32(reader)?;
2020
if magic_number != expected {
21-
return Err(io::Error::new(
22-
io::ErrorKind::Other,
23-
format!("incorrect magic number {magic_number} != {expected}"),
24-
));
21+
return Err(io::Error::other(format!(
22+
"incorrect magic number {magic_number} != {expected}"
23+
)));
2524
}
2625
Ok(())
2726
}

src/wrappers/utils.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ pub(super) fn path_to_cstring<T: AsRef<std::path::Path>>(
4848
let path = path.as_ref();
4949
match path.to_str() {
5050
Some(path) => Ok(std::ffi::CString::new(path)?),
51-
None => Err(TchError::Io(io::Error::new(
52-
io::ErrorKind::Other,
53-
format!("path {path:?} cannot be converted to UTF-8"),
54-
))),
51+
None => Err(TchError::Io(io::Error::other(format!(
52+
"path {path:?} cannot be converted to UTF-8"
53+
)))),
5554
}
5655
}
5756

0 commit comments

Comments
 (0)