use crate::{Matrix, Result};
use super::super::{Module, ModuleRegistry, matrix};
pub struct Relu {
registry: ModuleRegistry,
}
impl Relu {
pub const fn new() -> Self {
Self {
registry: ModuleRegistry::new(),
}
}
pub fn forward(&self, input: &Matrix) -> Result<Matrix> {
matrix::relu(input)
}
}
impl Default for Relu {
fn default() -> Self {
Self::new()
}
}
impl Module for Relu {
fn forward(&self, input: &Matrix) -> Result<Matrix> {
Relu::forward(self, input)
}
fn registry(&self) -> &ModuleRegistry {
&self.registry
}
}
pub struct Gelu {
registry: ModuleRegistry,
}
impl Gelu {
pub const fn new() -> Self {
Self {
registry: ModuleRegistry::new(),
}
}
pub fn forward(&self, input: &Matrix) -> Result<Matrix> {
matrix::gelu(input)
}
}
impl Default for Gelu {
fn default() -> Self {
Self::new()
}
}
impl Module for Gelu {
fn forward(&self, input: &Matrix) -> Result<Matrix> {
Gelu::forward(self, input)
}
fn registry(&self) -> &ModuleRegistry {
&self.registry
}
}
pub struct Silu {
registry: ModuleRegistry,
}
impl Silu {
pub const fn new() -> Self {
Self {
registry: ModuleRegistry::new(),
}
}
pub fn forward(&self, input: &Matrix) -> Result<Matrix> {
matrix::silu(input)
}
}
impl Default for Silu {
fn default() -> Self {
Self::new()
}
}
impl Module for Silu {
fn forward(&self, input: &Matrix) -> Result<Matrix> {
Silu::forward(self, input)
}
fn registry(&self) -> &ModuleRegistry {
&self.registry
}
}