已合并
test: add NPU coverage for torch._utils._get_available_device_type #42005
Lane0218创建于 7月17日
test: add NPU coverage for torch._utils._get_available_device_type #42005
已合并
共 1 个文件变更+33-0
| @@ -0,0 +1,33 @@ | |||
| 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 validation cases for torch._utils APIs on NPU: | ||
| 18 | +1. PyTorch community lacks sufficient direct validation for some APIs on NPU. | ||
| 19 | +2. This file validates torch._utils._get_available_device_type (extendable). | ||
| 20 | +""" | ||
| 21 | + | ||
| 22 | +import torch | ||
| 23 | +from torch.testing._internal.common_utils import TestCase, run_tests | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +class TestTorchUtilsAPIs(TestCase): | ||
| 27 | + | ||
| 28 | + def test_get_available_device_type(self): | ||
| 29 | + self.assertEqual(torch._utils._get_available_device_type(), "npu") | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +if __name__ == "__main__": | ||
| 33 | + run_tests() | ||