"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "ce37b8e4819142171b61558e64f7dcb0286e9937"
Unverified Commit 1e53faeb authored by Lysandre Debut's avatar Lysandre Debut Committed by GitHub
Browse files

Fix gelu test for torch 1.10 (#14167)

parent 8ddbfe97
...@@ -29,8 +29,8 @@ class TestActivations(unittest.TestCase): ...@@ -29,8 +29,8 @@ class TestActivations(unittest.TestCase):
def test_gelu_versions(self): def test_gelu_versions(self):
x = torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]) x = torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100])
torch_builtin = get_activation("gelu") torch_builtin = get_activation("gelu")
self.assertTrue(torch.eq(_gelu_python(x), torch_builtin(x)).all().item()) self.assertTrue(torch.allclose(_gelu_python(x), torch_builtin(x)))
self.assertFalse(torch.eq(_gelu_python(x), gelu_new(x)).all().item()) self.assertFalse(torch.allclose(_gelu_python(x), gelu_new(x)))
def test_get_activation(self): def test_get_activation(self):
get_activation("swish") get_activation("swish")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment