diff --git a/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py b/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py index 011c565edf26ad..87c5c4791bb39d 100644 --- a/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py +++ b/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py @@ -34,7 +34,8 @@ def forward(self, input_shape): @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool3d(self, ie_device, precision, ir_version, input_shape, output_size): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(output_size), ie_device, precision, ir_version) @@ -64,7 +65,8 @@ def forward(self, input_tensor): @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool2d(self, ie_device, precision, ir_version, input_shape, output_size): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(output_size), ie_device, precision, ir_version) @@ -94,7 +96,8 @@ def forward(self, input_tensor): @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool1d(self, ie_device, precision, ir_version, input_shape, output_size): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(output_size), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py b/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py index 8b6dfe51973c6a..6252b595b3bedc 100644 --- a/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py +++ b/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py @@ -52,7 +52,8 @@ def forward(self, input_tensor): @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') def test_adaptive_max_pool3d(self, ie_device, precision, ir_version, input_shape, output_size, return_indices): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) @@ -97,7 +98,8 @@ def forward(self, input_tensor): @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') def test_adaptive_max_pool2d(self, ie_device, precision, ir_version, input_shape, output_size, return_indices): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) @@ -144,5 +146,6 @@ def forward(self, input_tensor): @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') def test_adaptive_max_pool1d(self, ie_device, precision, ir_version, input_shape, output_size, return_indices): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_add.py b/tests/layer_tests/pytorch_tests/test_add.py index dfd330f2480aca..a8662ff5ec8922 100644 --- a/tests/layer_tests/pytorch_tests/test_add.py +++ b/tests/layer_tests/pytorch_tests/test_add.py @@ -43,7 +43,8 @@ def forward2(self, lhs, rhs): @pytest.mark.precommit_fx_backend @pytest.mark.parametrize("op_type", ["add", "add_"]) def test_add(self, ie_device, precision, ir_version, alpha, input_shape_rhs, op_type): - self.input_rhs = np.random.random_sample(input_shape_rhs).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_rhs = rng.standard_normal(size=input_shape_rhs).astype(np.float32) self._test(*self.create_model(alpha, op_type), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_all.py b/tests/layer_tests/pytorch_tests/test_all.py index c33b8e93773ef7..2a4da2a6e90a60 100644 --- a/tests/layer_tests/pytorch_tests/test_all.py +++ b/tests/layer_tests/pytorch_tests/test_all.py @@ -37,12 +37,12 @@ def _prepare_input(self): return (self.input_tensor,) @pytest.mark.parametrize("input_shape, d_type", [ - (np.eye(5,5), np.int16), - (np.zeros((5, 5)), np.int16), - (np.zeros((9,8)) + 1, np.int16), - ([5, 9, 7], np.int16), - ([10, 13, 11], np.int16), - ([8, 7, 6, 5, 4], np.int16), + (np.eye(5,5), np.int64), + (np.zeros((5, 5)), np.int64), + (np.zeros((9,8)) + 1, np.int64), + ([5, 9, 7], np.int64), + ([10, 13, 11], np.int64), + ([8, 7, 6, 5, 4], np.int64), ([11, 11], np.uint8), ([7, 7], np.uint8) ]) @@ -57,12 +57,12 @@ def test_all_noparams(self, input_shape, d_type, ie_device, precision, ir_versio ie_device, precision, ir_version, trace_model=True, freeze_model=False) @pytest.mark.parametrize("input_shape, d_type", [ - (np.eye(5,5), np.int16), - (np.zeros((5, 5)), np.int16), - (np.zeros((9,8)) + 1, np.int16), - ([5, 9, 7], np.int16), - ([10, 13, 11], np.int16), - ([8, 7, 6, 5, 4], np.int16), + (np.eye(5,5), np.int64), + (np.zeros((5, 5)), np.int64), + (np.zeros((9,8)) + 1, np.int64), + ([5, 9, 7], np.int64), + ([10, 13, 11], np.int64), + ([8, 7, 6, 5, 4], np.int64), ([11, 11], np.uint8), ([7, 7], np.uint8) ]) diff --git a/tests/layer_tests/pytorch_tests/test_argsort.py b/tests/layer_tests/pytorch_tests/test_argsort.py index a9bbff1efae865..1b412c5d052a46 100644 --- a/tests/layer_tests/pytorch_tests/test_argsort.py +++ b/tests/layer_tests/pytorch_tests/test_argsort.py @@ -74,7 +74,8 @@ def forward(self, input_tensor): def test_argsort(self, tensor_stable_pair, descending, ie_device, precision, ir_version): input_shape, stable = tensor_stable_pair if type(input_shape) is list: - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) else: self.input_tensor = input_shape dims = len(self.input_tensor.shape) diff --git a/tests/layer_tests/pytorch_tests/test_floor_divide.py b/tests/layer_tests/pytorch_tests/test_floor_divide.py index dea36173004118..5a0643de2b4718 100644 --- a/tests/layer_tests/pytorch_tests/test_floor_divide.py +++ b/tests/layer_tests/pytorch_tests/test_floor_divide.py @@ -55,11 +55,13 @@ def forward(self, input_tensor, other_tensor): reason='Ticket - 122715') def test_floor_divide(self, input_tensor, other_tensor, ie_device, precision, ir_version): if type(input_tensor) is list: - self.input_tensor = np.random.random_sample(input_tensor).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_tensor).astype(np.float32) else: self.input_tensor = input_tensor if type(other_tensor) is list: - self.other_tensor = np.random.random_sample(other_tensor).astype(np.float32) + rng = np.random.default_rng(seed=14) + self.other_tensor = rng.standard_normal(size=other_tensor).astype(np.float32) else: self.other_tensor = other_tensor self._test(*self.create_model(), ie_device, precision, ir_version, trace_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_index_put_.py b/tests/layer_tests/pytorch_tests/test_index_put_.py index 12bfa39494f47b..008211500ca0f1 100644 --- a/tests/layer_tests/pytorch_tests/test_index_put_.py +++ b/tests/layer_tests/pytorch_tests/test_index_put_.py @@ -54,7 +54,8 @@ def forward(self, input_tensor, values): @pytest.mark.nightly @pytest.mark.precommit def test_index_put_single_indices(self, ie_device, precision, ir_version, input_data, indices, accumulate): - self.input_tensor = np.random.random_sample(input_data["input_shape"]).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_data["input_shape"]).astype(np.float32) self.values = input_data["values"] self._test(*self.create_model(indices, accumulate), ie_device, precision, ir_version) @@ -107,7 +108,8 @@ def forward(self, input_tensor, values): @pytest.mark.nightly @pytest.mark.precommit def test_index_put_many_indices(self, ie_device, precision, ir_version, input_data, indices, accumulate): - self.input_tensor = np.random.random_sample(input_data["input_shape"]).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_data["input_shape"]).astype(np.float32) self.values = input_data["values"] self._test(*self.create_model(indices, accumulate), ie_device, precision, ir_version) @@ -158,7 +160,8 @@ def forward(self, input_tensor, values, indices_0, indices_1): @pytest.mark.nightly @pytest.mark.precommit def test_nonzero_index_put_(self, ie_device, precision, ir_version, input_data, indices, accumulate): - self.input_tensor = np.random.random_sample(input_data["input_shape"]).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_data["input_shape"]).astype(np.float32) self.values = input_data["values"] for i in range(len(indices)): if type(indices[i]) is list: diff --git a/tests/layer_tests/pytorch_tests/test_len.py b/tests/layer_tests/pytorch_tests/test_len.py index a885754b923d85..063353bf27edfd 100644 --- a/tests/layer_tests/pytorch_tests/test_len.py +++ b/tests/layer_tests/pytorch_tests/test_len.py @@ -42,13 +42,15 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit def test_len(self, ie_device, precision, ir_version, input_tensor): - self.input_tensor = np.random.random_sample(input_tensor).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_tensor).astype(np.float32) self._test(*self.create_model(), ie_device, precision, ir_version) @pytest.mark.nightly @pytest.mark.precommit def test_len_int_list(self, ie_device, precision, ir_version, input_tensor): - self.input_tensor = np.random.random_sample(input_tensor).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_tensor).astype(np.float32) self._test(*self.create_model_int_list(), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_narrow.py b/tests/layer_tests/pytorch_tests/test_narrow.py index a1d94019abfa35..fc2280e86cec85 100644 --- a/tests/layer_tests/pytorch_tests/test_narrow.py +++ b/tests/layer_tests/pytorch_tests/test_narrow.py @@ -38,7 +38,8 @@ def forward(self, input_tensor, dim: int, start, length: int): @pytest.mark.nightly @pytest.mark.precommit def test_narrow(self, input_shape, dim, start, length, ie_device, precision, ir_version): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self.dim = dim self.start = start self.length = length diff --git a/tests/layer_tests/pytorch_tests/test_remainder.py b/tests/layer_tests/pytorch_tests/test_remainder.py index b5386363e58448..89a77c9be0ee0c 100644 --- a/tests/layer_tests/pytorch_tests/test_remainder.py +++ b/tests/layer_tests/pytorch_tests/test_remainder.py @@ -31,7 +31,8 @@ def forward(self, lhs, rhs): @pytest.mark.nightly @pytest.mark.precommit def test_remainder(self, ie_device, precision, ir_version, input_shape_rhs): - self.input_rhs = np.random.random_sample(input_shape_rhs).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_rhs = rng.standard_normal(size=input_shape_rhs).astype(np.float32) self._test(*self.create_model(), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_roi_align.py b/tests/layer_tests/pytorch_tests/test_roi_align.py index 8248a698de3674..458d364dac299b 100644 --- a/tests/layer_tests/pytorch_tests/test_roi_align.py +++ b/tests/layer_tests/pytorch_tests/test_roi_align.py @@ -54,7 +54,8 @@ def forward(self, input_tensor, rois): @pytest.mark.precommit def test_roi_align(self, ie_device, precision, ir_version, input_shape, boxes, output_size, spatial_scale, sampling_ratio, aligned): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self.boxes = boxes self._test(*self.create_model(output_size, spatial_scale, sampling_ratio, aligned), ie_device, precision, ir_version, trace_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_rsub.py b/tests/layer_tests/pytorch_tests/test_rsub.py index 96db1eb8039a3f..7fd019a09b42ab 100644 --- a/tests/layer_tests/pytorch_tests/test_rsub.py +++ b/tests/layer_tests/pytorch_tests/test_rsub.py @@ -42,9 +42,13 @@ def forward(self, x, y:int, alpha: float): @pytest.mark.precommit def test_rsub(self, ie_device, precision, ir_version, input_data): self.input_data = [] + seed = 13 + rng = np.random.default_rng(seed=13) for input in input_data: if type(input) is list: - self.input_data.append(np.random.random_sample(input).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input).astype(np.float32)) + seed += 1 else: self.input_data.append(input) self._test(*self.create_model(second_type="float"), ie_device, precision, ir_version) @@ -57,9 +61,12 @@ def test_rsub(self, ie_device, precision, ir_version, input_data): @pytest.mark.precommit def test_rsub(self, ie_device, precision, ir_version, input_data): self.input_data = [] + seed = 13 for input in input_data: if type(input) is list: - self.input_data.append(np.random.random_sample(input).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input).astype(np.float32)) + seed += 1 else: self.input_data.append(input) self._test(*self.create_model(second_type="int"), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_sort.py b/tests/layer_tests/pytorch_tests/test_sort.py index b3da50fdcad287..cc02733c41b959 100644 --- a/tests/layer_tests/pytorch_tests/test_sort.py +++ b/tests/layer_tests/pytorch_tests/test_sort.py @@ -81,7 +81,8 @@ def forward(self, input_tensor): def test_sort(self, input_shape, descending, stable, ie_device, precision, ir_version): self.input_tensor = [] if type(input_shape) is list: - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) else: self.input_tensor = input_shape dims = len(self.input_tensor.shape) diff --git a/tests/layer_tests/pytorch_tests/test_stack.py b/tests/layer_tests/pytorch_tests/test_stack.py index 8e7084e5fdb813..357b5d193ca903 100644 --- a/tests/layer_tests/pytorch_tests/test_stack.py +++ b/tests/layer_tests/pytorch_tests/test_stack.py @@ -39,9 +39,11 @@ def forward(self, x, y): @pytest.mark.nightly @pytest.mark.precommit def test_stack2D(self, input_shape, dim, ie_device, precision, ir_version): + rng_1 = np.random.default_rng(seed=1) + rng_2 = np.random.default_rng(seed=2) self.input_tensors = [ - np.random.random_sample(input_shape).astype(np.float32), - np.random.random_sample(input_shape).astype(np.float32), + rng_1.standard_normal(input_shape).astype(np.float32), + rng_2.standard_normal(input_shape).astype(np.float32), ] self._test(*self.create_model(dim), ie_device, precision, ir_version) @@ -78,9 +80,12 @@ def forward(self, x, y, z): @pytest.mark.nightly @pytest.mark.precommit def test_stack3D(self, input_shape, dim, ie_device, precision, ir_version): + rng_1 = np.random.default_rng(seed=1) + rng_2 = np.random.default_rng(seed=2) + rng_3 = np.random.default_rng(seed=3) self.input_tensors = [ - np.random.random_sample(input_shape).astype(np.float32), - np.random.random_sample(input_shape).astype(np.float32), - np.random.random_sample(input_shape).astype(np.float32) + rng_1.standard_normal(input_shape).astype(np.float32), + rng_2.standard_normal(input_shape).astype(np.float32), + rng_3.standard_normal(input_shape).astype(np.float32) ] self._test(*self.create_model(dim), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_sub.py b/tests/layer_tests/pytorch_tests/test_sub.py index 89711c8db6e653..9e42942a3467ef 100644 --- a/tests/layer_tests/pytorch_tests/test_sub.py +++ b/tests/layer_tests/pytorch_tests/test_sub.py @@ -51,8 +51,11 @@ def _forward_inplace(self, x, y, alpha: float): @pytest.mark.precommit def test_sub(self, ie_device, precision, ir_version, input_shapes, inplace): self.input_data = [] + seed = 13 for input_shape in input_shapes: - self.input_data.append(np.random.random_sample(input_shape).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input_shape).astype(np.float32)) + seed += 1 self._test(*self.create_model(inplace), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_topk.py b/tests/layer_tests/pytorch_tests/test_topk.py index a0420a836e7e5d..5adc4063bf2876 100644 --- a/tests/layer_tests/pytorch_tests/test_topk.py +++ b/tests/layer_tests/pytorch_tests/test_topk.py @@ -63,5 +63,6 @@ def forward(self, input_tensor): @pytest.mark.precommit @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == 'true', reason="Ticket - 115085") def test_topK(self, input_shape, k, dim, largest, sort, ie_device, precision, ir_version): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(k, dim, largest, sort), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_unfold.py b/tests/layer_tests/pytorch_tests/test_unfold.py index 25f874a6dfe1ba..8386e79c3b595c 100644 --- a/tests/layer_tests/pytorch_tests/test_unfold.py +++ b/tests/layer_tests/pytorch_tests/test_unfold.py @@ -39,6 +39,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit def test_unfold(self, ie_device, precision, ir_version, dimension, size, step, input_shape): - self.input_tensor = np.random.random_sample(input_shape).astype(np.float32) + rng = np.random.default_rng(seed=13) + self.input_tensor = rng.standard_normal(size=input_shape).astype(np.float32) self._test(*self.create_model(dimension, size, step), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_view.py b/tests/layer_tests/pytorch_tests/test_view.py index 42c6238ae66584..0a97d84e6f0a78 100644 --- a/tests/layer_tests/pytorch_tests/test_view.py +++ b/tests/layer_tests/pytorch_tests/test_view.py @@ -36,9 +36,12 @@ def forward(self, input_tensor, dim1: int, dim2: int): @pytest.mark.precommit def test_view_list_construct(self, ie_device, precision, ir_version, input_shapes): self.input_data = [] + seed = 13 for input_shape in input_shapes: if type(input_shape) is list: - self.input_data.append(np.random.random_sample(input_shape).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input_shape).astype(np.float32)) + seed += 1 else: self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) @@ -68,9 +71,12 @@ def forward(self, input_tensor, dtype): @pytest.mark.precommit def test_view_dtype(self, ie_device, precision, ir_version, input_shapes): self.input_data = [] + seed = 13 for input_shape in input_shapes: if type(input_shape) is list: - self.input_data.append(np.random.random_sample(input_shape).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input_shape).astype(np.float32)) + seed += 1 else: self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) @@ -101,9 +107,12 @@ def forward(self, input_tensor, input_size): @pytest.mark.precommit def test_view_size(self, ie_device, precision, ir_version, input_shapes): self.input_data = [] + seed = 13 for input_shape in input_shapes: if type(input_shape) is list: - self.input_data.append(np.random.random_sample(input_shape).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input_shape).astype(np.float32)) + seed += 1 else: self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) @@ -144,9 +153,12 @@ def forward(self, input_tensor): @pytest.mark.precommit def test_view(self, ie_device, precision, ir_version, input_shapes): self.input_data = [] + seed = 13 for input_shape in input_shapes: if type(input_shape) is list: - self.input_data.append(np.random.random_sample(input_shape).astype(np.float32)) + rng = np.random.default_rng(seed) + self.input_data.append(rng.standard_normal(input_shape).astype(np.float32)) + seed += 1 else: self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version)