Fix activations being all the same module (#19728)

This commit is contained in:
Sylvain Gugger
2022-10-18 11:56:45 -04:00
committed by GitHub
parent 14fe3e0410
commit fb0bd7b7a8
2 changed files with 31 additions and 14 deletions

View File

@@ -63,3 +63,11 @@ class TestActivations(unittest.TestCase):
get_activation("bogus")
with self.assertRaises(KeyError):
get_activation(None)
def test_activations_are_distinct_objects(self):
act1 = get_activation("gelu")
act1.a = 1
act2 = get_activation("gelu")
self.assertEqual(act1.a, 1)
with self.assertRaises(AttributeError):
_ = act2.a