use cubecl_ir::ExpandElement;
use super::{CubePrimitive, Line};
use crate::prelude::ExpandElementTyped;
use crate::{
ir::{ElemType, Instruction, Plane, Scope, Type, UnaryOperator},
unexpanded,
};
pub fn plane_elect() -> bool {
unexpanded!()
}
pub mod plane_elect {
use super::*;
pub fn expand(scope: &mut Scope) -> ExpandElementTyped<bool> {
let output = scope.create_local(Type::scalar(ElemType::Bool));
let out = *output;
scope.register(Instruction::new(Plane::Elect, out));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_broadcast<E: CubePrimitive>(value: E, index: u32) -> E {
unexpanded!()
}
pub mod plane_broadcast {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
value: ExpandElementTyped<E>,
id: ExpandElementTyped<u32>,
) -> ExpandElementTyped<E> {
let output = scope.create_local(value.expand.ty);
let out = *output;
let lhs = *value.expand;
let rhs = *id.expand;
scope.register(Instruction::new(
Plane::Broadcast(crate::ir::BinaryOperator { lhs, rhs }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_shuffle<E: CubePrimitive>(value: E, src_lane: u32) -> E {
unexpanded!()
}
pub mod plane_shuffle {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
value: ExpandElementTyped<E>,
src_lane: ExpandElementTyped<u32>,
) -> ExpandElementTyped<E> {
let output = scope.create_local(value.expand.ty);
let out = *output;
let lhs = *value.expand;
let rhs = *src_lane.expand;
scope.register(Instruction::new(
Plane::Shuffle(crate::ir::BinaryOperator { lhs, rhs }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_shuffle_xor<E: CubePrimitive>(value: E, mask: u32) -> E {
unexpanded!()
}
pub mod plane_shuffle_xor {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
value: ExpandElementTyped<E>,
mask: ExpandElementTyped<u32>,
) -> ExpandElementTyped<E> {
let output = scope.create_local(value.expand.ty);
let out = *output;
let lhs = *value.expand;
let rhs = *mask.expand;
scope.register(Instruction::new(
Plane::ShuffleXor(crate::ir::BinaryOperator { lhs, rhs }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_shuffle_up<E: CubePrimitive>(value: E, delta: u32) -> E {
unexpanded!()
}
pub mod plane_shuffle_up {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
value: ExpandElementTyped<E>,
delta: ExpandElementTyped<u32>,
) -> ExpandElementTyped<E> {
let output = scope.create_local(value.expand.ty);
let out = *output;
let lhs = *value.expand;
let rhs = *delta.expand;
scope.register(Instruction::new(
Plane::ShuffleUp(crate::ir::BinaryOperator { lhs, rhs }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_shuffle_down<E: CubePrimitive>(value: E, delta: u32) -> E {
unexpanded!()
}
pub mod plane_shuffle_down {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
value: ExpandElementTyped<E>,
delta: ExpandElementTyped<u32>,
) -> ExpandElementTyped<E> {
let output = scope.create_local(value.expand.ty);
let out = *output;
let lhs = *value.expand;
let rhs = *delta.expand;
scope.register(Instruction::new(
Plane::ShuffleDown(crate::ir::BinaryOperator { lhs, rhs }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_sum<E: CubePrimitive>(value: E) -> E {
unexpanded!()
}
pub mod plane_sum {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(Plane::Sum(UnaryOperator { input }), out));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_inclusive_sum<E: CubePrimitive>(value: E) -> E {
unexpanded!()
}
pub mod plane_inclusive_sum {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(
Plane::InclusiveSum(UnaryOperator { input }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_exclusive_sum<E: CubePrimitive>(value: E) -> E {
unexpanded!()
}
pub mod plane_exclusive_sum {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(
Plane::ExclusiveSum(UnaryOperator { input }),
out,
));
output.into()
}
}
pub fn plane_prod<E: CubePrimitive>(_elem: E) -> E {
unexpanded!()
}
pub mod plane_prod {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(Plane::Prod(UnaryOperator { input }), out));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_inclusive_prod<E: CubePrimitive>(value: E) -> E {
unexpanded!()
}
pub mod plane_inclusive_prod {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(
Plane::InclusiveProd(UnaryOperator { input }),
out,
));
output.into()
}
}
#[allow(unused_variables)]
pub fn plane_exclusive_prod<E: CubePrimitive>(value: E) -> E {
unexpanded!()
}
pub mod plane_exclusive_prod {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(
Plane::ExclusiveProd(UnaryOperator { input }),
out,
));
output.into()
}
}
pub fn plane_max<E: CubePrimitive>(_elem: E) -> E {
unexpanded!()
}
pub mod plane_max {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(Plane::Max(UnaryOperator { input }), out));
output.into()
}
}
pub fn plane_min<E: CubePrimitive>(_elem: E) -> E {
unexpanded!()
}
pub mod plane_min {
use super::*;
pub fn expand<E: CubePrimitive>(
scope: &mut Scope,
elem: ExpandElementTyped<E>,
) -> ExpandElementTyped<E> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(Plane::Min(UnaryOperator { input }), out));
output.into()
}
}
pub fn plane_all(_elem: bool) -> bool {
unexpanded!()
}
pub mod plane_all {
use super::*;
pub fn expand(scope: &mut Scope, elem: ExpandElementTyped<bool>) -> ExpandElementTyped<bool> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(Plane::All(UnaryOperator { input }), out));
output.into()
}
}
pub fn plane_any(_elem: bool) -> bool {
unexpanded!()
}
pub mod plane_any {
use super::*;
pub fn expand(scope: &mut Scope, elem: ExpandElementTyped<bool>) -> ExpandElementTyped<bool> {
let elem: ExpandElement = elem.into();
let output = scope.create_local(elem.ty);
let out = *output;
let input = *elem;
scope.register(Instruction::new(Plane::Any(UnaryOperator { input }), out));
output.into()
}
}
pub fn plane_ballot(_elem: bool) -> Line<u32> {
unexpanded!()
}
pub mod plane_ballot {
use cubecl_ir::UIntKind;
use super::*;
pub fn expand(
scope: &mut Scope,
elem: ExpandElementTyped<bool>,
) -> ExpandElementTyped<Line<u32>> {
let elem: ExpandElement = elem.into();
let out_item = Type::scalar(ElemType::UInt(UIntKind::U32)).line(4);
let output = scope.create_local(out_item);
let out = *output;
let input = *elem;
scope.register(Instruction::new(
Plane::Ballot(UnaryOperator { input }),
out,
));
output.into()
}
}