okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-own-2n (ead5a32ae) into f-own-int: the Arm NEON tier of the quant layer0a9381336

main
1.3 KiB33 linesraw
1// arm_helpers.inc - the few ggml-cpu helpers the ported NEON code names (ggml/src/ggml-cpu/ggml-cpu-impl.h at 3cf03257f219afbe7334045ff7c6a06ac68c627d,
2// Copyright (c) 2023-2026 The ggml authors, MIT), in their aarch64 form.  Included inside the neon namespace by dot_neon.cpp and act_neon.cpp.
3
4#ifndef STRATA_ARM_HELPERS
5#define STRATA_ARM_HELPERS
6
7#define ggml_vld1q_u32(w, x, y, z) { (w), (x), (y), (z) }
8
9#define ggml_int16x8x2_t  int16x8x2_t
10#define ggml_uint8x16x2_t uint8x16x2_t
11#define ggml_uint8x16x4_t uint8x16x4_t
12#define ggml_int8x16x2_t  int8x16x2_t
13#define ggml_int8x16x4_t  int8x16x4_t
14
15#define ggml_vld1q_s16_x2 vld1q_s16_x2
16#define ggml_vld1q_u8_x2  vld1q_u8_x2
17#define ggml_vld1q_u8_x4  vld1q_u8_x4
18#define ggml_vld1q_s8_x2  vld1q_s8_x2
19#define ggml_vld1q_s8_x4  vld1q_s8_x4
20#define ggml_vqtbl1q_s8   vqtbl1q_s8
21#define ggml_vqtbl1q_u8   vqtbl1q_u8
22
23#define ggml_vdotq_s32(a, b, c) vdotq_s32(a, b, c)
24
25static inline int32x4_t ggml_nvfp4_dot8(const int8x8_t q4_lo, const int8x8_t q8_lo, const int8x8_t q4_hi, const int8x8_t q8_hi) {
26    const int16x8_t p_lo = vmull_s8(q4_lo, q8_lo);
27    const int16x8_t p_hi = vmull_s8(q4_hi, q8_hi);
28    const int32x4_t sum_lo = vpaddlq_s16(p_lo);
29    const int32x4_t sum_hi = vpaddlq_s16(p_hi);
30    return vaddq_s32(sum_lo, sum_hi);
31}
32
33#endif