From 66c38334cd2c0b2994623d2a444c806c07d68eae Mon Sep 17 00:00:00 2001 From: dlyakhov Date: Mon, 18 May 2026 16:35:38 +0200 Subject: [PATCH] [FX] Fix tests warnings --- .../function_hook/quantization/test_weights_compression.py | 6 +++--- tests/torch/fx/test_statistics_aggregator.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/torch/function_hook/quantization/test_weights_compression.py b/tests/torch/function_hook/quantization/test_weights_compression.py index 52a845e6008..a70e0f83879 100644 --- a/tests/torch/function_hook/quantization/test_weights_compression.py +++ b/tests/torch/function_hook/quantization/test_weights_compression.py @@ -73,7 +73,7 @@ def __init__(self): for _, main_value in enumerate(self.main_values): weights_data = torch.arange(0, 16, dtype=torch.float32).reshape(4, 4) weights_data[-1, -1] = main_value - weight_tensor = torch.tensor(weights_data) + weight_tensor = weights_data.detach().clone() layer = nn.Linear(4, 4, bias=False) layer.weight = nn.Parameter(weight_tensor.t()) self.layers.append(layer) @@ -223,9 +223,9 @@ def __init__(self, non_mergable_pattern: bool = False, is_int8=False): def get_linear_layer(self, weights_data, is_int8): if not is_int8: linear_layer = nn.Linear(weights_data.shape[1], weights_data.shape[0], bias=False) - linear_layer.weight = nn.Parameter(torch.tensor(weights_data, dtype=torch.float32)) + linear_layer.weight = nn.Parameter(weights_data.detach().clone().to(dtype=torch.float32)) else: - qw = torch.tensor(weights_data, dtype=torch.uint8).float() + qw = weights_data.detach().clone().to(dtype=torch.uint8).float() zp = torch.tensor([2**7], dtype=torch.uint8).float() scale = torch.ones((weights_data.shape[0], 1), dtype=torch.float32) weights = (qw - zp) * scale diff --git a/tests/torch/fx/test_statistics_aggregator.py b/tests/torch/fx/test_statistics_aggregator.py index b4f9a76caa1..625627cddd5 100644 --- a/tests/torch/fx/test_statistics_aggregator.py +++ b/tests/torch/fx/test_statistics_aggregator.py @@ -93,7 +93,7 @@ def dataset_samples(self, dataset_values): dataset_samples[0][0, i, 0, 0] = value["max"] dataset_samples[0][0, i, 0, 1] = value["min"] - return torch.tensor(dataset_samples, dtype=torch.float32) + return torch.tensor(np.array(dataset_samples), dtype=torch.float32) @pytest.fixture(params=[False], ids=["out_of_palce"]) def inplace_statistics(self, request) -> bool: