Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/MojoLlama/blob/main/src/mojollama/kernels/legacy-c/debug_layer.c # MojoLlama Archived Mojo/MAX quantizer and serving research repository (read-only history) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `MojoLlama / src / mojollama / kernels / legacy-c / debug_layer.c` 48 lines · 2413 bytes Raw Blame History 1 /* debug_layer.c — Print first layer intermediate values for debugging. 2 * Compile: gcc -O0 -g -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ 3 * -o debug_layer.so debug_layer.c -lm 4 */ 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 12 #define Q4_0_BS 18 13 14 static inline float f16_to_f32(uint16_t h) { return _cvtsh_ss(h); } 15 static inline float hsum_ps(__m256 v) { 16 __m128 l=_mm256_castps256_ps128(v),h=_mm256_extractf128_ps(v,1); 17 l=_mm_add_ps(l,h);l=_mm_hadd_ps(l,l);l=_mm_hadd_ps(l,l);return _mm_cvtss_f32(l); 18 } 19 20 void test_q4_matmul(const uint8_t *W, const float *x, float *out, 21 int n_rows, int n_cols, int layer, const char *name) { 22 int bp=n_cols/32; 23 #pragma omp parallel for schedule(static) 24 for(int r=0;r