Pack `dim` signs from `rotated` (negative = 1-bit, non-negative = 0-bit) into ceil(dim/8) bytes, LSB-first.
(rotated: &[f32], dim: usize)
| 88 | /// Pack `dim` signs from `rotated` (negative = 1-bit, non-negative = 0-bit) |
| 89 | /// into ceil(dim/8) bytes, LSB-first. |
| 90 | fn sign_pack(rotated: &[f32], dim: usize) -> Vec<u8> { |
| 91 | let nbytes = dim.div_ceil(8); |
| 92 | let mut out = vec![0u8; nbytes]; |
| 93 | for (i, &v) in rotated.iter().take(dim).enumerate() { |
| 94 | if v < 0.0 { |
| 95 | out[i / 8] |= 1 << (i % 8); |
| 96 | } |
| 97 | } |
| 98 | out |
| 99 | } |
| 100 | |
| 101 | /// Dequantize sign-packed bits back to ±1 values (for dot_quantized calc). |
| 102 | fn sign_unpack(packed: &[u8], dim: usize) -> Vec<f32> { |
no test coverage detected