diff --git a/imperative/python/megengine/functional/elemwise.py b/imperative/python/megengine/functional/elemwise.py index 8757b77645a2c9c15ed9ee91a53bf83bfb766c2c..3b71291c83d77bec501797cbcb16e04a640a8b20 100644 --- a/imperative/python/megengine/functional/elemwise.py +++ b/imperative/python/megengine/functional/elemwise.py @@ -33,7 +33,6 @@ __all__ = [ "equal", "exp", "expm1", - "fast_tanh", "floor", "floor_div", "greater", @@ -369,15 +368,6 @@ def atanh(x): return log1p(2 * x / (1 - x)) / 2 -def fast_tanh(x): - r"""Element-wise `fast tanh`; this is an approximation: - - .. math:: - \text{fast_tanh}(x) = x * (27. + x * x) / (27. + 9. * x * x) - """ - return _elwise(x, mode="fast_tanh") - - # bit-twiddling functions diff --git a/imperative/python/megengine/module/elemwise.py b/imperative/python/megengine/module/elemwise.py index 3542359d633da9cc82c6c135ce973367b40a9f5a..9bc05fbfc0c145cc0a3de3ffad898630ca85f324 100644 --- a/imperative/python/megengine/module/elemwise.py +++ b/imperative/python/megengine/module/elemwise.py @@ -34,7 +34,7 @@ class Elemwise(Module): * "EXP": exp(x) * "TANH": tanh(x) * "FUSE_MUL_ADD3": x * y + z - * "FAST_TANH": fast_tanh(x) + * "FAST_TANH": x * (27. + x * x) / (27. + 9. * x * x) * "NEGATE": -x * "ACOS": acos(x) * "ASIN": asin(x) diff --git a/imperative/python/test/unit/functional/test_elemwise.py b/imperative/python/test/unit/functional/test_elemwise.py index f0b51a56f221902a031f2f1939c7fdcb24628a8b..30421dd8ca9910ba09958bff6499758d9b3efc0f 100644 --- a/imperative/python/test/unit/functional/test_elemwise.py +++ b/imperative/python/test/unit/functional/test_elemwise.py @@ -113,14 +113,6 @@ def test_atanh(): np.testing.assert_almost_equal(y_np, y_mge, decimal=5) -def test_fast_tanh(): - np.random.seed(42) - x = np.random.randn(100).astype("float32") - y_np = x * (27.0 + x * x) / (27.0 + 9.0 * x * x) - y_mge = F.fast_tanh(tensor(x)).numpy() - np.testing.assert_almost_equal(y_np, y_mge, decimal=6) - - def test_hswish(): np.random.seed(42) x = np.random.randn(100).astype("float32")