cubecl_core/frontend/
base.rs1use cubecl_ir::Scope;
2
3use crate::frontend::{CubePrimitive, NativeExpand, init_mut_of_type};
4
5#[macro_export]
6macro_rules! unexpanded {
7 () => ({
8 panic!("Unexpanded Cube functions should not be called. ");
9 });
10 ($msg:expr) => ({
11 panic!($msg);
12 });
13 ($fmt:expr, $($arg:tt)*) => ({
14 panic!($fmt, $($arg)*);
15 });
16}
17
18#[macro_export]
19macro_rules! expand_error {
20 () => ({
21 panic!("An error occurred during kernel expansion");
22 });
23 ($msg:expr) => ({
24 panic!(concat!("An error occurred during kernel expansion:\n", $msg));
25 });
26 ($fmt:expr, $($arg:tt)*) => ({
27 panic!(concat!("An error occurred during kernel expansion:\n", $fmt), $($arg)*);
28 });
29}
30
31#[macro_export]
32macro_rules! expand_assert {
33 ($cond:expr) => ({
34 assert!($cond, "An error occurred during kernel expansion");
35 });
36 ($cond:expr, $msg:expr) => ({
37 assert!($cond, concat!("An error occurred during kernel expansion:\n", $msg));
38 });
39 ($cond:expr, $fmt:expr, $($arg:tt)*) => ({
40 assert!($cond, concat!("An error occurred during kernel expansion:\n", $fmt), $($arg)*);
41 });
42}
43
44#[macro_export]
45macro_rules! size {
46 ($name: ident) => {
47 $name
48 };
49}
50
51#[macro_export]
52macro_rules! define {
53 ($name: ident) => {
54 $name
55 };
56}
57
58pub fn unexpanded_value<T>() -> T {
59 unexpanded!()
60}
61
62pub fn uninit_local<T: CubePrimitive>(scope: &Scope) -> NativeExpand<T> {
66 init_mut_of_type(scope, T::__expand_as_type(scope)).into()
67}