(&self, x: &Tensor)
| 285 | } |
| 286 | |
| 287 | fn sigmoid(&self, x: &Tensor) -> Result<Tensor> { |
| 288 | if x.dtype() == DType::F32 { |
| 289 | let data = x.contiguous()?.flatten_all()?.to_vec1::<f32>()?; |
| 290 | let shape = x.dims(); |
| 291 | let mut out = data; |
| 292 | for v in out.iter_mut() { |
| 293 | *v = 1.0 / (1.0 + (-*v).exp()); |
| 294 | } |
| 295 | return Tensor::from_vec(out, shape, x.device()); |
| 296 | } |
| 297 | candle_nn::ops::sigmoid(x) |
| 298 | } |
| 299 | |
| 300 | fn silu(&self, x: &Tensor) -> Result<Tensor> { |
| 301 | if x.dtype() == DType::F32 { |