use crate::autograd::Variable;
use crate::tensor::Result;
use super::Module;
pub struct Identity;
impl Default for Identity {
fn default() -> Self {
Identity
}
}
impl Identity {
pub fn new() -> Self {
Self
}
}
impl Module for Identity {
fn name(&self) -> &str { "identity" }
fn forward(&self, input: &Variable) -> Result<Variable> {
Ok(input.clone())
}
}
pub struct ReLU;
impl Default for ReLU {
fn default() -> Self {
ReLU
}
}
impl ReLU {
pub fn new() -> Self {
Self
}
}
impl Module for ReLU {
fn name(&self) -> &str { "relu" }
fn forward(&self, input: &Variable) -> Result<Variable> {
input.relu()
}
}
pub struct Sigmoid;
impl Default for Sigmoid {
fn default() -> Self {
Sigmoid
}
}
impl Sigmoid {
pub fn new() -> Self {
Self
}
}
impl Module for Sigmoid {
fn name(&self) -> &str { "sigmoid" }
fn forward(&self, input: &Variable) -> Result<Variable> {
input.sigmoid()
}
}
pub struct Tanh;
impl Default for Tanh {
fn default() -> Self {
Tanh
}
}
impl Tanh {
pub fn new() -> Self {
Self
}
}
impl Module for Tanh {
fn name(&self) -> &str { "tanh" }
fn forward(&self, input: &Variable) -> Result<Variable> {
input.tanh()
}
}
pub struct GELU;
impl Default for GELU {
fn default() -> Self {
GELU
}
}
impl GELU {
pub fn new() -> Self {
Self
}
}
impl Module for GELU {
fn name(&self) -> &str { "gelu" }
fn forward(&self, input: &Variable) -> Result<Variable> {
input.gelu()
}
}
pub struct SiLU;
impl Default for SiLU {
fn default() -> Self {
SiLU
}
}
impl SiLU {
pub fn new() -> Self {
Self
}
}
impl Module for SiLU {
fn name(&self) -> &str { "silu" }
fn forward(&self, input: &Variable) -> Result<Variable> {
input.silu()
}
}