From ebff15d74394b8549a5af0f5f772073a928b5a3a Mon Sep 17 00:00:00 2001 From: abhi-ort <109558862+abhi-ort@users.noreply.github.com> Date: Thu, 25 Aug 2022 10:09:02 -0700 Subject: [PATCH] Pinning manual seed (#12714) --- orttraining/orttraining/eager/test/ort_ops.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/orttraining/orttraining/eager/test/ort_ops.py b/orttraining/orttraining/eager/test/ort_ops.py index 22e4787ee5..8f8c942666 100644 --- a/orttraining/orttraining/eager/test/ort_ops.py +++ b/orttraining/orttraining/eager/test/ort_ops.py @@ -221,6 +221,11 @@ class OrtOpTests(unittest.TestCase): ] ) def test_softmax_grad(self, input_shape, dim): + # The 1% tolerance used by this test is not working for any random inputs + # and on the other hand it is tough to come up with some tolerance value + # that works for any random input values. So, pin the seed value so that the + # random inputs used by this test are always the same. + torch.manual_seed(5) device = self.get_device() cpu_tensor = torch.nn.Parameter(torch.rand(input_shape)) ort_tensor = torch.nn.Parameter(cpu_tensor.detach().clone().to(device)) @@ -243,6 +248,11 @@ class OrtOpTests(unittest.TestCase): ] ) def test_logsoftmax_grad(self, input_shape, dim): + # The 5% tolerance used by this test is not working for any random inputs + # and on the other hand it is tough to come up with some tolerance value + # that works for any random input values. So, pin the seed value so that the + # random inputs used by this test are always the same. + torch.manual_seed(5) device = self.get_device() cpu_tensor = torch.nn.Parameter(torch.rand(input_shape)) ort_tensor = torch.nn.Parameter(cpu_tensor.detach().clone().to(device))