MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / unpack_hot

Function unpack_hot

nodedb-codec/src/vector_quant/ternary/packing.rs:81–97  ·  view source on GitHub ↗

Unpack hot 2-bpw format back to `i8` trits.

(hot: &[u8], dim: usize)

Source from the content-addressed store, hash-verified

79
80/// Unpack hot 2-bpw format back to `i8` trits.
81pub fn unpack_hot(hot: &[u8], dim: usize) -> Vec<i8> {
82 let mut out = Vec::with_capacity(dim);
83 'outer: for &byte in hot {
84 for slot in 0..4 {
85 if out.len() >= dim {
86 break 'outer;
87 }
88 let bits = (byte >> (slot * 2)) & 0b11;
89 out.push(match bits {
90 0b00 => -1,
91 0b10 => 1,
92 _ => 0,
93 });
94 }
95 }
96 out
97}
98
99/// Convert cold-packed trits to hot-packed trits.
100pub fn cold_to_hot(cold: &[u8], dim: usize) -> Vec<u8> {

Callers 4

scaled_norm_sqFunction · 0.85
ternary_dot_scalarFunction · 0.85
ternary_dot_avx512Function · 0.85
ternary_dot_neonFunction · 0.85

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected