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