From 4258502a78404de87a7381bbd6be212174131cdd Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Thu, 28 Nov 2024 11:04:26 -0500 Subject: [PATCH] Update for rust 1.83 (#2562) * Fix issues with rust 1.83 * Set MSRV to 1.82 --- .github/workflows/test.yml | 2 +- backend-comparison/src/burnbenchapp/base.rs | 8 ++++---- crates/burn-core/src/module/param/visitor.rs | 2 +- crates/burn-core/src/optim/grad_accum.rs | 4 +--- crates/burn-core/src/optim/simple/adaptor.rs | 2 +- crates/burn-core/src/optim/visitor.rs | 4 ++-- crates/burn-dataset/src/dataset/iterator.rs | 2 +- crates/burn-dataset/src/transform/window.rs | 4 ++-- crates/burn-fusion/src/stream/execution/validator.rs | 4 ++-- crates/burn-fusion/src/stream/multi.rs | 2 +- crates/burn-import/src/burn/graph.rs | 4 ++-- crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d.rs | 1 + .../src/kernel/pool/adaptive_avg_pool2d_backward.rs | 1 + crates/burn-ndarray/src/sharing.rs | 2 +- crates/burn-tensor/src/tensor/distribution.rs | 2 +- crates/burn-tensor/src/tensor/ops/bool_tensor.rs | 2 -- crates/burn-tensor/src/tensor/report.rs | 1 - crates/burn-train/src/renderer/tui/base.rs | 2 +- crates/burn-train/src/renderer/tui/metric_numeric.rs | 2 +- crates/burn/Cargo.toml | 2 +- 20 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9192c6e254..2721233595 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ env: # Note: It is not possible to define env vars in composite actions. # To work around this issue we use inputs and define all the env vars here. - RUST_PREVIOUS_VERSION: 1.81.0 + RUST_PREVIOUS_VERSION: 1.82.0 # Cargo CARGO_TERM_COLOR: "always" diff --git a/backend-comparison/src/burnbenchapp/base.rs b/backend-comparison/src/burnbenchapp/base.rs index 87b7265128..0424e00c4e 100644 --- a/backend-comparison/src/burnbenchapp/base.rs +++ b/backend-comparison/src/burnbenchapp/base.rs @@ -231,16 +231,16 @@ fn run_backend_comparison_benchmarks( } fn run_cargo( - bench: &String, - backend: &String, + bench: &str, + backend: &str, url: &str, token: Option<&str>, progress_bar: &Option>>, ) -> io::Result { let processor: Arc = if let Some(pb) = progress_bar { Arc::new(NiceProcessor::new( - bench.clone(), - backend.clone(), + bench.to_string(), + backend.to_string(), pb.clone(), )) } else { diff --git a/crates/burn-core/src/module/param/visitor.rs b/crates/burn-core/src/module/param/visitor.rs index cc8c922912..10ed3d6a8c 100644 --- a/crates/burn-core/src/module/param/visitor.rs +++ b/crates/burn-core/src/module/param/visitor.rs @@ -9,7 +9,7 @@ struct ParamIdCollector<'a, M> { phantom: PhantomData, } -impl<'a, B, M> ModuleVisitor for ParamIdCollector<'a, M> +impl ModuleVisitor for ParamIdCollector<'_, M> where B: Backend, M: Module, diff --git a/crates/burn-core/src/optim/grad_accum.rs b/crates/burn-core/src/optim/grad_accum.rs index 598f655738..cab24ff0ac 100644 --- a/crates/burn-core/src/optim/grad_accum.rs +++ b/crates/burn-core/src/optim/grad_accum.rs @@ -54,9 +54,7 @@ struct ModuleGradsAccumulator<'a, M> { phantom: PhantomData, } -impl<'a, B: AutodiffBackend, M: AutodiffModule> ModuleVisitor - for ModuleGradsAccumulator<'a, M> -{ +impl> ModuleVisitor for ModuleGradsAccumulator<'_, M> { fn visit_float(&mut self, id: ParamId, _tensor: &Tensor) { let grad_updated = match self.grads_new.remove::(id) { Some(new) => match self.grads.remove::(id) { diff --git a/crates/burn-core/src/optim/simple/adaptor.rs b/crates/burn-core/src/optim/simple/adaptor.rs index fa4f18a9df..c41ea12ca3 100644 --- a/crates/burn-core/src/optim/simple/adaptor.rs +++ b/crates/burn-core/src/optim/simple/adaptor.rs @@ -110,7 +110,7 @@ where grad_clipping: Option<&'a GradientClipping>, } -impl<'a, M, B, O> ModuleMapper for SimpleOptimizerMapper<'a, M, B, O> +impl ModuleMapper for SimpleOptimizerMapper<'_, M, B, O> where M: AutodiffModule, B: AutodiffBackend, diff --git a/crates/burn-core/src/optim/visitor.rs b/crates/burn-core/src/optim/visitor.rs index 532ee68103..7163fdddb0 100644 --- a/crates/burn-core/src/optim/visitor.rs +++ b/crates/burn-core/src/optim/visitor.rs @@ -18,7 +18,7 @@ pub struct GradientsParamsChangeDevice<'a, M: AutodiffModule, B: AutodiffBack phatom: PhantomData, } -impl<'a, B, M> ModuleVisitor for GradientsParamsConverter<'a, M, B> +impl ModuleVisitor for GradientsParamsConverter<'_, M, B> where B: AutodiffBackend, M: AutodiffModule, @@ -37,7 +37,7 @@ where } } -impl<'a, B, M> ModuleVisitor for GradientsParamsChangeDevice<'a, M, B> +impl ModuleVisitor for GradientsParamsChangeDevice<'_, M, B> where B: AutodiffBackend, M: AutodiffModule, diff --git a/crates/burn-dataset/src/dataset/iterator.rs b/crates/burn-dataset/src/dataset/iterator.rs index e513e1a08c..cbea4767f7 100644 --- a/crates/burn-dataset/src/dataset/iterator.rs +++ b/crates/burn-dataset/src/dataset/iterator.rs @@ -20,7 +20,7 @@ impl<'a, I> DatasetIterator<'a, I> { } } -impl<'a, I> Iterator for DatasetIterator<'a, I> { +impl Iterator for DatasetIterator<'_, I> { type Item = I; fn next(&mut self) -> Option { diff --git a/crates/burn-dataset/src/transform/window.rs b/crates/burn-dataset/src/transform/window.rs index 058f03125b..67e6684979 100644 --- a/crates/burn-dataset/src/transform/window.rs +++ b/crates/burn-dataset/src/transform/window.rs @@ -79,7 +79,7 @@ impl<'a, I> WindowsIterator<'a, I> { } } -impl<'a, I> Iterator for WindowsIterator<'a, I> { +impl Iterator for WindowsIterator<'_, I> { type Item = Vec; fn next(&mut self) -> Option> { @@ -88,7 +88,7 @@ impl<'a, I> Iterator for WindowsIterator<'a, I> { } } -impl<'a, I> Clone for WindowsIterator<'a, I> { +impl Clone for WindowsIterator<'_, I> { fn clone(&self) -> Self { WindowsIterator { size: self.size, diff --git a/crates/burn-fusion/src/stream/execution/validator.rs b/crates/burn-fusion/src/stream/execution/validator.rs index 5cc68a25c0..bc9f016f70 100644 --- a/crates/burn-fusion/src/stream/execution/validator.rs +++ b/crates/burn-fusion/src/stream/execution/validator.rs @@ -112,7 +112,7 @@ pub(crate) enum TriggerProgress { /// trigger. pub(crate) type TriggerId = usize; -impl<'b, O> OperationsStore for TriggerOperationsStore<'b, O> { +impl OperationsStore for TriggerOperationsStore<'_, O> { type Id = TriggerId; fn get(&self, id: Self::Id) -> &[OperationDescription] { @@ -131,7 +131,7 @@ pub(crate) struct ExecutionPlanOperationsStore<'a, O> { store: &'a ExecutionPlanStore, } -impl<'b, O> OperationsStore for ExecutionPlanOperationsStore<'b, O> { +impl OperationsStore for ExecutionPlanOperationsStore<'_, O> { type Id = ExecutionPlanId; fn get(&self, id: Self::Id) -> &[OperationDescription] { diff --git a/crates/burn-fusion/src/stream/multi.rs b/crates/burn-fusion/src/stream/multi.rs index ca49630006..e3f7e9ac79 100644 --- a/crates/burn-fusion/src/stream/multi.rs +++ b/crates/burn-fusion/src/stream/multi.rs @@ -153,7 +153,7 @@ struct Segment<'a, R: FusionRuntime> { handles: &'a mut HandleContainer, } -impl<'i, R: FusionRuntime> StreamSegment for Segment<'i, R> { +impl StreamSegment for Segment<'_, R> { fn operations(&self) -> &[OperationDescription] { &self.queue.relative } diff --git a/crates/burn-import/src/burn/graph.rs b/crates/burn-import/src/burn/graph.rs index ac0d33ed5a..f6dee5479d 100644 --- a/crates/burn-import/src/burn/graph.rs +++ b/crates/burn-import/src/burn/graph.rs @@ -589,7 +589,7 @@ struct BurnGraphState<'a, PS: PrecisionSettings> { /// Instead, they use the `StructTuple` serialization strategy (to avoid memory overhead presumably). struct StructMap<'a, PS: PrecisionSettings>(BurnGraphState<'a, PS>); -impl<'a, PS: PrecisionSettings> Serialize for StructMap<'a, PS> { +impl Serialize for StructMap<'_, PS> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -623,7 +623,7 @@ impl<'a, PS: PrecisionSettings> Serialize for StructMap<'a, PS> { /// serializing tuples. Instead, they use the `StructMap` serialization strategy. struct StructTuple<'a, PS: PrecisionSettings>(BurnGraphState<'a, PS>); -impl<'a, PS: PrecisionSettings> Serialize for StructTuple<'a, PS> { +impl Serialize for StructTuple<'_, PS> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, diff --git a/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d.rs b/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d.rs index a41e9b7fd1..e93d6f6b2b 100644 --- a/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d.rs +++ b/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d.rs @@ -62,6 +62,7 @@ fn start_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 (output_size_index * input_size) / output_size } +#[allow(clippy::manual_div_ceil)] #[cube] fn end_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 { let index = (output_size_index + 1) * input_size; diff --git a/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d_backward.rs b/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d_backward.rs index a22bf4b68a..11b6796f88 100644 --- a/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d_backward.rs +++ b/crates/burn-jit/src/kernel/pool/adaptive_avg_pool2d_backward.rs @@ -66,6 +66,7 @@ fn start_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 (output_size_index * input_size) / output_size } +#[allow(clippy::manual_div_ceil)] #[cube] fn end_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 { let index = (output_size_index + 1) * input_size; diff --git a/crates/burn-ndarray/src/sharing.rs b/crates/burn-ndarray/src/sharing.rs index 073f3d3872..75d51421f2 100644 --- a/crates/burn-ndarray/src/sharing.rs +++ b/crates/burn-ndarray/src/sharing.rs @@ -5,7 +5,7 @@ pub(crate) struct UnsafeSharedRef<'a, T> { cell: UnsafeCell<&'a mut T>, } -unsafe impl<'a, T> Sync for UnsafeSharedRef<'a, T> {} +unsafe impl Sync for UnsafeSharedRef<'_, T> {} impl<'a, T> UnsafeSharedRef<'a, T> { pub fn new(data: &'a mut T) -> Self { diff --git a/crates/burn-tensor/src/tensor/distribution.rs b/crates/burn-tensor/src/tensor/distribution.rs index b503362b88..0fddd40272 100644 --- a/crates/burn-tensor/src/tensor/distribution.rs +++ b/crates/burn-tensor/src/tensor/distribution.rs @@ -49,7 +49,7 @@ where Normal(rand_distr::Normal), } -impl<'a, E, R> DistributionSampler<'a, E, R> +impl DistributionSampler<'_, E, R> where Standard: rand::distributions::Distribution, E: rand::distributions::uniform::SampleUniform, diff --git a/crates/burn-tensor/src/tensor/ops/bool_tensor.rs b/crates/burn-tensor/src/tensor/ops/bool_tensor.rs index c0ea76efa4..ffb74156f9 100644 --- a/crates/burn-tensor/src/tensor/ops/bool_tensor.rs +++ b/crates/burn-tensor/src/tensor/ops/bool_tensor.rs @@ -339,7 +339,6 @@ pub trait BoolTensorOps { /// A boolean tensor `Tensor` with the same size as input `tensor`, except in the `dim` axis /// where the size is 1. The elem in the `dim` axis is True if any element along this dim in the input /// evaluates to True, False otherwise. - fn bool_any_dim(tensor: BoolTensor, dim: usize) -> BoolTensor { let sum = B::int_sum_dim(B::bool_into_int(tensor), dim); B::int_greater_elem(sum, 0.elem()) @@ -373,7 +372,6 @@ pub trait BoolTensorOps { /// A boolean tensor `Tensor` with the same size as input `tensor`, except in the `dim` axis /// where the size is 1. The elem in the `dim` axis is True if all elements along this dim in the input /// evaluates to True, False otherwise. - fn bool_all_dim(tensor: BoolTensor, dim: usize) -> BoolTensor { let num_elems = tensor.shape().dims[dim]; let sum = B::int_sum_dim(B::bool_into_int(tensor), dim); diff --git a/crates/burn-tensor/src/tensor/report.rs b/crates/burn-tensor/src/tensor/report.rs index af253cae25..0a457ae2d9 100644 --- a/crates/burn-tensor/src/tensor/report.rs +++ b/crates/burn-tensor/src/tensor/report.rs @@ -71,7 +71,6 @@ use colored::*; /// /// Closeness check complete. /// ``` - pub fn check_closeness(output: &Tensor, expected: &Tensor) { println!("{}", "Tensor Closeness Check Results:".bold()); println!("==============================="); diff --git a/crates/burn-train/src/renderer/tui/base.rs b/crates/burn-train/src/renderer/tui/base.rs index 38d6c25b31..dbb9b7f510 100644 --- a/crates/burn-train/src/renderer/tui/base.rs +++ b/crates/burn-train/src/renderer/tui/base.rs @@ -12,7 +12,7 @@ pub(crate) struct MetricsView<'a> { status: StatusView, } -impl<'a> MetricsView<'a> { +impl MetricsView<'_> { pub(crate) fn render(self, frame: &mut TerminalFrame<'_>, size: Rect) { let chunks = Layout::default() .direction(Direction::Vertical) diff --git a/crates/burn-train/src/renderer/tui/metric_numeric.rs b/crates/burn-train/src/renderer/tui/metric_numeric.rs index f05dd6af19..70e3871b89 100644 --- a/crates/burn-train/src/renderer/tui/metric_numeric.rs +++ b/crates/burn-train/src/renderer/tui/metric_numeric.rs @@ -182,7 +182,7 @@ pub(crate) enum NumericMetricView<'a> { None, } -impl<'a> NumericMetricView<'a> { +impl NumericMetricView<'_> { pub(crate) fn render(self, frame: &mut TerminalFrame<'_>, size: Rect) { match self { Self::Plots(titles, selected, chart, kind) => { diff --git a/crates/burn/Cargo.toml b/crates/burn/Cargo.toml index adfb90786a..d6287382d9 100644 --- a/crates/burn/Cargo.toml +++ b/crates/burn/Cargo.toml @@ -9,7 +9,7 @@ license.workspace = true name = "burn" readme.workspace = true repository = "https://github.com/tracel-ai/burn" -rust-version = "1.81" +rust-version = "1.82" version.workspace = true [features]