MCPcopy Create free account
hub / github.com/evilsocket/cake / silu

Method silu

cake-core/src/backends/cpu/mod.rs:300–312  ·  view source on GitHub ↗
(&self, x: &Tensor)

Source from the content-addressed store, hash-verified

298 }
299
300 fn silu(&self, x: &Tensor) -> Result<Tensor> {
301 if x.dtype() == DType::F32 {
302 let data = x.contiguous()?.flatten_all()?.to_vec1::<f32>()?;
303 let shape = x.dims();
304 let mut out = data;
305 for v in out.iter_mut() {
306 let x = *v;
307 *v = x / (1.0 + (-x).exp());
308 }
309 return Tensor::from_vec(out, shape, x.device());
310 }
311 candle_nn::ops::silu(x)
312 }
313
314 fn f8e4m3_to_f32(&self, x: &Tensor) -> Result<Tensor> {
315 x.to_dtype(DType::F32)

Callers 12

siluFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forward_with_maskMethod · 0.45
forwardMethod · 0.45
causal_conv1d_seqMethod · 0.45
forwardMethod · 0.45
forward_fastMethod · 0.45
forwardMethod · 0.45
test_silu_shapeFunction · 0.45
test_silu_zero_is_zeroFunction · 0.45
test_silu_matches_candleFunction · 0.45

Calls 3

siluFunction · 0.85
dtypeMethod · 0.80
deviceMethod · 0.45

Tested by 3

test_silu_shapeFunction · 0.36
test_silu_zero_is_zeroFunction · 0.36
test_silu_matches_candleFunction · 0.36