Skip to content

Commit 16df359

Browse files
StrycekSimonrobert-kalmar
authored andcommitted
NXP backend: Make setUpClass placement consistent across unit tests
1 parent c9089a2 commit 16df359

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

backends/nxp/tests/ir/converter/node_converter/test_tanh_converter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
class TestTanhConverter(unittest.TestCase):
2828
__test__ = False # Prevent interfering with PyTest tests
2929

30+
@classmethod
31+
def setUpClass(cls):
32+
torch.manual_seed(23)
33+
np.random.seed(23)
34+
3035
@parameterized.expand(
3136
input=[
3237
(
@@ -78,8 +83,3 @@ def test_conv_tanh(
7883
input_data=input_data,
7984
atol=2.0,
8085
)
81-
82-
@classmethod
83-
def setUpClass(cls):
84-
torch.manual_seed(23)
85-
np.random.seed(23)

backends/nxp/tests/test_per_channel_conversion.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ def get_anchors(
103103
class TestPerChannelConversion(unittest.TestCase):
104104
__test__ = False # Prevent interfering with PyTest tests
105105

106+
@classmethod
107+
def setUpClass(cls):
108+
torch.manual_seed(25)
109+
np.random.seed(25)
110+
106111
def test_per_channel_convolution(self):
107112
with kgb.spy_on(
108113
EdgeProgramToIRConverter.convert_program, call_original=True
@@ -146,8 +151,3 @@ def test_per_channel_convolution(self):
146151
"quantized_decomposed.dequantize_per_channel.default"
147152
)
148153
assert nodes[10].name == "aten_convolution_default"
149-
150-
@classmethod
151-
def setUpClass(cls):
152-
torch.manual_seed(25)
153-
np.random.seed(25)

backends/nxp/tests/test_removing_dead_code.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def forward(self, x):
3333
class TestRemovingDeadCode(unittest.TestCase):
3434
__test__ = False # Prevent interfering with PyTest tests
3535

36+
@classmethod
37+
def setUpClass(cls):
38+
torch.manual_seed(23)
39+
np.random.seed(23)
40+
3641
def test_removing_dead_code(self):
3742
input_shape = (42,)
3843
example_inputs = (torch.ones(input_shape),)
@@ -55,8 +60,3 @@ def test_removing_dead_code(self):
5560
assert not any(
5661
"add" in str(node.target) for node in exir_program_aten_quant.graph.nodes
5762
)
58-
59-
@classmethod
60-
def setUpClass(cls):
61-
torch.manual_seed(23)
62-
np.random.seed(23)

0 commit comments

Comments
 (0)