1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2026 Fábio Henrique de Lima Silva (fhl.bsb@gmail.com) All rights reserved.
//! Unification macros for activation-slice SIMD scanning loops.
//!
//! These macros extract the boilerplate slice-iteration logic shared across
//! all activation functions (`avx2` / `avx512`), so each activation kernel
//! only needs to supply its core arithmetic body.
/// AVX2 activation slice kernel: 16-wide (dual `__m256`) loop then
/// 8-wide (single `__m256`) remainder.
///
/// Caller owns `$i` and handles the scalar tail after this macro.
///
/// The caller must wrap the invocation in `unsafe { ... }`.
///
/// # Parameters
/// - `$i`: mutable index variable (e.g. `i`)
/// - `$len`: slice length expression (e.g. `len` or `data.len()`)
/// - `{ $($dual:tt)* }`: body for the 16-wide loop; receives
/// `$i` as current offset
/// - `{ $($single:tt)* }`: body for the 8-wide remainder loop
/// AVX-512 activation slice kernel: 16-wide (single `__m512`) loop.
///
/// Caller owns `$i` and handles the scalar tail after this macro.
///
/// The caller must wrap the invocation in `unsafe { ... }`.
///
/// # Parameters
/// - `$i`: mutable index variable
/// - `$len`: slice length expression
/// - `{ $($simd:tt)* }`: body for the 16-wide loop