use ruda_tensor::{bf16, f16};
use ruda_kernel::dsl::{
flex32,
prelude::{Float, Int},
};
use rublas::kernel_ir::definition::{MatmulPrecision, MatrixPrecision};
use ruprim::reduce::ReducePrecision;
pub use ruda_kernel::tensor::element::TensorElement;
pub trait MatmulElement:
TensorElement + MatmulPrecision<Acc: MatrixPrecision<Global: TensorElement>>
{
}
pub trait FloatElement: MatmulElement + Float {}
pub trait IntElement:
MatmulElement + Int + ReducePrecision<EI: TensorElement, EA: TensorElement>
{
}
pub trait BoolElement: TensorElement + Int {
fn true_val() -> Self {
Self::from_int(1)
}
fn false_val() -> Self {
Self::from_int(0)
}
fn new_bool(val: bool) -> Self {
match val {
true => Self::true_val(),
false => Self::false_val(),
}
}
}
impl FloatElement for f64 {}
impl FloatElement for f32 {}
impl FloatElement for flex32 {}
impl FloatElement for bf16 {}
impl FloatElement for f16 {}
impl IntElement for i64 {}
impl IntElement for i32 {}
impl IntElement for i16 {}
impl IntElement for i8 {}
impl IntElement for u64 {}
impl IntElement for u32 {}
impl IntElement for u16 {}
impl IntElement for u8 {}
impl BoolElement for u8 {}
impl BoolElement for u32 {}
impl MatmulElement for f64 {}
impl MatmulElement for f32 {}
impl MatmulElement for flex32 {}
impl MatmulElement for bf16 {}
impl MatmulElement for f16 {}
impl MatmulElement for i64 {}
impl MatmulElement for i32 {}
impl MatmulElement for i16 {}
impl MatmulElement for i8 {}
impl MatmulElement for u64 {}
impl MatmulElement for u32 {}
impl MatmulElement for u16 {}
impl MatmulElement for u8 {}