已合并
【ut覆盖率】cpp_builder 测试用例补充 #31545
qiaoyaodan创建于 3月9日
【ut覆盖率】cpp_builder 测试用例补充 #31545
已合并
共 1 个文件变更+39-0
| @@ -0,0 +1,39 @@ | |||
| 1 | +from torch.testing._internal.common_utils import run_tests, instantiate_parametrized_tests | ||
| 2 | +from testutils import TestUtils | ||
| 3 | +import torch_npu | ||
| 4 | +import torch_npu._inductor | ||
| 5 | +from torch_npu._inductor.cpp_builder import get_cpp_torch_device_options | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +class TestCppBuilder(TestUtils): | ||
| 9 | + def test_cpp_builder(self): | ||
| 10 | + ( | ||
| 11 | + definations, | ||
| 12 | + include_dirs, | ||
| 13 | + cflags, | ||
| 14 | + ldflags, | ||
| 15 | + libraries_dirs, | ||
| 16 | + libraries, | ||
| 17 | + passthough_args, | ||
| 18 | + ) = get_cpp_torch_device_options( | ||
| 19 | + device_type="npu", | ||
| 20 | + aot_mode=False, | ||
| 21 | + compile_only=False | ||
| 22 | + ) | ||
| 23 | + # get accurate results | ||
| 24 | + definations_acc = [] | ||
| 25 | + definations_acc.append("USE_NPU") | ||
| 26 | + libraries_acc = [] | ||
| 27 | + libraries_acc += ["torch_npu", "runtime", "ascendcl"] | ||
| 28 | + passthough_args_acc = [] | ||
| 29 | + passthough_args_acc += ["-DBUILD_LIBTORCH=ON -Wno-unused-function"] | ||
| 30 | + | ||
| 31 | + # compare results | ||
| 32 | + self.assertEqual(definations_acc, definations) | ||
| 33 | + self.assertEqual(libraries_acc, libraries) | ||
| 34 | + self.assertEqual(passthough_args_acc, passthough_args) | ||
| 35 | + | ||
| 36 | +instantiate_parametrized_tests(TestCppBuilder) | ||
| 37 | + | ||
| 38 | +if __name__ == "__main__": | ||
| 39 | + run_tests() | ||