Skip to content

[WIP] Run clippy fix on clippy::pedantic errors #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ license = "MIT OR Apache-2.0"
readme = "README.md"
version = "0.18.0"

[workspace.lints.clippy]
suspicious = "deny"
perf = "deny"
# pedantic = "deny"

[workspace.dependencies]
atomic_float = "1"
bytemuck = "1.21.0"
Expand Down Expand Up @@ -156,9 +161,9 @@ portable-atomic = { version = "1.11.0" }
portable-atomic-util = { version = "0.2.4", features = ["alloc"] }

### For the main burn branch. ###
cubecl = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "cfcbc082c8fbe4285e8d01d587132ff6720295fa" }
cubecl-common = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "cfcbc082c8fbe4285e8d01d587132ff6720295fa" }
cubecl-std = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "cfcbc082c8fbe4285e8d01d587132ff6720295fa" }
cubecl = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "6ebfb95975cf10979f163ab04b1c86b75fbd9a4d" }
cubecl-common = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "6ebfb95975cf10979f163ab04b1c86b75fbd9a4d" }
cubecl-std = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "6ebfb95975cf10979f163ab04b1c86b75fbd9a4d" }
### For local development. ###
# cubecl = { path = "../cubecl/crates/cubecl", default-features = false }
# cubecl-common = { path = "../cubecl/crates/cubecl-common", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions crates/burn-autodiff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ repository = "https://github.com/tracel-ai/burn/tree/main/crates/burn-autodiff"
documentation = "https://docs.rs/burn-autodiff"
version.workspace = true

[lints]
workspace = true

[features]
default = ["std"]
export_tests = ["burn-tensor-testgen"]
Expand Down
3 changes: 3 additions & 0 deletions crates/burn-candle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ repository = "https://github.com/tracel-ai/burn/tree/main/crates/burn-candle"
documentation = "https://docs.rs/burn-candle"
version.workspace = true

[lints]
workspace = true

