Impulse Graph C++ Engine 2.4.0
High-Performance Zero-Copy C-ABI Kernel and C++20 Fluent VM Engine
Loading...
Searching...
No Matches
impulse_math_ops.h
Go to the documentation of this file.
1
8
9#ifndef IMPULSE_MATH_OPS_H
10#define IMPULSE_MATH_OPS_H
11
12#include <stdint.h>
13#include <stddef.h>
14#include <stdbool.h>
15#include <math.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
24typedef enum {
25 // --- Algebraic & Roots (0x01 - 0x07) ---
33
34 // --- Exponential & Logarithmic (0x08 - 0x0F) ---
43
44 // --- Trigonometric & Spatial (0x10 - 0x17) ---
53
54 // --- Hyperbolic & Poincaré GNN (0x18 - 0x1D) ---
61
62 // --- Rounding & Clamping (0x1E - 0x24) ---
70
71 // --- GNN & Neural Activations (0x25 - 0x2A) ---
78
79 // --- Statistics & Special (0x2B - 0x2D) ---
83
84 // --- Discrete & Bitwise (0x2E - 0x32) ---
90
91 // --- Safe Arithmetic & IEEE 754 Sanitizers (0x33 - 0x36) ---
97
98#if defined(_MSC_VER)
99#include <intrin.h>
100static inline uint32_t impulse_builtin_popcount32(uint32_t x) {
101 return (uint32_t)__popcnt(x);
102}
103static inline uint32_t impulse_builtin_clz32(uint32_t x) {
104 unsigned long idx;
105 return _BitScanReverse(&idx, x) ? (31 - idx) : 32;
106}
107static inline uint32_t impulse_builtin_ctz32(uint32_t x) {
108 unsigned long idx;
109 return _BitScanForward(&idx, x) ? idx : 32;
110}
111static inline uint32_t impulse_builtin_popcount64(uint64_t x) {
112#if defined(_M_X64) || defined(_M_ARM64)
113 return (uint32_t)__popcnt64(x);
114#else
115 return (uint32_t)(__popcnt((uint32_t)x) + __popcnt((uint32_t)(x >> 32)));
116#endif
117}
118static inline uint32_t impulse_builtin_clz64(uint64_t x) {
119#if defined(_M_X64) || defined(_M_ARM64)
120 unsigned long idx;
121 return _BitScanReverse64(&idx, x) ? (63 - idx) : 64;
122#else
123 uint32_t high = (uint32_t)(x >> 32);
124 if (high != 0) return impulse_builtin_clz32(high);
125 return 32 + impulse_builtin_clz32((uint32_t)x);
126#endif
127}
128static inline uint32_t impulse_builtin_ctz64(uint64_t x) {
129#if defined(_M_X64) || defined(_M_ARM64)
130 unsigned long idx;
131 return _BitScanForward64(&idx, x) ? idx : 64;
132#else
133 uint32_t low = (uint32_t)x;
134 if (low != 0) return impulse_builtin_ctz32(low);
135 return 32 + impulse_builtin_ctz32((uint32_t)(x >> 32));
136#endif
137}
138#else
139static inline uint32_t impulse_builtin_popcount32(uint32_t x) {
140 return (uint32_t)__builtin_popcount((unsigned int)x);
141}
142static inline uint32_t impulse_builtin_clz32(uint32_t x) {
143 return x == 0 ? 32 : (uint32_t)__builtin_clz((unsigned int)x);
144}
145static inline uint32_t impulse_builtin_ctz32(uint32_t x) {
146 return x == 0 ? 32 : (uint32_t)__builtin_ctz((unsigned int)x);
147}
148static inline uint32_t impulse_builtin_popcount64(uint64_t x) {
149 return (uint32_t)__builtin_popcountll((unsigned long long)x);
150}
151static inline uint32_t impulse_builtin_clz64(uint64_t x) {
152 return x == 0 ? 64 : (uint32_t)__builtin_clzll((unsigned long long)x);
153}
154static inline uint32_t impulse_builtin_ctz64(uint64_t x) {
155 return x == 0 ? 64 : (uint32_t)__builtin_ctzll((unsigned long long)x);
156}
157#endif
158
162static inline uint32_t impulse_f32_to_u32_clamped(float x) {
163 if (isnan(x) || x <= 0.0f) return 0u;
164 if ((double)x >= 4294967295.0) return 0xFFFFFFFFu;
165 return (uint32_t)trunc((double)x);
166}
167
171static inline uint64_t impulse_f64_to_u64_clamped(double x) {
172 if (isnan(x) || x <= 0.0) return 0ULL;
173 if (x >= 18446744073709551616.0) return 0xFFFFFFFFFFFFFFFFULL;
174 return (uint64_t)trunc(x);
175}
176
180static inline uint32_t impulse_shift_amount_f64(double y, uint32_t mask) {
181 if (isnan(y) || isinf(y) || y <= -9007199254740992.0 || y >= 9007199254740992.0) return 0u;
182 int64_t sy = (int64_t)trunc(y);
183 return ((uint32_t)sy) & mask;
184}
185
189static inline float impulse_math_unary_f32(uint8_t func_id, float x) {
190 switch (func_id) {
191 case MATH_FUNC_ABS: return fabsf(x);
192 case MATH_FUNC_SQRT: return sqrtf(x);
193 case MATH_FUNC_RSQRT: return (float)(1.0 / sqrt((double)x));
194 case MATH_FUNC_CBRT: return cbrtf(x);
195 case MATH_FUNC_EXP: return expf(x);
196 case MATH_FUNC_EXP2: return exp2f(x);
197 case MATH_FUNC_EXP10: return powf(10.0f, x);
198 case MATH_FUNC_EXPM1: return expm1f(x);
199 case MATH_FUNC_LOG: return logf(x);
200 case MATH_FUNC_LOG2: return log2f(x);
201 case MATH_FUNC_LOG10: return log10f(x);
202 case MATH_FUNC_LOG1P: return log1pf(x);
203 case MATH_FUNC_SIN: return sinf(x);
204 case MATH_FUNC_COS: return cosf(x);
205 case MATH_FUNC_TAN: return tanf(x);
206 case MATH_FUNC_ASIN: return asinf(x);
207 case MATH_FUNC_ACOS: return acosf(x);
208 case MATH_FUNC_ATAN: return atanf(x);
209 case MATH_FUNC_SINC: return isnan(x) ? x : ((fabsf(x) < 1e-7f) ? 1.0f : (sinf(x) / x));
210 case MATH_FUNC_SINH: return sinhf(x);
211 case MATH_FUNC_COSH: return coshf(x);
212 case MATH_FUNC_TANH: return tanhf(x);
213 case MATH_FUNC_ASINH: return asinhf(x);
214 case MATH_FUNC_ACOSH: return acoshf(x);
215 case MATH_FUNC_ATANH: return atanhf(x);
216 case MATH_FUNC_FLOOR: return floorf(x);
217 case MATH_FUNC_CEIL: return ceilf(x);
218 case MATH_FUNC_TRUNC: return truncf(x);
219 case MATH_FUNC_ROUND: return roundf(x);
220 case MATH_FUNC_RELU: return isnan(x) ? x : ((x > 0.0f) ? x : 0.0f);
221 case MATH_FUNC_LEAKY_RELU: return isnan(x) ? x : ((x > 0.0f) ? x : (0.01f * x));
222 case MATH_FUNC_SIGMOID: return 1.0f / (1.0f + expf(-x));
223 case MATH_FUNC_GELU: {
224 if (isnan(x)) return x;
225 if (isinf(x)) return (x > 0.0f) ? x : 0.0f;
226 if (x <= -15.0f) return 0.0f;
227 if (x >= 15.0f) return x;
228 const float k0 = 0.7978845608f; // sqrt(2/pi)
229 const float k1 = 0.044715f;
230 return 0.5f * x * (1.0f + tanhf(k0 * (x + k1 * x * x * x)));
231 }
232 case MATH_FUNC_SILU: {
233 if (isnan(x)) return x;
234 if (isinf(x)) return (x > 0.0f) ? x : 0.0f;
235 return x / (1.0f + expf(-x));
236 }
237 case MATH_FUNC_SOFTPLUS: {
238 if (isnan(x)) return x;
239 if (isinf(x)) return (x > 0.0f) ? x : 0.0f;
240 if (x > 20.0f) return x;
241 return log1pf(expf(x));
242 }
243 case MATH_FUNC_ERF: return erff(x);
244 case MATH_FUNC_ERFC: return erfcf(x);
245 case MATH_FUNC_LGAMMA: {
246 if (isnan(x)) return x;
247 if (isinf(x)) return (float)INFINITY;
248 if (x <= 0.0f && floorf(x) == x) return (float)INFINITY;
249 return lgammaf(x);
250 }
251 case MATH_FUNC_POPCOUNT: return isnan(x) ? x : (float)impulse_builtin_popcount32(impulse_f32_to_u32_clamped(x));
252 case MATH_FUNC_CLZ: return isnan(x) ? x : (float)impulse_builtin_clz32(impulse_f32_to_u32_clamped(x));
253 case MATH_FUNC_CTZ: return isnan(x) ? x : (float)impulse_builtin_ctz32(impulse_f32_to_u32_clamped(x));
254 case MATH_FUNC_ISNAN: return isnan(x) ? 1.0f : 0.0f;
255 case MATH_FUNC_ISINF: return isinf(x) ? 1.0f : 0.0f;
256 case MATH_FUNC_ISFINITE: return isfinite(x) ? 1.0f : 0.0f;
257 default: return x;
258 }
259}
260
264static inline double impulse_math_unary_f64(uint8_t func_id, double x) {
265 switch (func_id) {
266 case MATH_FUNC_ABS: return fabs(x);
267 case MATH_FUNC_SQRT: return sqrt(x);
268 case MATH_FUNC_RSQRT: return 1.0 / sqrt(x);
269 case MATH_FUNC_CBRT: return cbrt(x);
270 case MATH_FUNC_EXP: return exp(x);
271 case MATH_FUNC_EXP2: return exp2(x);
272 case MATH_FUNC_EXP10: return pow(10.0, x);
273 case MATH_FUNC_EXPM1: return expm1(x);
274 case MATH_FUNC_LOG: return log(x);
275 case MATH_FUNC_LOG2: return log2(x);
276 case MATH_FUNC_LOG10: return log10(x);
277 case MATH_FUNC_LOG1P: return log1p(x);
278 case MATH_FUNC_SIN: return sin(x);
279 case MATH_FUNC_COS: return cos(x);
280 case MATH_FUNC_TAN: return tan(x);
281 case MATH_FUNC_ASIN: return asin(x);
282 case MATH_FUNC_ACOS: return acos(x);
283 case MATH_FUNC_ATAN: return atan(x);
284 case MATH_FUNC_SINC: return isnan(x) ? x : ((fabs(x) < 1e-15) ? 1.0 : (sin(x) / x));
285 case MATH_FUNC_SINH: return sinh(x);
286 case MATH_FUNC_COSH: return cosh(x);
287 case MATH_FUNC_TANH: return tanh(x);
288 case MATH_FUNC_ASINH: return asinh(x);
289 case MATH_FUNC_ACOSH: return acosh(x);
290 case MATH_FUNC_ATANH: return atanh(x);
291 case MATH_FUNC_FLOOR: return floor(x);
292 case MATH_FUNC_CEIL: return ceil(x);
293 case MATH_FUNC_TRUNC: return trunc(x);
294 case MATH_FUNC_ROUND: return round(x);
295 case MATH_FUNC_RELU: return isnan(x) ? x : ((x > 0.0) ? x : 0.0);
296 case MATH_FUNC_LEAKY_RELU: return isnan(x) ? x : ((x > 0.0) ? x : (0.01 * x));
297 case MATH_FUNC_SIGMOID: return 1.0 / (1.0 + exp(-x));
298 case MATH_FUNC_GELU: {
299 if (isnan(x)) return x;
300 if (isinf(x)) return (x > 0.0) ? x : 0.0;
301 if (x <= -15.0) return 0.0;
302 if (x >= 15.0) return x;
303 const double k0 = 0.7978845608028654; // sqrt(2/pi)
304 const double k1 = 0.044715;
305 return 0.5 * x * (1.0 + tanh(k0 * (x + k1 * x * x * x)));
306 }
307 case MATH_FUNC_SILU: {
308 if (isnan(x)) return x;
309 if (isinf(x)) return (x > 0.0) ? x : 0.0;
310 return x / (1.0 + exp(-x));
311 }
312 case MATH_FUNC_SOFTPLUS: {
313 if (isnan(x)) return x;
314 if (isinf(x)) return (x > 0.0) ? x : 0.0;
315 if (x > 40.0) return x;
316 return log1p(exp(x));
317 }
318 case MATH_FUNC_ERF: return erf(x);
319 case MATH_FUNC_ERFC: return erfc(x);
320 case MATH_FUNC_LGAMMA: {
321 if (isnan(x)) return x;
322 if (isinf(x)) return (double)INFINITY;
323 if (x <= 0.0 && floor(x) == x) return (double)INFINITY;
324 return lgamma(x);
325 }
326 case MATH_FUNC_POPCOUNT: return isnan(x) ? x : (double)impulse_builtin_popcount64(impulse_f64_to_u64_clamped(x));
327 case MATH_FUNC_CLZ: return isnan(x) ? x : (double)impulse_builtin_clz64(impulse_f64_to_u64_clamped(x));
328 case MATH_FUNC_CTZ: return isnan(x) ? x : (double)impulse_builtin_ctz64(impulse_f64_to_u64_clamped(x));
329 case MATH_FUNC_ISNAN: return isnan(x) ? 1.0 : 0.0;
330 case MATH_FUNC_ISINF: return isinf(x) ? 1.0 : 0.0;
331 case MATH_FUNC_ISFINITE: return isfinite(x) ? 1.0 : 0.0;
332 default: return x;
333 }
334}
335
339static inline float impulse_math_binary_f32(uint8_t func_id, float x, float y) {
340 switch (func_id) {
341 case 0: return x + y;
342 case 1: return x - y;
343 case 2: return x * y;
344 case 3: return isnan(x) ? x : ((y == 0.0f || isnan(y)) ? 0.0f : (x / y));
345 case 4: return powf(x, y);
346 case MATH_FUNC_POW: return powf(x, y);
347 case MATH_FUNC_HYPOT: return hypotf(x, y);
348 case MATH_FUNC_ATAN2: return atan2f(x, y);
349 case MATH_FUNC_COPYSIGN: return (isnan(x) || isnan(y)) ? (float)NAN : copysignf(x, y);
350 case MATH_FUNC_FMOD: return fmodf(x, y);
351 case MATH_FUNC_LEAKY_RELU: return (isnan(x) || isnan(y)) ? (float)NAN : ((x > 0.0f) ? x : (y * x));
352 case MATH_FUNC_SAFE_DIV: return isnan(x) ? x : ((y == 0.0f || isnan(y)) ? 0.0f : (x / y));
353 case MATH_FUNC_ROTL: {
354 if (isnan(x) || isnan(y)) return (float)NAN;
355 uint32_t ux = impulse_f32_to_u32_clamped(x);
356 uint32_t s = impulse_shift_amount_f64((double)y, 31u);
357 return (s == 0u) ? (float)ux : (float)((ux << s) | (ux >> (32u - s)));
358 }
359 case MATH_FUNC_ROTR: {
360 if (isnan(x) || isnan(y)) return (float)NAN;
361 uint32_t ux = impulse_f32_to_u32_clamped(x);
362 uint32_t s = impulse_shift_amount_f64((double)y, 31u);
363 return (s == 0u) ? (float)ux : (float)((ux >> s) | (ux << (32u - s)));
364 }
365 default: return x;
366 }
367}
368
372static inline double impulse_math_binary_f64(uint8_t func_id, double x, double y) {
373 switch (func_id) {
374 case 0: return x + y;
375 case 1: return x - y;
376 case 2: return x * y;
377 case 3: return isnan(x) ? x : ((y == 0.0 || isnan(y)) ? 0.0 : (x / y));
378 case 4: return pow(x, y);
379 case MATH_FUNC_POW: return pow(x, y);
380 case MATH_FUNC_HYPOT: return hypot(x, y);
381 case MATH_FUNC_ATAN2: return atan2(x, y);
382 case MATH_FUNC_COPYSIGN: return (isnan(x) || isnan(y)) ? (double)NAN : copysign(x, y);
383 case MATH_FUNC_FMOD: return fmod(x, y);
384 case MATH_FUNC_LEAKY_RELU: return (isnan(x) || isnan(y)) ? (double)NAN : ((x > 0.0) ? x : (y * x));
385 case MATH_FUNC_SAFE_DIV: return isnan(x) ? x : ((y == 0.0 || isnan(y)) ? 0.0 : (x / y));
386 case MATH_FUNC_ROTL: {
387 if (isnan(x) || isnan(y)) return (double)NAN;
388 uint64_t ux = impulse_f64_to_u64_clamped(x);
389 uint32_t s = impulse_shift_amount_f64(y, 63u);
390 return (s == 0u) ? (double)ux : (double)((ux << s) | (ux >> (64u - s)));
391 }
392 case MATH_FUNC_ROTR: {
393 if (isnan(x) || isnan(y)) return (double)NAN;
394 uint64_t ux = impulse_f64_to_u64_clamped(x);
395 uint32_t s = impulse_shift_amount_f64(y, 63u);
396 return (s == 0u) ? (double)ux : (double)((ux >> s) | (ux << (64u - s)));
397 }
398 default: return x;
399 }
400}
401
405static inline float impulse_math_ternary_f32(uint8_t func_id, float x, float y, float z) {
406 switch (func_id) {
407 case 0:
408 case 1: return fmaf(x, y, z);
409 case MATH_FUNC_LERP: return x + z * (y - x);
410 case MATH_FUNC_CLAMP: return (isnan(x) || isnan(y) || isnan(z)) ? (float)NAN : ((x < y) ? y : ((x > z) ? z : x));
411 case MATH_FUNC_SAFE_DIV: return isnan(x) ? x : ((y == 0.0f || isnan(y)) ? z : (x / y));
412 default: return x;
413 }
414}
415
419static inline double impulse_math_ternary_f64(uint8_t func_id, double x, double y, double z) {
420 switch (func_id) {
421 case 0:
422 case 1: return fma(x, y, z);
423 case MATH_FUNC_LERP: return x + z * (y - x);
424 case MATH_FUNC_CLAMP: return (isnan(x) || isnan(y) || isnan(z)) ? (double)NAN : ((x < y) ? y : ((x > z) ? z : x));
425 case MATH_FUNC_SAFE_DIV: return isnan(x) ? x : ((y == 0.0 || isnan(y)) ? z : (x / y));
426 default: return x;
427 }
428}
429
433static inline void impulse_vector_math_unary_f32(uint8_t func_id, float* dst, const float* src, size_t count) {
434 #pragma omp parallel for schedule(static, 1024) if (count > 2048)
435 for (size_t i = 0; i < count; ++i) {
436 dst[i] = impulse_math_unary_f32(func_id, src[i]);
437 }
438}
439
440static inline void impulse_vector_math_unary_f64(uint8_t func_id, double* dst, const double* src, size_t count) {
441 #pragma omp parallel for schedule(static, 1024) if (count > 2048)
442 for (size_t i = 0; i < count; ++i) {
443 dst[i] = impulse_math_unary_f64(func_id, src[i]);
444 }
445}
446
450static inline void impulse_vector_math_binary_f32(uint8_t func_id, float* dst, const float* src1, const float* src2, size_t count) {
451 #pragma omp parallel for schedule(static, 1024) if (count > 2048)
452 for (size_t i = 0; i < count; ++i) {
453 dst[i] = impulse_math_binary_f32(func_id, src1[i], src2[i]);
454 }
455}
456
457static inline void impulse_vector_math_binary_f64(uint8_t func_id, double* dst, const double* src1, const double* src2, size_t count) {
458 #pragma omp parallel for schedule(static, 1024) if (count > 2048)
459 for (size_t i = 0; i < count; ++i) {
460 dst[i] = impulse_math_binary_f64(func_id, src1[i], src2[i]);
461 }
462}
463
467static inline void impulse_vector_math_ternary_f32(uint8_t func_id, float* dst, const float* src1, const float* src2, const float* src3, size_t count) {
468 #pragma omp parallel for schedule(static, 1024) if (count > 2048)
469 for (size_t i = 0; i < count; ++i) {
470 dst[i] = impulse_math_ternary_f32(func_id, src1[i], src2[i], src3[i]);
471 }
472}
473
474static inline void impulse_vector_math_ternary_f64(uint8_t func_id, double* dst, const double* src1, const double* src2, const double* src3, size_t count) {
475 #pragma omp parallel for schedule(static, 1024) if (count > 2048)
476 for (size_t i = 0; i < count; ++i) {
477 dst[i] = impulse_math_ternary_f64(func_id, src1[i], src2[i], src3[i]);
478 }
479}
480
481#ifdef __cplusplus
482}
483#endif
484
485#endif // IMPULSE_MATH_OPS_H
static uint32_t impulse_builtin_popcount64(uint64_t x)
Definition impulse_math_ops.h:148
static double impulse_math_unary_f64(uint8_t func_id, double x)
Evaluates a scalar unary math operation on double.
Definition impulse_math_ops.h:264
static float impulse_math_ternary_f32(uint8_t func_id, float x, float y, float z)
Evaluates a scalar ternary math operation on float.
Definition impulse_math_ops.h:405
static uint32_t impulse_builtin_clz32(uint32_t x)
Definition impulse_math_ops.h:142
static void impulse_vector_math_ternary_f32(uint8_t func_id, float *dst, const float *src1, const float *src2, const float *src3, size_t count)
Vectorized Ternary Vector Math Evaluation.
Definition impulse_math_ops.h:467
static uint32_t impulse_builtin_ctz32(uint32_t x)
Definition impulse_math_ops.h:145
static double impulse_math_ternary_f64(uint8_t func_id, double x, double y, double z)
Evaluates a scalar ternary math operation on double.
Definition impulse_math_ops.h:419
static void impulse_vector_math_binary_f32(uint8_t func_id, float *dst, const float *src1, const float *src2, size_t count)
Vectorized Binary Vector Math Evaluation.
Definition impulse_math_ops.h:450
static float impulse_math_unary_f32(uint8_t func_id, float x)
Evaluates a scalar unary math operation on float.
Definition impulse_math_ops.h:189
static void impulse_vector_math_binary_f64(uint8_t func_id, double *dst, const double *src1, const double *src2, size_t count)
Definition impulse_math_ops.h:457
static double impulse_math_binary_f64(uint8_t func_id, double x, double y)
Evaluates a scalar binary math operation on double.
Definition impulse_math_ops.h:372
impulse_math_func_id_t
Canonical 42 Vector Math Function Identifiers (func_id).
Definition impulse_math_ops.h:24
@ MATH_FUNC_COPYSIGN
Definition impulse_math_ops.h:68
@ MATH_FUNC_COS
Definition impulse_math_ops.h:46
@ MATH_FUNC_SAFE_DIV
Definition impulse_math_ops.h:92
@ MATH_FUNC_ATAN
Definition impulse_math_ops.h:50
@ MATH_FUNC_ACOS
Definition impulse_math_ops.h:49
@ MATH_FUNC_HYPOT
Definition impulse_math_ops.h:31
@ MATH_FUNC_LOG10
Definition impulse_math_ops.h:41
@ MATH_FUNC_FMOD
Definition impulse_math_ops.h:69
@ MATH_FUNC_TANH
Definition impulse_math_ops.h:57
@ MATH_FUNC_CLZ
Definition impulse_math_ops.h:86
@ MATH_FUNC_COSH
Definition impulse_math_ops.h:56
@ MATH_FUNC_CEIL
Definition impulse_math_ops.h:64
@ MATH_FUNC_CBRT
Definition impulse_math_ops.h:29
@ MATH_FUNC_SIN
Definition impulse_math_ops.h:45
@ MATH_FUNC_SIGMOID
Definition impulse_math_ops.h:74
@ MATH_FUNC_ATANH
Definition impulse_math_ops.h:60
@ MATH_FUNC_EXP2
Definition impulse_math_ops.h:36
@ MATH_FUNC_RELU
Definition impulse_math_ops.h:72
@ MATH_FUNC_TRUNC
Definition impulse_math_ops.h:65
@ MATH_FUNC_FLOOR
Definition impulse_math_ops.h:63
@ MATH_FUNC_GELU
Definition impulse_math_ops.h:75
@ MATH_FUNC_ROUND
Definition impulse_math_ops.h:66
@ MATH_FUNC_CLAMP
Definition impulse_math_ops.h:67
@ MATH_FUNC_ROTL
Definition impulse_math_ops.h:88
@ MATH_FUNC_SILU
Definition impulse_math_ops.h:76
@ MATH_FUNC_LOG2
Definition impulse_math_ops.h:40
@ MATH_FUNC_ASIN
Definition impulse_math_ops.h:48
@ MATH_FUNC_SINC
Definition impulse_math_ops.h:52
@ MATH_FUNC_TAN
Definition impulse_math_ops.h:47
@ MATH_FUNC_ATAN2
Definition impulse_math_ops.h:51
@ MATH_FUNC_ACOSH
Definition impulse_math_ops.h:59
@ MATH_FUNC_POW
Definition impulse_math_ops.h:30
@ MATH_FUNC_SQRT
Definition impulse_math_ops.h:27
@ MATH_FUNC_POPCOUNT
Definition impulse_math_ops.h:85
@ MATH_FUNC_EXP
Definition impulse_math_ops.h:35
@ MATH_FUNC_EXPM1
Definition impulse_math_ops.h:38
@ MATH_FUNC_ISFINITE
Definition impulse_math_ops.h:95
@ MATH_FUNC_LEAKY_RELU
Definition impulse_math_ops.h:73
@ MATH_FUNC_ERF
Definition impulse_math_ops.h:80
@ MATH_FUNC_ROTR
Definition impulse_math_ops.h:89
@ MATH_FUNC_LOG
Definition impulse_math_ops.h:39
@ MATH_FUNC_LERP
Definition impulse_math_ops.h:32
@ MATH_FUNC_ASINH
Definition impulse_math_ops.h:58
@ MATH_FUNC_ABS
Definition impulse_math_ops.h:26
@ MATH_FUNC_ERFC
Definition impulse_math_ops.h:81
@ MATH_FUNC_LOG1P
Definition impulse_math_ops.h:42
@ MATH_FUNC_EXP10
Definition impulse_math_ops.h:37
@ MATH_FUNC_SINH
Definition impulse_math_ops.h:55
@ MATH_FUNC_ISNAN
Definition impulse_math_ops.h:93
@ MATH_FUNC_CTZ
Definition impulse_math_ops.h:87
@ MATH_FUNC_RSQRT
Definition impulse_math_ops.h:28
@ MATH_FUNC_ISINF
Definition impulse_math_ops.h:94
@ MATH_FUNC_LGAMMA
Definition impulse_math_ops.h:82
@ MATH_FUNC_SOFTPLUS
Definition impulse_math_ops.h:77
static void impulse_vector_math_ternary_f64(uint8_t func_id, double *dst, const double *src1, const double *src2, const double *src3, size_t count)
Definition impulse_math_ops.h:474
static uint32_t impulse_shift_amount_f64(double y, uint32_t mask)
UB-free masked shift count extraction from double.
Definition impulse_math_ops.h:180
static void impulse_vector_math_unary_f32(uint8_t func_id, float *dst, const float *src, size_t count)
Vectorized Unary Vector Math Evaluation.
Definition impulse_math_ops.h:433
static uint32_t impulse_builtin_popcount32(uint32_t x)
Definition impulse_math_ops.h:139
static float impulse_math_binary_f32(uint8_t func_id, float x, float y)
Evaluates a scalar binary math operation on float.
Definition impulse_math_ops.h:339
static uint64_t impulse_f64_to_u64_clamped(double x)
UB-free double-to-uint64 saturating truncation helper.
Definition impulse_math_ops.h:171
static void impulse_vector_math_unary_f64(uint8_t func_id, double *dst, const double *src, size_t count)
Definition impulse_math_ops.h:440
static uint32_t impulse_builtin_clz64(uint64_t x)
Definition impulse_math_ops.h:151
static uint32_t impulse_f32_to_u32_clamped(float x)
UB-free float-to-uint32 saturating truncation helper.
Definition impulse_math_ops.h:162
static uint32_t impulse_builtin_ctz64(uint64_t x)
Definition impulse_math_ops.h:154