From 4bf2ebf836523a4ebf97494f387f064b204db717 Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Sat, 29 Jul 2023 11:32:58 +0100 Subject: Use u8 tensors for masks. (#273) --- candle-wasm-examples/llama2-c/src/model.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'candle-wasm-examples/llama2-c') diff --git a/candle-wasm-examples/llama2-c/src/model.rs b/candle-wasm-examples/llama2-c/src/model.rs index d95672b9..8cf53c2a 100644 --- a/candle-wasm-examples/llama2-c/src/model.rs +++ b/candle-wasm-examples/llama2-c/src/model.rs @@ -47,9 +47,8 @@ impl Cache { if let Some(mask) = masks.get(&t) { Ok(mask.clone()) } else { - // TODO: If we support bool or u8 tensors, this would be better. let mask: Vec<_> = (0..t) - .flat_map(|i| (0..t).map(move |j| u32::from(j > i))) + .flat_map(|i| (0..t).map(move |j| u8::from(j > i))) .collect(); let mask = Tensor::from_slice(&mask, (t, t), &self.device)?; masks.insert(t, mask.clone()); -- cgit v1.2.3