Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demos/auto_mode/baseline/add/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion demos/auto_mode/torch_jit/add/add_compile_and_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 6 additions & 7 deletions tests/cpu/st/testcase/tisa_coverage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void AssignTileStorage(TileData &tile, size_t &addr)
}

template <typename... TileData>
void AssignTileStorage(size_t &addr, TileData &... tiles)
void AssignTileStorage(size_t &addr, TileData &...tiles)
{
(AssignTileStorage(tiles, addr), ...);
}
Expand Down Expand Up @@ -211,8 +211,7 @@ std::set<std::string> CollectCpuListedCases(const std::filesystem::path &repoRoo
return listed;
}

class IsaCoverageTest : public testing::Test {
};
class IsaCoverageTest : public testing::Test {};

TEST_F(IsaCoverageTest, RepoWideCoverageTouchesEveryIsaEntryPoint)
{
Expand Down Expand Up @@ -783,13 +782,13 @@ TEST_F(IsaCoverageTest, ThistogramWrapperBuildsCumulativeBins)
SetValue(src, 0, 6, static_cast<uint16_t>(0x4413u));
SetValue(src, 0, 7, static_cast<uint16_t>(0x2214u));

THISTOGRAM<true>(dst, src, idx);
THISTOGRAM<HistByte::BYTE_1>(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<false>(dst, src, idx);
THISTOGRAM<HistByte::BYTE_0>(dst, src, idx);
EXPECT_EQ(GetValue(dst, 0, 0x00), 0u);
EXPECT_EQ(GetValue(dst, 0, 0x01), 1u);
EXPECT_EQ(GetValue(dst, 0, 0x02), 2u);
Expand Down Expand Up @@ -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<float>(GetValue(src, r, c)) - GetValue(offset, r, c)) *
GetValue(scale, r, c);
const float expected =
(static_cast<float>(GetValue(src, r, c)) - GetValue(offset, r, c)) * GetValue(scale, r, c);
EXPECT_FLOAT_EQ(GetValue(dst, r, c), expected);
}
}
Expand Down
14 changes: 10 additions & 4 deletions tests/script/all_cpu_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading