已合并
test update ut #39948
huangyunlong创建于 7月3日
test update ut #39948
已合并
共 1 个文件变更+10-12
| @@ -7,8 +7,6 @@ from functools import wraps | |||
| 7 | import torch | 7 | import torch |
| 8 | import torch_npu | 8 | import torch_npu |
| 9 | 9 | ||
| 10 | -import torch_npu.npu.utils as utils | ||
| 11 | - | ||
| 12 | from torch_npu.testing.testcase import TestCase, run_tests | 10 | from torch_npu.testing.testcase import TestCase, run_tests |
| 13 | from torch_npu.testing.common_utils import SupportedDevices, SkipIfNotGteCANNVersion | 11 | from torch_npu.testing.common_utils import SupportedDevices, SkipIfNotGteCANNVersion |
| 14 | 12 | ||
| @@ -114,6 +112,16 @@ class TestAclOpInitMode(TestCase): | |||
| 114 | self.assertIn(self.INVALID_VALUE_WARN, stderr) | 112 | self.assertIn(self.INVALID_VALUE_WARN, stderr) |
| 115 | 113 | ||
| 116 | 114 | ||
| 115 | +def _skipIfLazy(fn): | ||
| 116 | + | ||
| 117 | + def wrapper(slf, *args, **kwargs): | ||
| 118 | + if torch_npu.npu.utils._is_gte_cann_version('8.3.RC1'): | ||
| 119 | + raise unittest.SkipTest( | ||
| 120 | + "Test only for non-lazy set_device mode (CANN < 8.3.RC1)") | ||
| 121 | + return fn(slf, *args, **kwargs) | ||
| 122 | + return wrapper | ||
| 123 | + | ||
| 124 | + | ||
| 117 | class TestAclInitConfigPath(TestCase): | 125 | class TestAclInitConfigPath(TestCase): |
| 118 | 126 | ||
| 119 | LACKS_DEFAULT_DEVICE_MSG = "lacks 'defaultDevice'" | 127 | LACKS_DEFAULT_DEVICE_MSG = "lacks 'defaultDevice'" |
| @@ -170,16 +178,6 @@ class TestAclInitConfigPath(TestCase): | |||
| 170 | 178 | ||
| 171 | # ---- non-lazy 模式(CANN < 8.3.RC1) ---- | 179 | # ---- non-lazy 模式(CANN < 8.3.RC1) ---- |
| 172 | 180 | ||
| 173 | - | ||
| 174 | - def _skipIfLazy(fn): | ||
| 175 | - | ||
| 176 | - def wrapper(slf, *args, **kwargs): | ||
| 177 | - if utils._is_gte_cann_version('8.3.RC1'): | ||
| 178 | - raise unittest.SkipTest( | ||
| 179 | - "Test only for non-lazy set_device mode (CANN < 8.3.RC1)") | ||
| 180 | - return fn(slf, *args, **kwargs) | ||
| 181 | - return wrapper | ||
| 182 | - | ||
| 183 | 181 | ||
| 184 | def test_valid_json_non_lazy(self): | 182 | def test_valid_json_non_lazy(self): |
| 185 | """non-lazy 模式:不含 defaultDevice 的用户 JSON 正常使用""" | 183 | """non-lazy 模式:不含 defaultDevice 的用户 JSON 正常使用""" |