From b37cf7dee49190fbadaab204198c757a140f9ce4 Mon Sep 17 00:00:00 2001 From: Henrik Holm <33653878+henholm@users.noreply.github.com> Date: Mon, 20 Dec 2021 15:25:34 +0100 Subject: [PATCH] Add 'with torch.no_grad()' to integration test forward pass (#14821) --- tests/test_modeling_deberta.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_modeling_deberta.py b/tests/test_modeling_deberta.py index cb11b3a521..0c769eb8e5 100644 --- a/tests/test_modeling_deberta.py +++ b/tests/test_modeling_deberta.py @@ -275,7 +275,8 @@ class DebertaModelIntegrationTest(unittest.TestCase): input_ids = torch.tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]) attention_mask = torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) - output = model(input_ids, attention_mask=attention_mask)[0] + with torch.no_grad(): + output = model(input_ids, attention_mask=attention_mask)[0] # compare the actual values for a slice. expected_slice = torch.tensor( [[[-0.5986, -0.8055, -0.8462], [1.4484, -0.9348, -0.8059], [0.3123, 0.0032, -1.4131]]]