已合并
test: add torch.QInt32Storage.dtype validation cases #44071
test: add torch.QInt32Storage.dtype validation cases #44071
已合并
gcw_rZ2ZS0CZ创建于 29 天前
1 个文件变更+44-0
@@ -0,0 +1,44 @@
1+# Copyright (c) 2026 Huawei Technologies Co., Ltd
2+# All rights reserved.
3+#
4+# Licensed under the BSD 3-Clause License (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# https://opensource.org/licenses/BSD-3-Clause
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+ 
16+"""
17+Add focused validation cases for torch.QInt32Storage.dtype:
18+1. PyTorch community covers the property through test_storage_error while
19+ iterating torch._storage_classes. The registry mixes CPU, CUDA, and NPU
20+ storage classes in the downstream NPU environment.
21+2. This file directly validates the class and instance dtype properties.
22+"""
23+ 
24+import torch
25+from torch.testing._internal.common_utils import run_tests, TestCase
26+ 
27+ 
28+class TestQInt32StorageDtype(TestCase):
29+ def test_class_dtype(self):
30+ self.assertIs(torch.QInt32Storage.dtype, torch.qint32)
31+ 
32+ def test_instance_dtype(self):
33+ storages = (
34+ torch.QInt32Storage(),
35+ torch.QInt32Storage(4),
36+ torch.QInt32Storage([0, 1, 2]),
37+ )
38+ for storage in storages:
39+ self.assertIs(storage.dtype, torch.qint32)
40+ self.assertIs(storage.dtype, torch.QInt32Storage.dtype)
41+ 
42+ 
43+if __name__ == "__main__":
44+ run_tests()