Skip to content

Commit

Permalink
fix leaky relu grad bug (#7634)
Browse files Browse the repository at this point in the history
Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
  • Loading branch information
2 people authored and marigoold committed Mar 15, 2022
1 parent d8a4da9 commit 0b2779d
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions oneflow/user/kernels/activation_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ struct LeakyReluFunctor {
template<typename T>
struct LeakyReluGradFunctor {
OF_DEVICE_FUNC explicit LeakyReluGradFunctor(float alpha) : alpha(alpha) {}
OF_DEVICE_FUNC T operator()(T x, T dy) const {
if (alpha > 0) {
return dy > 0 ? dy : dy * alpha;
} else {
return (x > 0) ? dy : dy * alpha;
}
}
OF_DEVICE_FUNC T operator()(T x, T dy) const { return (x > 0) ? dy : dy * alpha; }
const T alpha;
};

Expand Down

0 comments on commit 0b2779d

Please sign in to comment.