Skip to content

Commit 8823085

Browse files
committed
more clppy
1 parent 11b83ec commit 8823085

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

candle-core/tests/quantized_tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use candle_core::{
66
DType, Device, IndexOp, Module, Result, Tensor, Var,
77
};
88
use quantized::{k_quants, GgmlType};
9-
use rand::prelude::*;
9+
use rand::{prelude::*, random};
1010

1111
const GGML_TEST_SIZE: usize = 32 * 128;
1212

@@ -1110,13 +1110,11 @@ fn get_random_tensors(
11101110
n: usize,
11111111
device: &Device,
11121112
) -> Result<(Tensor, Tensor, Tensor)> {
1113-
let mut rng = StdRng::seed_from_u64(314159265358979);
1114-
11151113
let lhs = (0..m * k)
1116-
.map(|_| rng.gen::<f32>() - 0.5)
1114+
.map(|_| random::<f32>() - 0.5)
11171115
.collect::<Vec<_>>();
11181116
let rhs = (0..n * k)
1119-
.map(|_| rng.gen::<f32>() - 0.5)
1117+
.map(|_| random::<f32>() - 0.5)
11201118
.collect::<Vec<_>>();
11211119

11221120
let lhs = Tensor::from_vec(lhs, (m, k), device)?;

candle-nn/src/loss.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use candle::{Result, Tensor};
77
/// Arguments
88
///
99
/// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number
10-
/// of categories. This is expected to contain log probabilities.
10+
/// of categories. This is expected to contain log probabilities.
1111
/// * [target]: The ground truth labels as a tensor of u32 of dimension `N`.
1212
///
1313
/// The resulting tensor is a scalar containing the average value over the batch.
@@ -34,7 +34,7 @@ pub fn nll(inp: &Tensor, target: &Tensor) -> Result<Tensor> {
3434
/// Arguments
3535
///
3636
/// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number
37-
/// of categories. This is expected to raw logits.
37+
/// of categories. This is expected to raw logits.
3838
/// * [target]: The ground truth labels as a tensor of u32 of dimension `N`.
3939
///
4040
/// The resulting tensor is a scalar containing the average value over the batch.
@@ -56,9 +56,9 @@ pub fn mse(inp: &Tensor, target: &Tensor) -> Result<Tensor> {
5656
/// Arguments
5757
///
5858
/// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number
59-
/// of categories. This is expected to raw logits.
59+
/// of categories. This is expected to raw logits.
6060
/// * [target]: The ground truth labels as a tensor of u32 of dimension `N, C` where `N` is the batch size and `C` the number
61-
/// of categories.
61+
/// of categories.
6262
///
6363
/// The resulting tensor is a scalar containing the average value over the batch.
6464
pub fn binary_cross_entropy_with_logit(inp: &Tensor, target: &Tensor) -> Result<Tensor> {

0 commit comments

Comments
 (0)