Skip to content

Commit d8c29b0

Browse files
committed
silu: fix cpu df
1 parent a14b40b commit d8c29b0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

dfdx-core/src/tensor_ops/silu/cpu_kernel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ impl<F: num_traits::Float> UnaryDerivative<F> for super::SiLUKernelOp {
1515
#[inline(always)]
1616
fn df(&self, x: &F) -> F {
1717
let exp_nx = x.neg().exp();
18-
F::one() + exp_nx + *x * exp_nx / (F::one() + exp_nx).powi(2)
18+
(F::one() + exp_nx + *x * exp_nx) / (F::one() + exp_nx).powi(2)
1919
}
2020
}

dfdx-core/src/tensor_ops/silu/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod tests {
5656
let g = r.mean().backward();
5757
assert_close_to_literal!(
5858
g.get(&x),
59-
[1.635814, 0.70433396, 0.4, 0.31289828, 0.26906452]
59+
[-0.018156849, 0.014465898, 0.1, 0.1855341, 0.21815684]
6060
);
6161
}
6262
}

0 commit comments

Comments
 (0)