Skip to content

Commit

Permalink
Fix wasm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Feb 24, 2025
1 parent 6148daf commit 919dddc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions candle-core/benches/benchmarks/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ fn run_reduce<T: candle_core::FloatDType>(
let k = 1024;

let a = if strided {
Tensor::rand(lo, up, (b, m, k), &device)
Tensor::rand(lo, up, (b, m, k), device)
.unwrap()
.transpose(0, 2)
.unwrap()
} else {
Tensor::rand(lo, up, (b, m, k), &device).unwrap()
Tensor::rand(lo, up, (b, m, k), device).unwrap()
};

let flops = b * m * k * T::DTYPE.size_in_bytes();
Expand Down Expand Up @@ -105,12 +105,12 @@ fn run_arg_reduce<T: candle_core::FloatDType>(
let k = 1024;

let a = if strided {
Tensor::rand(lo, up, (b, m, k), &device)
Tensor::rand(lo, up, (b, m, k), device)
.unwrap()
.transpose(0, 2)
.unwrap()
} else {
Tensor::rand(lo, up, (b, m, k), &device).unwrap()
Tensor::rand(lo, up, (b, m, k), device).unwrap()
};

let flops = b * m * k * T::DTYPE.size_in_bytes();
Expand Down
2 changes: 1 addition & 1 deletion candle-core/benches/benchmarks/where_cond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const M: usize = 1024;
const K: usize = 1024;
const SIZE: usize = B * M * K;

const DATA: [u8; SIZE] = create_cond_arr::<SIZE>();
static DATA: [u8; SIZE] = create_cond_arr::<SIZE>();

fn run_where_cond_benchmark(c: &mut Criterion, device: &Device, dtype: DType, name: &str) {
let tensor = Tensor::from_slice(DATA.as_slice(), (B, M, K), device).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions candle-core/src/quantized/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ pub(crate) fn vec_dot_iq4_xs_q8k(n: usize, xs: &[BlockIQ4xs], ys: &[BlockQ8K]) -
let prod2 =
vdotq_s32_local(vdotq_s32_local(vdupq_n_s32(0), q4b.2, q8b.2), q4b.3, q8b.3);

let ls1 = (x_block.scales_l[ib] & 0xf) as i32 | ((h << 4) & 0x30) as i32 - 32;
let ls2 = (x_block.scales_l[ib] >> 4) as i32 | ((h << 2) & 0x30) as i32 - 32;
let ls1 = (x_block.scales_l[ib] & 0xf) as i32 | (((h << 4) & 0x30) as i32 - 32);
let ls2 = (x_block.scales_l[ib] >> 4) as i32 | (((h << 2) & 0x30) as i32 - 32);
h >>= 4;

sumi1 += vaddvq_s32(prod1) * ls1;
Expand Down
4 changes: 2 additions & 2 deletions candle-nn/benches/benchmarks/softmax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use criterion::{black_box, criterion_group, Criterion};
use std::time::Instant;

fn run(input: &Tensor) {
let _ = softmax_last_dim(&input).unwrap();
let _ = softmax_last_dim(input).unwrap();
}

const B: usize = 1;
Expand All @@ -16,7 +16,7 @@ const K: usize = 1024;
fn run_softmax_benchmark(c: &mut Criterion, device: &Device, dtype: DType, name: &str) {
let elements = B * M * K;

let input = Tensor::rand(-1000.0f32, 1000.0f32, (B, M, K), &device)
let input = Tensor::rand(-1000.0f32, 1000.0f32, (B, M, K), device)
.unwrap()
.to_dtype(dtype)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions candle-wasm-tests/tests/quantized_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(unused)]
use candle::{
quantized::{self, k_quants, GgmlDType, GgmlType},
quantized::{self, k_quants, quants, GgmlDType, GgmlType},
test_utils::to_vec2_round,
Device, Module, Result, Tensor,
};
Expand All @@ -23,7 +23,7 @@ fn quantized_matmul_neg() -> Result<()> {
.collect::<Vec<_>>();
let tensor_rhs = Tensor::from_slice(&rhs, (n, k), cpu)?.t()?;
k_quants::BlockQ4_0::from_float(&rhs, &mut rhs_t)?;
k_quants::matmul((m, k, n), &lhs, &rhs_t, &mut dst)?;
quants::matmul((m, k, n), &lhs, &rhs_t, &mut dst)?;
assert_eq!(
dst.iter().map(|x| x.round()).collect::<Vec<_>>(),
&[
Expand Down

0 comments on commit 919dddc

Please sign in to comment.