cubecl_core/frontend/element/
bool.rs1use cubecl_ir::{ExpandElement, Scope};
2
3use crate::frontend::{CubePrimitive, CubeType};
4use crate::ir::Elem;
5
6use super::{ExpandElementBaseInit, ExpandElementTyped, Init, IntoRuntime, init_expand_element};
7
8pub trait BoolOps {
10 #[allow(clippy::new_ret_no_self)]
11 fn new(value: bool) -> bool {
12 value
13 }
14 fn __expand_new(
15 _scope: &mut Scope,
16 value: ExpandElementTyped<bool>,
17 ) -> ExpandElementTyped<bool> {
18 ExpandElement::Plain(Elem::Bool.from_constant(*value.expand)).into()
19 }
20}
21
22impl BoolOps for bool {}
23
24impl CubeType for bool {
25 type ExpandType = ExpandElementTyped<Self>;
26}
27
28impl CubePrimitive for bool {
29 fn as_elem_native() -> Option<Elem> {
30 Some(Elem::Bool)
31 }
32}
33
34impl IntoRuntime for bool {
35 fn __expand_runtime_method(self, scope: &mut Scope) -> ExpandElementTyped<Self> {
36 let expand: ExpandElementTyped<Self> = self.into();
37 Init::init(expand, scope)
38 }
39}
40
41impl ExpandElementBaseInit for bool {
42 fn init_elem(scope: &mut Scope, elem: ExpandElement) -> ExpandElement {
43 init_expand_element(scope, elem)
44 }
45}