deeprcurs-staff commited on
Commit
5dcfe5d
·
verified ·
1 Parent(s): b6b576f

Upload kernels/satu1_common.h with huggingface_hub

Browse files
Files changed (1) hide show
  1. kernels/satu1_common.h +41 -0
kernels/satu1_common.h ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // satu1_common.h — IKNN-Rl1-A.1 — Common types for SatU1
2
+ // Version: v1.0
3
+ // Created: 2026-09-03T16:55:00+07:00
4
+ // Last Updated: 2026-09-03T16:55:00+07:00
5
+ // Status: PUBLISHABLE — EN ONLY
6
+ // Repo: IKNN-Rl1-A.1 — Integrated Knowledge-phase Neural Network — Recursive Language Iteration 1 — Architecture 1
7
+ // Hardware: AVX2 (Ryzen5 5650U) + AVX-512 (Xeon with VPOPCNTDQ, VBMI2)
8
+
9
+ #pragma once
10
+ #include <cstdint>
11
+ #include <immintrin.h>
12
+
13
+ namespace iknn {
14
+ namespace satu1 {
15
+
16
+ struct Block64 {
17
+ uint64_t bits;
18
+ float alpha;
19
+ };
20
+
21
+ inline int32_t popcount64_naive(uint64_t x) {
22
+ return __builtin_popcountll(x);
23
+ }
24
+
25
+ inline float compute_satu1_block_naive(
26
+ const uint64_t* activation_bits,
27
+ const uint64_t* weight_bits,
28
+ float alpha,
29
+ int block_size_words)
30
+ {
31
+ int32_t total_pop = 0;
32
+ for (int i = 0; i < block_size_words; ++i) {
33
+ uint64_t xnor = ~(activation_bits[i] ^ weight_bits[i]);
34
+ total_pop += __builtin_popcountll(xnor);
35
+ }
36
+ int32_t signed_sum = (2 * total_pop) - (block_size_words * 64);
37
+ return static_cast<float>(signed_sum) * alpha;
38
+ }
39
+
40
+ } // namespace satu1
41
+ } // namespace iknn