Engineering Category: Balanced Ternary & b158 Quantization
Best Use in Production: Packing and unpacking balanced ternary (-1, 0, +1) activation lanes into dense 64-bit registers for C64-constrained inference pipelines.
When to Select This Capsule: Sole canonical implementation for its 64-vector functional equivalence class. Sub-10-cycle hardware kernel (2887733/400000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.
Snap-Circuit Wiring Role: Specialized Multi-Pin Stage `(i8,i8,i8,i8,i8)->u8` — wire matching input pins via `snap_dag` or `snap_pipeline`.
.text: 69 B (17 x86_64 insns)325 B)pub fn pack5_trits_u8(t0: i8, t1: i8, t2: i8, t3: i8, t4: i8) -> u8 {
let mut byte: u16 = 0;
byte += ((t0 as i16 + 1) as u16) * 1;
byte += ((t1 as i16 + 1) as u16) * 3;
byte += ((t2 as i16 + 1) as u16) * 9;
byte += ((t3 as i16 + 1) as u16) * 27;
byte += ((t4 as i16 + 1) as u16) * 81;
byte as u8
}
rustc -C opt-level=3 x86_64 Disassembly (69 B .text / 17 insns)pack5_trits_u8:
movzx eax, sil
movzx edx, dl
shl edx, 16
or edx, eax
movd xmm0, edx
pinsrw xmm0, ecx, 2
pinsrw xmm0, r8d, 3
pmullw xmm0, xmmword ptr [rip + .LCPI7_0]
pand xmm0, xmmword ptr [rip + .LCPI7_1]
packuswb xmm0, xmm0
pxor xmm1, xmm1
punpckldq xmm0, xmm1
psadbw xmm0, xmm1
movd eax, xmm0
add al, dil
add al, 121
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #67 | pack5_trits_u8 (THIS CAPSULE) domain: zerocpu | id: 13ddc68f8edc93e28ac25d96efb8b7fe | 2887733/400000 cyc/op | 902541/400000 ns/op | 400000000/902541 ops/us | 69 B .text (17 insns) | + (1) | aye::Peter+Omni(0+1)::aarch64 @ 432Hz |