Skip to content

Commit 537dd20

Browse files
committed
Try fix
1 parent 3753bae commit 537dd20

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests_pytest/pytorch_tests/e2e_tests/test_exporter.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
QuantizationConfigOptions, OpQuantizationConfig, Signedness, TargetPlatformCapabilities
1515

1616

17+
def set_seed(seed: int = 42):
18+
# Set seed for Python random
19+
random.seed(seed)
20+
21+
# Set seed for NumPy
22+
np.random.seed(seed)
23+
24+
# Set seed for PyTorch
25+
torch.manual_seed(seed)
26+
torch.cuda.manual_seed(seed)
27+
torch.cuda.manual_seed_all(seed) # if you are using multi-GPU
28+
29+
# Ensure deterministic behavior in PyTorch (optional but recommended)
30+
torch.backends.cudnn.deterministic = True
31+
torch.backends.cudnn.benchmark = False
32+
33+
1734
def rmse(x, y):
1835
return np.sqrt(np.power(x - y, 2).mean())
1936

@@ -140,6 +157,7 @@ def forward(self, x):
140157

141158
class TestExporter:
142159
def setup_method(self):
160+
set_seed(0)
143161
self.in_channels = 3
144162
self.out_channels = 4
145163
self.onnx_file = f"./tmp_model_{np.random.randint(1e10)}.onnx"

0 commit comments

Comments
 (0)