提交 67d33303 编写于 作者: M Megvii Engine Team

feat(mge): remove fast_tanh

GitOrigin-RevId: 7ad5f7ecce158c471920ffc62e700ee726029077
上级 78d21894
......@@ -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
......
......@@ -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)
......
......@@ -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")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册