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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// RLX — versatile ML compiler + runtime.
// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Compile-time target predicates (plan #78).
//!
//! Borrowed from MAX's `std.gpu.host.info` `is_cpu` / `is_valid_target`
//! pattern. Centralized const fns the optimizer / fusion patterns use
//! to prune backend-specific code paths at compile time instead of
//! branching at runtime.
//!
//! Why a module instead of inline `cfg!()`?
//! - One source of truth: changing a predicate (e.g. broadening
//! `has_amx` to include M-series Pro/Max) updates every call site.
//! - Documented contract: each predicate's docstring records what
//! the answer means and what kernels rely on it.
//! - `const fn`: can be used in const contexts (lookup tables,
//! static assertions).
/// True on Apple Silicon — M-series Macs and the A/M/S-series chips in
/// iPhones, iPads, Apple TVs, Apple Watches and Vision Pro (plus the
/// aarch64 simulators). They ship the AMX coprocessor (and, except the
/// Watch, a Metal GPU), so the same fast paths apply. The x86_64
/// simulators are deliberately excluded (they run on Intel Macs).
pub const
/// True on iOS (iPhone/iPad), device or simulator.
pub const
/// True on tvOS (Apple TV), device or simulator.
pub const
/// True on watchOS (Apple Watch), device or simulator. Note: watchOS has
/// no Metal — see [`has_metal`].
pub const
/// True on visionOS (Apple Vision Pro / "xrOS"), device or simulator.
pub const
/// True on any Apple platform that RLX builds native backends for —
/// macOS, iOS, tvOS, watchOS or visionOS. The Accelerate (AMX BLAS) and
/// CoreML/ANE backends compile on all of them; use this instead of
/// repeating the `target_vendor = "apple"` cfg inline. (Metal is the one
/// exception — it skips watchOS; see [`has_metal`].)
pub const
/// True on aarch64 broadly (Apple Silicon + Linux ARM + AWS Graviton).
pub const
/// True on x86_64 (Intel / AMD desktop and server).
pub const
/// True on macOS (any arch).
pub const
/// True if NEON intrinsics are available. On AArch64 NEON is
/// architectural (always present); on x86 we'd need explicit
/// runtime detection (not done here).
pub const
/// True only when this build was *pinned* to AVX2 at compile time, i.e. it
/// was given `-C target-cpu=native` (or `x86-64-v3`, or an explicit
/// `+avx2`). It is NOT "this CPU has AVX2": a stock `cargo build` answers
/// false on an AVX-512 server, because a stock build deliberately stays
/// baseline so one artifact runs everywhere.
///
/// Do not use this to pick a code path. It reads like a capability check and
/// is really a build-flag check, and acting on it is how a kernel ends up
/// existing only in a non-portable artifact: `rlx-cpu`'s `bias_gelu` and
/// `layer_norm_row` were gated this way, so the portable build silently lost
/// their AVX2 kernels and the only way to get them was a binary that
/// `SIGILL`s on any pre-Gracemont Atom. Both now dispatch on
/// `is_x86_feature_detected!`, which is the pattern to copy — compile the
/// path unconditionally, choose it at runtime. `just check-isa` enforces it.
pub const
/// True when the target has access to the Apple AMX coprocessor —
/// i.e. through Accelerate's BLAS path. Not a direct AMX intrinsic
/// gate (those are unstable / undocumented); used by callers that
/// want to know "is there something matmul-grade besides NEON
/// available."
pub const
/// True on a Metal-capable Apple platform — macOS, iOS, tvOS and
/// visionOS. All ship Metal, MetalPerformanceShaders and MPSGraph, so the
/// native `rlx-metal` backend builds and runs on each. **watchOS is
/// excluded**: it has no public Metal API, so the Metal backend never
/// builds there (Accelerate + CoreML remain available via
/// [`is_apple_platform`]).
pub const