mirror of
https://github.com/huggingface/candle.git
synced 2025-06-18 19:47:12 +00:00
[nn] Move the Embedding and Activation parts. (#116)
* Share the Embedding and Activation parts. * Tweak some activations.
This commit is contained in:
18
candle-nn/src/activation.rs
Normal file
18
candle-nn/src/activation.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use candle::Tensor;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Activation {
|
||||
Gelu,
|
||||
Relu,
|
||||
Elu(f64),
|
||||
}
|
||||
|
||||
impl Activation {
|
||||
pub fn forward(&self, xs: &Tensor) -> candle::Result<Tensor> {
|
||||
match self {
|
||||
Self::Gelu => xs.gelu(),
|
||||
Self::Relu => xs.relu(),
|
||||
&Self::Elu(alpha) => xs.elu(alpha),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user