(vec: &[f32; VECTOR_SIZE])
| 1 | use crate::constants::{QUANTIZED_VECTOR_SIZE, VECTOR_SIZE}; |
| 2 | |
| 3 | pub fn quantize(vec: &[f32; VECTOR_SIZE]) -> [u8; QUANTIZED_VECTOR_SIZE] { |
| 4 | let mut result = [0; QUANTIZED_VECTOR_SIZE]; |
| 5 | for i in 0..QUANTIZED_VECTOR_SIZE { |
| 6 | for j in 0..8 { |
| 7 | result[i] |= ((vec[i * 8 + j] >= 0.0) as u8) << j; |
| 8 | } |
| 9 | } |
| 10 | result |
| 11 | } |
| 12 | |
| 13 | pub fn dequantize(vec: &[u8; QUANTIZED_VECTOR_SIZE]) -> [f32; VECTOR_SIZE] { |
| 14 | let mut result = [0.0; VECTOR_SIZE]; |
no outgoing calls
no test coverage detected