use crate::error::Result;
use crate::runtime::Runtime;
use crate::tensor::Tensor;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum GemmActivation {
None,
ReLU,
GELU,
SiLU,
Sigmoid,
Tanh,
}
impl GemmActivation {
pub fn code(self) -> u32 {
match self {
Self::None => 0,
Self::ReLU => 1,
Self::GELU => 2,
Self::SiLU => 3,
Self::Sigmoid => 4,
Self::Tanh => 5,
}
}
}
pub trait GemmEpilogueOps<R: Runtime> {
fn matmul_bias_activation(
&self,
a: &Tensor<R>,
b: &Tensor<R>,
bias: &Tensor<R>,
activation: GemmActivation,
) -> Result<Tensor<R>>;
fn matmul_bias_residual(
&self,
a: &Tensor<R>,
b: &Tensor<R>,
bias: &Tensor<R>,
residual: &Tensor<R>,
) -> Result<Tensor<R>>;
fn matmul_bias_activation_bwd(
&self,
grad: &Tensor<R>,
a: &Tensor<R>,
b: &Tensor<R>,
bias: &Tensor<R>,
activation: GemmActivation,
) -> Result<(Tensor<R>, Tensor<R>, Tensor<R>)>;
}