1pub const ROPE_SPV: &[u8] = include_bytes!("../../shaders/rope.spv");
11pub const SILU_MUL_SPV: &[u8] = include_bytes!("../../shaders/silu_mul.spv");
12pub const RMSNORM_SPV: &[u8] = include_bytes!("../../shaders/rmsnorm.spv");
13pub const VEC_ADD_SPV: &[u8] = include_bytes!("../../shaders/vec_add.spv");
14pub const HOT_STRATUM_E8_SPV: &[u8] = include_bytes!("../../shaders/hot_stratum_e8.spv");
15pub const PGA_TRANSFORM_SPV: &[u8] = include_bytes!("../../shaders/pga_transform.spv");
16pub const CGA_TRANSFORM_SPV: &[u8] = include_bytes!("../../shaders/cga_transform.spv");
17pub const GA_CL3_BATCH_SPV: &[u8] = include_bytes!("../../shaders/ga_cl3_batch.spv");
18pub const POINCARE_MOBIUS_BATCH_SPV: &[u8] = include_bytes!("../../shaders/poincare_mobius_batch.spv");
19
20#[repr(C)]
22#[derive(Debug, Clone, Copy, PartialEq)]
23#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
24pub struct RopePushConstants {
25 pub pos: u32,
26 pub n_heads: u32,
27 pub head_dim: u32,
28 pub rope_theta: f32,
29 pub is_neox: u32,
30 pub _pad0: u32,
31 pub _pad1: u32,
32 pub _pad2: u32,
33}
34
35impl RopePushConstants {
36 pub fn new(pos: u32, n_heads: u32, head_dim: u32, rope_theta: f32, is_neox: bool) -> Self {
37 Self {
38 pos,
39 n_heads,
40 head_dim,
41 rope_theta,
42 is_neox: if is_neox { 1 } else { 0 },
43 _pad0: 0,
44 _pad1: 0,
45 _pad2: 0,
46 }
47 }
48}
49
50#[repr(C)]
52#[derive(Debug, Clone, Copy, PartialEq)]
53#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
54pub struct SiluMulPushConstants {
55 pub num_elements: u32,
56 pub _pad0: u32,
57 pub _pad1: u32,
58 pub _pad2: u32,
59}
60
61impl SiluMulPushConstants {
62 pub fn new(num_elements: u32) -> Self {
63 Self {
64 num_elements,
65 _pad0: 0,
66 _pad1: 0,
67 _pad2: 0,
68 }
69 }
70}
71
72#[repr(C)]
74#[derive(Debug, Clone, Copy, PartialEq)]
75#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
76pub struct RmsNormPushConstants {
77 pub d_model: u32,
78 pub eps: f32,
79 pub gamma_offset_f32: u32,
80 pub _pad1: u32,
81}
82
83impl RmsNormPushConstants {
84 pub fn new(d_model: u32, eps: f32, gamma_offset_f32: u32) -> Self {
85 Self {
86 d_model,
87 eps,
88 gamma_offset_f32,
89 _pad1: 0,
90 }
91 }
92}
93
94#[repr(C)]
96#[derive(Debug, Clone, Copy, PartialEq)]
97#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
98pub struct VecAddPushConstants {
99 pub num_elements: u32,
100 pub _pad0: u32,
101 pub _pad1: u32,
102 pub _pad2: u32,
103}
104
105impl VecAddPushConstants {
106 pub fn new(num_elements: u32) -> Self {
107 Self {
108 num_elements,
109 _pad0: 0,
110 _pad1: 0,
111 _pad2: 0,
112 }
113 }
114}
115
116#[repr(C)]
118#[derive(Debug, Clone, Copy, PartialEq)]
119#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
120pub struct HotStratumE8PushConstants {
121 pub d_model: u32,
122 pub neuron_count: u32,
123 pub pass_id: u32,
124 pub layer_gamma: f32,
125 pub beta: f32,
126 pub gate_gamma: f32,
127 pub up_gamma: f32,
128 pub words_per_row: u32,
129}
130
131#[repr(C)]
133#[derive(Debug, Clone, Copy, PartialEq)]
134#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
135pub struct PgaTransformPushConstants {
136 pub num_points: u32,
137 pub motor_s: f32,
138 pub motor_b23: f32,
139 pub motor_b31: f32,
140 pub motor_b12: f32,
141 pub motor_d01: f32,
142 pub motor_d02: f32,
143 pub motor_d03: f32,
144 pub motor_e0123: f32,
145 pub _pad0: u32,
146 pub _pad1: u32,
147 pub _pad2: u32,
148}
149
150impl PgaTransformPushConstants {
151 pub fn new(num_points: u32, motor: &crate::pga::PgaMotor) -> Self {
152 Self {
153 num_points,
154 motor_s: motor.s,
155 motor_b23: motor.b23,
156 motor_b31: motor.b31,
157 motor_b12: motor.b12,
158 motor_d01: motor.d01,
159 motor_d02: motor.d02,
160 motor_d03: motor.d03,
161 motor_e0123: motor.e0123,
162 _pad0: 0,
163 _pad1: 0,
164 _pad2: 0,
165 }
166 }
167}
168
169#[repr(C)]
171#[derive(Debug, Clone, Copy, PartialEq)]
172#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
173pub struct CgaTransformPushConstants {
174 pub num_points: u32,
175 pub op_type: u32,
176 pub sphere_cx: f32,
177 pub sphere_cy: f32,
178 pub sphere_cz: f32,
179 pub sphere_radius: f32,
180 pub param_lambda: f32,
181 pub param_dy: f32,
182 pub param_dz: f32,
183 pub _pad0: u32,
184 pub _pad1: u32,
185 pub _pad2: u32,
186}
187
188impl CgaTransformPushConstants {
189 pub fn spherical_inversion(num_points: u32, center: [f32; 3], radius: f32) -> Self {
190 Self {
191 num_points,
192 op_type: 0,
193 sphere_cx: center[0],
194 sphere_cy: center[1],
195 sphere_cz: center[2],
196 sphere_radius: radius,
197 param_lambda: 0.0,
198 param_dy: 0.0,
199 param_dz: 0.0,
200 _pad0: 0,
201 _pad1: 0,
202 _pad2: 0,
203 }
204 }
205
206 pub fn dilation(num_points: u32, factor: f32) -> Self {
207 Self {
208 num_points,
209 op_type: 1,
210 sphere_cx: 0.0,
211 sphere_cy: 0.0,
212 sphere_cz: 0.0,
213 sphere_radius: 0.0,
214 param_lambda: factor,
215 param_dy: 0.0,
216 param_dz: 0.0,
217 _pad0: 0,
218 _pad1: 0,
219 _pad2: 0,
220 }
221 }
222
223 pub fn translation(num_points: u32, shift: [f32; 3]) -> Self {
224 Self {
225 num_points,
226 op_type: 2,
227 sphere_cx: 0.0,
228 sphere_cy: 0.0,
229 sphere_cz: 0.0,
230 sphere_radius: 0.0,
231 param_lambda: shift[0],
232 param_dy: shift[1],
233 param_dz: shift[2],
234 _pad0: 0,
235 _pad1: 0,
236 _pad2: 0,
237 }
238 }
239}
240
241#[repr(C)]
243#[derive(Debug, Clone, Copy, PartialEq)]
244#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
245pub struct GaCl3BatchPushConstants {
246 pub num_elements: u32,
247 pub op_code: u32,
248 pub _pad0: u32,
249 pub _pad1: u32,
250}
251
252impl GaCl3BatchPushConstants {
253 pub fn new(num_elements: u32, op_code: u32) -> Self {
254 Self {
255 num_elements,
256 op_code,
257 _pad0: 0,
258 _pad1: 0,
259 }
260 }
261}
262
263#[repr(C)]
265#[derive(Debug, Clone, Copy, PartialEq)]
266#[cfg_attr(feature = "vulkan", derive(bytemuck::Pod, bytemuck::Zeroable))]
267pub struct PoincareBatchPushConstants {
268 pub num_elements: u32,
269 pub op_code: u32,
270 pub sphere_cx: f32,
271 pub sphere_cy: f32,
272 pub sphere_cz: f32,
273 pub sphere_radius: f32,
274 pub _pad0: u32,
275 pub _pad1: u32,
276}
277
278impl PoincareBatchPushConstants {
279 pub fn new(num_elements: u32, op_code: u32, sphere_center: [f32; 3], sphere_radius: f32) -> Self {
280 Self {
281 num_elements,
282 op_code,
283 sphere_cx: sphere_center[0],
284 sphere_cy: sphere_center[1],
285 sphere_cz: sphere_center[2],
286 sphere_radius,
287 _pad0: 0,
288 _pad1: 0,
289 }
290 }
291}