cubecl_core/frontend/
plane.rs1use cubecl_ir::ManagedVariable;
2
3use super::{CubePrimitive, Vector};
4use crate::prelude::*;
5use crate::{
6 ir::{ElemType, Instruction, Plane, Scope, Type, UnaryOperator},
7 unexpanded,
8};
9
10pub fn plane_elect() -> bool {
12 unexpanded!()
13}
14
15pub mod plane_elect {
17
18 use super::*;
19
20 pub fn expand(scope: &mut Scope) -> NativeExpand<bool> {
22 let output = scope.create_local(Type::scalar(ElemType::Bool));
23 let out = *output;
24
25 scope.register(Instruction::new(Plane::Elect, out));
26
27 output.into()
28 }
29}
30
31#[allow(unused_variables)]
35pub fn plane_broadcast<E: CubePrimitive>(value: E, index: u32) -> E {
36 unexpanded!()
37}
38
39pub mod plane_broadcast {
41
42 use super::*;
43
44 pub fn expand<E: CubePrimitive>(
46 scope: &mut Scope,
47 value: NativeExpand<E>,
48 id: u32,
49 ) -> NativeExpand<E> {
50 let output = scope.create_local(value.expand.ty);
51 let out = *output;
52 let lhs = *value.expand;
53 let rhs = id.into();
54
55 scope.register(Instruction::new(
56 Plane::Broadcast(crate::ir::BinaryOperator { lhs, rhs }),
57 out,
58 ));
59
60 output.into()
61 }
62}
63
64#[allow(unused_variables)]
71pub fn plane_shuffle<E: CubePrimitive>(value: E, src_lane: u32) -> E {
72 unexpanded!()
73}
74
75pub mod plane_shuffle {
77
78 use super::*;
79
80 pub fn expand<E: CubePrimitive>(
82 scope: &mut Scope,
83 value: NativeExpand<E>,
84 src_lane: NativeExpand<u32>,
85 ) -> NativeExpand<E> {
86 let output = scope.create_local(value.expand.ty);
87 let out = *output;
88 let lhs = *value.expand;
89 let rhs = *src_lane.expand;
90
91 scope.register(Instruction::new(
92 Plane::Shuffle(crate::ir::BinaryOperator { lhs, rhs }),
93 out,
94 ));
95
96 output.into()
97 }
98}
99
100#[allow(unused_variables)]
110pub fn plane_shuffle_xor<E: CubePrimitive>(value: E, mask: u32) -> E {
111 unexpanded!()
112}
113
114pub mod plane_shuffle_xor {
116
117 use super::*;
118
119 pub fn expand<E: CubePrimitive>(
121 scope: &mut Scope,
122 value: NativeExpand<E>,
123 mask: NativeExpand<u32>,
124 ) -> NativeExpand<E> {
125 let output = scope.create_local(value.expand.ty);
126 let out = *output;
127 let lhs = *value.expand;
128 let rhs = *mask.expand;
129
130 scope.register(Instruction::new(
131 Plane::ShuffleXor(crate::ir::BinaryOperator { lhs, rhs }),
132 out,
133 ));
134
135 output.into()
136 }
137}
138
139#[allow(unused_variables)]
146pub fn plane_shuffle_up<E: CubePrimitive>(value: E, delta: u32) -> E {
147 unexpanded!()
148}
149
150pub mod plane_shuffle_up {
152
153 use super::*;
154
155 pub fn expand<E: CubePrimitive>(
157 scope: &mut Scope,
158 value: NativeExpand<E>,
159 delta: NativeExpand<u32>,
160 ) -> NativeExpand<E> {
161 let output = scope.create_local(value.expand.ty);
162 let out = *output;
163 let lhs = *value.expand;
164 let rhs = *delta.expand;
165
166 scope.register(Instruction::new(
167 Plane::ShuffleUp(crate::ir::BinaryOperator { lhs, rhs }),
168 out,
169 ));
170
171 output.into()
172 }
173}
174
175#[allow(unused_variables)]
182pub fn plane_shuffle_down<E: CubePrimitive>(value: E, delta: u32) -> E {
183 unexpanded!()
184}
185
186pub mod plane_shuffle_down {
188
189 use super::*;
190
191 pub fn expand<E: CubePrimitive>(
193 scope: &mut Scope,
194 value: NativeExpand<E>,
195 delta: NativeExpand<u32>,
196 ) -> NativeExpand<E> {
197 let output = scope.create_local(value.expand.ty);
198 let out = *output;
199 let lhs = *value.expand;
200 let rhs = *delta.expand;
201
202 scope.register(Instruction::new(
203 Plane::ShuffleDown(crate::ir::BinaryOperator { lhs, rhs }),
204 out,
205 ));
206
207 output.into()
208 }
209}
210
211#[allow(unused_variables)]
213pub fn plane_sum<E: CubePrimitive>(value: E) -> E {
214 unexpanded!()
215}
216
217pub mod plane_sum {
219 use super::*;
220
221 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
223 let elem: ManagedVariable = elem.into();
224 let output = scope.create_local(elem.ty);
225
226 let out = *output;
227 let input = *elem;
228
229 scope.register(Instruction::new(Plane::Sum(UnaryOperator { input }), out));
230
231 output.into()
232 }
233}
234
235#[allow(unused_variables)]
242pub fn plane_inclusive_sum<E: CubePrimitive>(value: E) -> E {
243 unexpanded!()
244}
245
246pub mod plane_inclusive_sum {
248 use super::*;
249
250 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
252 let elem: ManagedVariable = elem.into();
253 let output = scope.create_local(elem.ty);
254
255 let out = *output;
256 let input = *elem;
257
258 scope.register(Instruction::new(
259 Plane::InclusiveSum(UnaryOperator { input }),
260 out,
261 ));
262
263 output.into()
264 }
265}
266
267#[allow(unused_variables)]
275pub fn plane_exclusive_sum<E: CubePrimitive>(value: E) -> E {
276 unexpanded!()
277}
278
279pub mod plane_exclusive_sum {
281 use super::*;
282
283 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
285 let elem: ManagedVariable = elem.into();
286 let output = scope.create_local(elem.ty);
287
288 let out = *output;
289 let input = *elem;
290
291 scope.register(Instruction::new(
292 Plane::ExclusiveSum(UnaryOperator { input }),
293 out,
294 ));
295
296 output.into()
297 }
298}
299
300pub fn plane_prod<E: CubePrimitive>(_elem: E) -> E {
302 unexpanded!()
303}
304
305pub mod plane_prod {
307 use super::*;
308
309 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
311 let elem: ManagedVariable = elem.into();
312 let output = scope.create_local(elem.ty);
313
314 let out = *output;
315 let input = *elem;
316
317 scope.register(Instruction::new(Plane::Prod(UnaryOperator { input }), out));
318
319 output.into()
320 }
321}
322
323#[allow(unused_variables)]
330pub fn plane_inclusive_prod<E: CubePrimitive>(value: E) -> E {
331 unexpanded!()
332}
333
334pub mod plane_inclusive_prod {
336 use super::*;
337
338 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
340 let elem: ManagedVariable = elem.into();
341 let output = scope.create_local(elem.ty);
342
343 let out = *output;
344 let input = *elem;
345
346 scope.register(Instruction::new(
347 Plane::InclusiveProd(UnaryOperator { input }),
348 out,
349 ));
350
351 output.into()
352 }
353}
354
355#[allow(unused_variables)]
363pub fn plane_exclusive_prod<E: CubePrimitive>(value: E) -> E {
364 unexpanded!()
365}
366
367pub mod plane_exclusive_prod {
369 use super::*;
370
371 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
373 let elem: ManagedVariable = elem.into();
374 let output = scope.create_local(elem.ty);
375
376 let out = *output;
377 let input = *elem;
378
379 scope.register(Instruction::new(
380 Plane::ExclusiveProd(UnaryOperator { input }),
381 out,
382 ));
383
384 output.into()
385 }
386}
387
388pub fn plane_max<E: CubePrimitive>(_elem: E) -> E {
390 unexpanded!()
391}
392
393pub mod plane_max {
395 use super::*;
396
397 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
399 let elem: ManagedVariable = elem.into();
400 let output = scope.create_local(elem.ty);
401
402 let out = *output;
403 let input = *elem;
404
405 scope.register(Instruction::new(Plane::Max(UnaryOperator { input }), out));
406
407 output.into()
408 }
409}
410
411pub fn plane_min<E: CubePrimitive>(_elem: E) -> E {
413 unexpanded!()
414}
415
416pub mod plane_min {
418 use super::*;
419
420 pub fn expand<E: CubePrimitive>(scope: &mut Scope, elem: NativeExpand<E>) -> NativeExpand<E> {
422 let elem: ManagedVariable = elem.into();
423 let output = scope.create_local(elem.ty);
424
425 let out = *output;
426 let input = *elem;
427
428 scope.register(Instruction::new(Plane::Min(UnaryOperator { input }), out));
429
430 output.into()
431 }
432}
433
434pub fn plane_all(_elem: bool) -> bool {
436 unexpanded!()
437}
438
439pub mod plane_all {
441
442 use super::*;
443
444 pub fn expand(scope: &mut Scope, elem: NativeExpand<bool>) -> NativeExpand<bool> {
446 let elem: ManagedVariable = elem.into();
447 let output = scope.create_local(elem.ty);
448
449 let out = *output;
450 let input = *elem;
451
452 scope.register(Instruction::new(Plane::All(UnaryOperator { input }), out));
453
454 output.into()
455 }
456}
457
458pub fn plane_any(_elem: bool) -> bool {
460 unexpanded!()
461}
462
463pub mod plane_any {
465
466 use super::*;
467
468 pub fn expand(scope: &mut Scope, elem: NativeExpand<bool>) -> NativeExpand<bool> {
470 let elem: ManagedVariable = elem.into();
471 let output = scope.create_local(elem.ty);
472
473 let out = *output;
474 let input = *elem;
475
476 scope.register(Instruction::new(Plane::Any(UnaryOperator { input }), out));
477
478 output.into()
479 }
480}
481
482pub fn plane_ballot(_elem: bool) -> Vector<u32, Const<4>> {
488 unexpanded!()
489}
490
491pub mod plane_ballot {
493 use cubecl_ir::UIntKind;
494
495 use super::*;
496
497 pub fn expand(
499 scope: &mut Scope,
500 elem: NativeExpand<bool>,
501 ) -> NativeExpand<Vector<u32, Const<4>>> {
502 let elem: ManagedVariable = elem.into();
503 let out_item = Type::scalar(ElemType::UInt(UIntKind::U32)).with_vector_size(4);
504 let output = scope.create_local(out_item);
505
506 let out = *output;
507 let input = *elem;
508
509 scope.register(Instruction::new(
510 Plane::Ballot(UnaryOperator { input }),
511 out,
512 ));
513
514 output.into()
515 }
516}