[features]
default = ["std"]
std = []
Expand Down
2 changes: 2 additions & 0 deletions crates/burn-candle/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub enum CandleDevice {
impl CandleDevice {
/// Create a Cuda device with the given index.
/// The index is the index of the Cuda device in the list of all Cuda devices found on the system.
#[must_use]
pub fn cuda(index: usize) -> Self {
CandleDevice::Cuda(CudaDevice {
device: candle_core::CudaDevice::new(index).unwrap(),
Expand All @@ -64,6 +65,7 @@ impl CandleDevice {

/// Create a Metal device with the given index.
/// The index is the index of the Metal device in the list of all Metal devices found on the system.
#[must_use]
pub fn metal(index: usize) -> Self {
CandleDevice::Metal(MetalDevice {
device: candle_core::MetalDevice::new(index).unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion crates/burn-candle/src/ops/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn slice(tensor: CandleTensor, ranges: &[std::ops::Range<usize>]) -> CandleT
for (i, range) in ranges.iter().enumerate().take(ranges.len()) {
narrow_tensor = narrow_tensor
.narrow(i, range.start, range.end - range.start)
.unwrap()
.unwrap();
}
CandleTensor::new(narrow_tensor)
}
Expand Down
12 changes: 6 additions & 6 deletions crates/burn-candle/src/ops/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ impl<F: FloatCandleElement, I: IntCandleElement> FloatTensorOps<Self> for Candle
}

fn float_matmul(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> {
let lhs_contiguous = if !lhs.tensor.is_contiguous() {
lhs.tensor.contiguous().unwrap()
} else {
let lhs_contiguous = if lhs.tensor.is_contiguous() {
lhs.tensor
};
let rhs_contiguous = if !rhs.tensor.is_contiguous() {
rhs.tensor.contiguous().unwrap()
} else {
lhs.tensor.contiguous().unwrap()
};
let rhs_contiguous = if rhs.tensor.is_contiguous() {
rhs.tensor
} else {
rhs.tensor.contiguous().unwrap()
};
CandleTensor::new(lhs_contiguous.broadcast_matmul(&rhs_contiguous).unwrap())
}
Expand Down
2 changes: 2 additions & 0 deletions crates/burn-candle/src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl TensorMetadata for CandleTensor {

impl CandleTensor {
/// Create a new tensor.
#[must_use]
pub fn new(tensor: candle_core::Tensor) -> Self {
Self { tensor }
}
Expand All @@ -45,6 +46,7 @@ impl CandleTensor {
/// # Returns
///
/// A new tensor.
#[must_use]
pub fn from_data<E: CandleElement>(data: TensorData, device: CandleDevice) -> Self {
let candle_shape: candle_core::Shape = data.shape.clone().into();
let tensor = candle_core::Tensor::from_slice(
Expand Down
3 changes: 3 additions & 0 deletions crates/burn-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ repository = "https://github.com/tracel-ai/burn/tree/main/crates/burn-common"
documentation = "https://docs.rs/burn-common"
version.workspace = true

[lints]
workspace = true

[features]
default = ["std", "cubecl-common/default"]
std = ["cubecl-common/std"]
Expand Down
1 change: 1 addition & 0 deletions crates/burn-common/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub struct IdGenerator {}

impl IdGenerator {
/// Generates a new ID.
#[must_use]
pub fn generate() -> u64 {
// Generate a random u64 (18,446,744,073,709,551,615 combinations)
let random_bytes: [u8; 8] = gen_random();
Expand Down
2 changes: 2 additions & 0 deletions crates/burn-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub mod tensor {
/// of all dimensions greater than `k`.
///
/// This means that strides increase as you move from the rightmost to the leftmost dimension.
#[must_use]
pub fn is_contiguous(shape: &[usize], strides: &[usize]) -> bool {
if shape.is_empty() {
return true;
Expand All @@ -52,6 +53,7 @@ pub mod tensor {
///
/// In a contiguous row-major tensor, the stride for each dimension
/// equals the product of all dimension sizes to its right.
#[must_use]
pub fn contiguous_strides(shape: &[usize]) -> Vec<usize> {
let mut strides = Vec::with_capacity(shape.len());
let mut current = 1;
Expand Down
3 changes: 2 additions & 1 deletion crates/burn-common/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod downloader {
/// A vector of bytes containing the downloaded file data.
#[cfg(feature = "std")]
#[tokio::main(flavor = "current_thread")]
#[must_use]
pub async fn download_file_as_bytes(url: &str, message: &str) -> Vec<u8> {
// Get file from web
let mut response = Client::new().get(url).send().await.unwrap();
Expand All @@ -34,7 +35,7 @@ pub mod downloader {
.with_key(
"eta",
|state: &ProgressState, w: &mut dyn std::fmt::Write| {
write!(w, "{:.1}s", state.eta().as_secs_f64()).unwrap()
write!(w, "{:.1}s", state.eta().as_secs_f64()).unwrap();
},
)
.progress_chars("▬ "),
Expand Down
3 changes: 3 additions & 0 deletions crates/burn-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ readme.workspace = true
repository = "https://github.com/tracel-ai/burn/tree/main/crates/burn-core"
version.workspace = true

[lints]
workspace = true

[features]
dataset = ["burn-dataset"]
default = [
Expand Down
3 changes: 3 additions & 0 deletions crates/burn-cubecl-fusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ readme.workspace = true
repository = "https://github.com/tracel-ai/burn/tree/main/crates/burn-cubecl-fusion"
version.workspace = true

[lints]
workspace = true

[features]
default = ["autotune", "std", "cubecl/default"]
autotune = []
Expand Down
2 changes: 1 addition & 1 deletion crates/burn-cubecl-fusion/src/elemwise/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<R: Runtime> OptimizationBuilder<CubeOptimization<R>> for ElementWiseBuilder
}

fn reset(&mut self) {
self.builder.reset()
self.builder.reset();
}

fn status(&self) -> burn_fusion::OptimizationStatus {
Expand Down
2 changes: 1 addition & 1 deletion crates/burn-cubecl-fusion/src/elemwise/optimization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ fn elemwise_fuse(
let length = ref_len(inputs, outputs, &locals, config);

if pos < length {
fuse_on_write::<f32>(inputs, outputs, &mut locals, pos, values, args, config)
fuse_on_write::<f32>(inputs, outputs, &mut locals, pos, values, args, config);
}
}
18 changes: 10 additions & 8 deletions crates/burn-cubecl-fusion/src/matmul/optimization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,15 @@ impl FusedMatmul {
lhs_shape[..lhs_shape.len() - 2].to_vec(),
rhs_shape[..rhs_shape.len() - 2].to_vec(),
),
lhs_layout: match lhs_transposed {
true => components::MatrixLayout::ColMajor,
false => components::MatrixLayout::RowMajor,
lhs_layout: if lhs_transposed {
components::MatrixLayout::ColMajor
} else {
components::MatrixLayout::RowMajor
},
rhs_layout: match rhs_transposed {
true => components::MatrixLayout::ColMajor,
false => components::MatrixLayout::RowMajor,
rhs_layout: if rhs_transposed {
components::MatrixLayout::ColMajor
} else {
components::MatrixLayout::RowMajor
},
lhs_line_size,
rhs_line_size,
Expand Down Expand Up @@ -353,7 +355,7 @@ impl FusedMatmul {
problem,
plane_size,
) {
Ok(_) => Ok(()),
Ok(()) => Ok(()),
Err(err) => Err(FusedMatmulError::LaunchError(err)),
}
}
Expand All @@ -365,7 +367,7 @@ impl FusedMatmul {
problem,
plane_size,
) {
Ok(_) => Ok(()),
Ok(()) => Ok(()),
Err(err) => Err(FusedMatmulError::LaunchError(err)),
}
}
Expand Down
Loading
Loading