From 1ec3b2cc189fa6020018f2c8dad7b216b4512019 Mon Sep 17 00:00:00 2001 From: Lionel Touati Date: Sun, 2 Jun 2024 14:30:06 +0200 Subject: add where_cond f32 for metal (#2236) --- candle-metal-kernels/src/tests.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'candle-metal-kernels') diff --git a/candle-metal-kernels/src/tests.rs b/candle-metal-kernels/src/tests.rs index 960ae1df..8c38e74a 100644 --- a/candle-metal-kernels/src/tests.rs +++ b/candle-metal-kernels/src/tests.rs @@ -1023,6 +1023,27 @@ fn where_cond() { ); assert_eq!(approx(results, 4), vec![-1.0f32, 2.0, -3.0, -4.0, 5.0, 6.0]); } +#[test] +fn where_cond_u32_f32() { + let shape = vec![6]; + let cond = vec![0u32, 1, 0, 0, 1, 1]; + let cond_l = (vec![1], 0); + let left_true = vec![1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0]; + let left_l = (vec![1], 0); + let right_false = vec![-1.0f32, -2.0, -3.0, -4.0, -5.0, -6.0]; + let right_l = (vec![1], 0); + let results = run_where_cond( + &shape, + &cond, + cond_l, + &left_true, + left_l, + &right_false, + right_l, + "where_u32_f32", + ); + assert_eq!(approx(results, 4), vec![-1.0f32, 2.0, -3.0, -4.0, 5.0, 6.0]); +} fn run_gemm( (b, m, n, k): (usize, usize, usize, usize), -- cgit v1.2.3