File q15_mac.h¶
Go to the source code of this file
Static inline Q15 dot-product primitives: scalar fallback and AVX2. More...
#include <stddef.h>#include <stdint.h>
Public Static Functions¶
| Type | Name |
|---|---|
| int64_t | dot_q15_scalar (const int16_t * a, const int16_t * b, size_t n) Scalar Q15 dot product. |
Detailed Description¶
Provides two functions:
int64_t dot_q15_scalar(a, b, n) int64_t dot_q15_avx2 (a, b, n) — only when AVX2 is defined
Both compute the exact integer inner product sum(a[i] * b[i]) for i in [0, n), accumulating into int64_t without saturation. The caller decides how to round and saturate the result.
Result format: Q30 (each Q15 × Q15 product is Q30; n products accumulate in int64_t, which has sufficient headroom for n ≤ 2^33 before overflow).
The hsum_epi32_i64 helper is also exposed so callers that maintain their own AVX2 accumulator can reduce it to a scalar at the end.
Usage:
#include "q15_mac.h"
int64_t acc;
#if defined(__AVX2__)
acc = dot_q15_avx2(a, b, n);
#else
acc = dot_q15_scalar(a, b, n);
#endif
// shift to Q15: int32_t out = (int32_t)((acc + (1 << 14)) >> 15);
Public Static Functions Documentation¶
function dot_q15_scalar¶
Scalar Q15 dot product.
Each product is widened to int32_t before accumulation into int64_t to avoid overflow. Correct for all Q15 inputs and any n ≤ 2^33.
The documentation for this class was generated from the following file native/inc/q15_mac.h