use cubecl_ir::ManagedVariable;
use super::{CubePrimitive, Vector};
use crate::prelude::*;
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) -> NativeExpand<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: NativeExpand<E>,
id: u32,
) -> NativeExpand<E> {
let output = scope.create_local(value.expand.ty);
let out = *output;
let lhs = *value.expand;
let rhs = id.into();
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: NativeExpand<E>,
src_lane: NativeExpand<u32>,
) -> NativeExpand<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: NativeExpand<E>,
mask: NativeExpand<u32>,
) -> NativeExpand<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: NativeExpand<E>,
delta: NativeExpand<u32>,
) -> NativeExpand<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: NativeExpand<E>,
delta: NativeExpand<u32>,
) -> NativeExpand<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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<E>) -> NativeExpand<E> {
let elem: ManagedVariable = 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: NativeExpand<bool>) -> NativeExpand<bool> {
let elem: ManagedVariable = 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: NativeExpand<bool>) -> NativeExpand<bool> {
let elem: ManagedVariable = 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) -> Vector<u32, Const<4>> {
unexpanded!()
}
pub mod plane_ballot {
use cubecl_ir::UIntKind;
use super::*;
pub fn expand(
scope: &mut Scope,
elem: NativeExpand<bool>,
) -> NativeExpand<Vector<u32, Const<4>>> {
let elem: ManagedVariable = elem.into();
let out_item = Type::scalar(ElemType::UInt(UIntKind::U32)).with_vector_size(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()
}
}