ci/Fix `cargo clippy` action (#942)

This commit is contained in:
Luni-4 2023-11-17 01:35:38 +01:00 committed by GitHub
parent 945014b7f1
commit ec9df53d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 7 deletions

View File

@ -89,7 +89,10 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Run clippy for each workspace, targets, and featrues, considering
# warnings as errors
clippy_flags: --workspace --all-targets --all-features -- -D warnings
clippy_flags: --all-targets -- -Dwarnings
# Do not filter results
filter_mode: nofilter
# Report clippy annotations as snippets
reporter: github-pr-check
- name: Install grcov

View File

@ -52,9 +52,7 @@ where
Erf: Fn(Tensor<B, D>) -> Tensor<B, D>,
{
let x = x.clone() * (erf(x / SQRT_2) + 1);
let result = x / 2;
result
x / 2
}
fn erf_custom<B: Backend, const D: usize>(x: Tensor<B, D>) -> Tensor<B, D> {
@ -81,7 +79,7 @@ fn erf_positive<B: Backend, const D: usize>(x: Tensor<B, D>) -> Tensor<B, D> {
let t = x1.recip();
let tmp = (((((t.clone() * a5) + a4) * t.clone()) + a3) * t.clone() + a2) * t.clone() + a1;
return -(tmp * t * (-x.clone() * x).exp()) + 1.0;
-(tmp * t * (-x.clone() * x).exp()) + 1.0
}
#[allow(dead_code)]

View File

@ -551,8 +551,11 @@ mod tests {
fn linear() {
// Initialize the model with weights (loaded from the exported file)
let model: linear::Model<Backend> = linear::Model::default();
#[allow(clippy::approx_constant)]
let input1 = Tensor::<Backend, 2>::full([4, 3], 3.14);
#[allow(clippy::approx_constant)]
let input2 = Tensor::<Backend, 2>::full([2, 5], 3.14);
#[allow(clippy::approx_constant)]
let input3 = Tensor::<Backend, 3>::full([3, 2, 7], 3.14);
let (output1, output2, output3) = model.forward(input1, input2, input3);

View File

@ -131,6 +131,7 @@ mod tests {
let data = Data::from([0.0, 1.0, 2.0]);
let tensor = Tensor::<TestBackend, 1>::from_data(data.clone());
#[allow(clippy::reversed_empty_ranges)]
let data_actual = tensor.slice([2..1]).into_data();
assert_eq!(data, data_actual);

View File

@ -36,7 +36,7 @@ fn main() {
fn generate_labels_from_txt_file() -> std::io::Result<()> {
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join(LABEL_DEST_FILE);
let mut f = File::create(&dest_path)?;
let mut f = File::create(dest_path)?;
let file = File::open(LABEL_SOURCE_FILE)?;
let reader = BufReader::new(file);

View File

@ -120,7 +120,7 @@ fn cargo_clippy() {
// Run cargo clippy
run_cargo(
"clippy",
["--color=always", "--", "-D", "warnings"].into(),
["--color=always", "--all-targets", "--", "-D", "warnings"].into(),
"Failed to run cargo clippy",
);
}