Skip to content

Commit e675c33

Browse files
janeyx99pytorchmergebot
authored andcommitted
[onnx] have all classes that call setUp inherit from common_utils.setUp (pytorch#79543)
The remaining one is `class _TestONNXRuntime:`, which intentionally doesn't want to inherit from anything, so I left it alone. Pull Request resolved: pytorch#79543 Approved by: https://github.com/malfet
1 parent 9705fb0 commit e675c33

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

test/onnx/test_pytorch_onnx_caffe2.py

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class TestCaffe2Backend_opset9(TestCase):
135135
embed_params = False
136136

137137
def setUp(self):
138+
# the following should ideally be super().setUp(), https://github.com/pytorch/pytorch/issues/79630
139+
TestCase.setUp(self)
138140
torch.manual_seed(0)
139141
if torch.cuda.is_available():
140142
torch.cuda.manual_seed_all(0)

test/onnx/test_pytorch_onnx_onnxruntime.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,10 @@ class _TestONNXRuntime:
159159
keep_initializers_as_inputs = True # For IR version 3 type export.
160160

161161
def setUp(self):
162-
torch.manual_seed(0)
162+
set_rng_seed(0)
163163
onnxruntime.set_seed(0)
164164
if torch.cuda.is_available():
165165
torch.cuda.manual_seed_all(0)
166-
np.random.seed(seed=0)
167166
os.environ["ALLOW_RELEASED_ONNX_OPSET_ONLY"] = "0"
168167
self.is_script_test_enabled = True
169168

test/onnx/test_verification.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Owner(s): ["module: onnx"]
22

3-
import unittest
4-
53
import torch
64
from torch.onnx import _experimental, verification
5+
from torch.testing._internal import common_utils
76

87

9-
class TestVerification(unittest.TestCase):
8+
class TestVerification(common_utils.TestCase):
109
def setUp(self) -> None:
10+
super().setUp()
1111
torch.manual_seed(0)
1212
if torch.cuda.is_available():
1313
torch.cuda.manual_seed_all(0)

0 commit comments

Comments
 (0)