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
// RLX — versatile ML compiler + runtime.
// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! 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.
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 if AVX2 is reasonably likely to be present at runtime.
/// This is a *static* prediction — explicit runtime detection
/// belongs in the dispatch path; this is for "should we even
/// compile the AVX2 code path?"
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 the Metal-capable platform (macOS, plus iOS/tvOS in the
/// future if RLX adds those targets).
pub const