diff --git a/demos/auto_mode/baseline/add/test/test.py b/demos/auto_mode/baseline/add/test/test.py index e13d6bd1..a0d4a5c0 100644 --- a/demos/auto_mode/baseline/add/test/test.py +++ b/demos/auto_mode/baseline/add/test/test.py @@ -10,10 +10,11 @@ # See LICENSE in the root of the software repository for the full text of the License. # -------------------------------------------------------------------------------- -import op_extension # noqa: F401 import torch from torch_npu.testing.testcase import TestCase, run_tests +import op_extension # noqa: F401 + class TestCustomAdd(TestCase): def test_add_custom_ops(self): diff --git a/demos/auto_mode/torch_jit/add/add_compile_and_run.py b/demos/auto_mode/torch_jit/add/add_compile_and_run.py index d70e5728..28fdf352 100644 --- a/demos/auto_mode/torch_jit/add/add_compile_and_run.py +++ b/demos/auto_mode/torch_jit/add/add_compile_and_run.py @@ -11,7 +11,7 @@ # -------------------------------------------------------------------------------- import torch -import torch_npu # noqa: F401 +import torch_npu # noqa: F401 # Required for NPU backend registration from jit_util_add import jit_compile diff --git a/tests/cpu/st/testcase/tisa_coverage/main.cpp b/tests/cpu/st/testcase/tisa_coverage/main.cpp index 3df0dcec..4b55e7db 100644 --- a/tests/cpu/st/testcase/tisa_coverage/main.cpp +++ b/tests/cpu/st/testcase/tisa_coverage/main.cpp @@ -53,7 +53,7 @@ void AssignTileStorage(TileData &tile, size_t &addr) } template -void AssignTileStorage(size_t &addr, TileData &... tiles) +void AssignTileStorage(size_t &addr, TileData &...tiles) { (AssignTileStorage(tiles, addr), ...); } @@ -211,8 +211,7 @@ std::set CollectCpuListedCases(const std::filesystem::path &repoRoo return listed; } -class IsaCoverageTest : public testing::Test { -}; +class IsaCoverageTest : public testing::Test {}; TEST_F(IsaCoverageTest, RepoWideCoverageTouchesEveryIsaEntryPoint) { @@ -783,13 +782,13 @@ TEST_F(IsaCoverageTest, ThistogramWrapperBuildsCumulativeBins) SetValue(src, 0, 6, static_cast(0x4413u)); SetValue(src, 0, 7, static_cast(0x2214u)); - THISTOGRAM(dst, src, idx); + THISTOGRAM(dst, src, idx); EXPECT_EQ(GetValue(dst, 0, 0x11), 0u); EXPECT_EQ(GetValue(dst, 0, 0x12), 3u); EXPECT_EQ(GetValue(dst, 0, 0x33), 6u); EXPECT_EQ(GetValue(dst, 0, 0x34), 7u); - THISTOGRAM(dst, src, idx); + THISTOGRAM(dst, src, idx); EXPECT_EQ(GetValue(dst, 0, 0x00), 0u); EXPECT_EQ(GetValue(dst, 0, 0x01), 1u); EXPECT_EQ(GetValue(dst, 0, 0x02), 2u); @@ -821,8 +820,8 @@ TEST_F(IsaCoverageTest, TdequantAppliesScaleAndOffset) for (int r = 0; r < dst.GetValidRow(); ++r) { for (int c = 0; c < dst.GetValidCol(); ++c) { - const float expected = (static_cast(GetValue(src, r, c)) - GetValue(offset, r, c)) * - GetValue(scale, r, c); + const float expected = + (static_cast(GetValue(src, r, c)) - GetValue(offset, r, c)) * GetValue(scale, r, c); EXPECT_FLOAT_EQ(GetValue(dst, r, c), expected); } } diff --git a/tests/script/all_cpu_tests.py b/tests/script/all_cpu_tests.py index 3c1eb4da..ec26dc1e 100644 --- a/tests/script/all_cpu_tests.py +++ b/tests/script/all_cpu_tests.py @@ -112,10 +112,16 @@ def generate_test_data(repo_root: Path, build_dir: Path, args: argparse.Namespac gen_env["PYTHONPATH"] = str(repo_root) + os.pathsep + gen_env.get("PYTHONPATH", "") if args.enable_bf16: gen_env["PTO_CPU_SIM_ENABLE_BF16"] = "1" - for script in sorted(testcase_src_root.glob("*/gen_data.py")): - dst = build_dir / f"{script.parent.name}_gen_data.py" - dst.write_text(script.read_text(encoding="utf-8"), encoding="utf-8") - run_command([sys.executable, str(dst.name)], cwd=build_dir, env=gen_env, verbose=args.verbose) + copied_scripts: list[Path] = [] + try: + for script in sorted(testcase_src_root.glob("*/gen_data.py")): + dst = build_dir / f"{script.parent.name}_gen_data.py" + copied_scripts.append(dst) + dst.write_text(script.read_text(encoding="utf-8"), encoding="utf-8") + run_command([sys.executable, str(dst.name)], cwd=build_dir, env=gen_env, verbose=args.verbose) + finally: + for script_path in copied_scripts: + script_path.unlink(missing_ok=True) def run_binaries(repo_root: Path, build_dir: Path, args: argparse.Namespace) -> int: