Skip to content

Commit

Permalink
silu: fix cpu df
Browse files Browse the repository at this point in the history
  • Loading branch information
swfsql committed Feb 20, 2024
1 parent a14b40b commit d8c29b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dfdx-core/src/tensor_ops/silu/cpu_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ impl<F: num_traits::Float> UnaryDerivative<F> for super::SiLUKernelOp {
#[inline(always)]
fn df(&self, x: &F) -> F {
let exp_nx = x.neg().exp();
F::one() + exp_nx + *x * exp_nx / (F::one() + exp_nx).powi(2)
(F::one() + exp_nx + *x * exp_nx) / (F::one() + exp_nx).powi(2)
}
}
2 changes: 1 addition & 1 deletion dfdx-core/src/tensor_ops/silu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod tests {
let g = r.mean().backward();
assert_close_to_literal!(
g.get(&x),
[1.635814, 0.70433396, 0.4, 0.31289828, 0.26906452]
[-0.018156849, 0.014465898, 0.1, 0.1855341, 0.21815684]
);
}
}

0 comments on commit d8c29b0

Please sign in to comment.