Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
057af15
pt2 验证基建:结构对拍 sweep、数值对拍工具与 pt2 专属测试
magician336 Aug 29, 2026
b766bf0
pt2 Python 桥接前端留档(架构已作废,勿在此继续开发)
magician336 Aug 29, 2026
9cca4f7
清理:移除作废的 Python 桥接架构,恢复干净基线
magician336 Aug 31, 2026
f37f929
验证基建补充:local_diff.py 落盘 DIFF 诊断工具
magician336 Aug 31, 2026
874bfbc
N1 格式层:pt2 schema 解析 + main 分发 + json 边界加固
magician336 Aug 31, 2026
ab8e910
N2 忠实转写最小闭环:pt2 双路径 .ncnn.param/.bin 逐字节一致
magician336 Aug 31, 2026
64030be
N3 默认值静态表:builder 表驱动补全 torch.export 省略实参,新架构 sweep 基线 PASS 115/219
magician336 Aug 31, 2026
0850a8b
复核修复:pt2_schema 整数判型守卫统一,清理过期注释
magician336 Aug 31, 2026
e8e8dbc
N4 第一批:常量前置 + 切分族/conv 族/weight_norm/adaptive pool PT2 形态收敛,sweep PAS…
magician336 Sep 1, 2026
fcb01d6
N4 第二批:nn_module_stack 模块形态转写,sweep PASS 178→197
magician336 Sep 1, 2026
964a541
N4 第三批:ones_like 静态折叠 + LayerNorm/RMSNorm 模块形态 + 枚举实参转写,sweep PASS 19…
magician336 Sep 1, 2026
6d043eb
N4 整改:ones_like 折叠守卫前置 + DEVICE 索引保留 + 对拍 helper 收紧,新增回归样例,基线 204/12/…
magician336 Sep 2, 2026
1434eb0
docs/15 M0-M2:Conv3d pad 融合 + weight_norm 命令式折叠 + LRN 链级重写,
magician336 Sep 2, 2026
98f5499
test(pnnx): integrate torch export tests
magician336 Sep 3, 2026
f15074d
apply code-format changes
magician336 Sep 3, 2026
b1971ee
fix(pnnx): address pt2 review findings
magician336 Sep 3, 2026
39dc6a0
apply code-format changes
magician336 Sep 3, 2026
0f62632
fix(pnnx): address latest pt2 review
magician336 Sep 3, 2026
ebd4508
apply code-format changes
magician336 Sep 3, 2026
d9a86c8
fix(pnnx): address latest review findings
magician336 Sep 3, 2026
8d8f4ac
apply code-format changes
magician336 Sep 3, 2026
7f9f7c5
fix(pnnx): address adaptive and zip review
magician336 Sep 3, 2026
90942a8
apply code-format changes
magician336 Sep 3, 2026
331ec7a
fix(pnnx): address adaptive and symbolic review
magician336 Sep 3, 2026
49b9277
apply code-format changes
magician336 Sep 3, 2026
6aa8ab2
fix(pnnx): preserve module adaptive None
magician336 Sep 3, 2026
b7512b2
apply code-format changes
magician336 Sep 3, 2026
ed72331
fix(pnnx): address PT2 review findings
magician336 Sep 3, 2026
631bc3a
apply code-format changes
magician336 Sep 3, 2026
0cebcad
fix(pnnx): close remaining PT2 review gaps
magician336 Sep 3, 2026
824a049
apply code-format changes
magician336 Sep 3, 2026
72b851b
ci(pnnx): fetch submodules for pt2-test job
magician336 Sep 4, 2026
c2a20b1
test(pnnx): disable pt2 tests on torch < 2.9
magician336 Sep 4, 2026
41bf721
fix(pnnx): harden PT2 metadata and mutation
magician336 Sep 6, 2026
e7080d9
fix(pnnx): move PT2 module normalization
magician336 Sep 6, 2026
c960521
fix(pnnx): fold static PT2 window ops
magician336 Sep 7, 2026
27aa101
build(pnnx): use c++20 for torch 2.14
magician336 Sep 7, 2026
46edea9
apply code-format changes
magician336 Sep 7, 2026
d0f2242
fix(pnnx): keep one-element PT2 window fold at 1
magician336 Sep 7, 2026
d28d0f1
fix(pnnx): restore raw-string literals broken by code-format
magician336 Sep 7, 2026
be619e7
fix(pnnx): fold periodic window overloads and fill zeros_like defaults
magician336 Sep 7, 2026
557ad69
apply code-format changes
magician336 Sep 7, 2026
7a6b49c
fix(pnnx): map PT2 bfloat16 scalar type
magician336 Sep 7, 2026
e32f7f2
merge fork/pnnx-pt2-support
magician336 Sep 8, 2026
65ce577
fix(pnnx): restore PT2 test raw strings
magician336 Sep 8, 2026
ebdab50
apply code-format changes
magician336 Sep 8, 2026
e6171c3
style(pnnx): trim PT2 comments
magician336 Sep 8, 2026
c90d8a8
fix(pnnx): normalize PT2 max-pool stride
magician336 Sep 8, 2026
46b8514
merge fork/pnnx-pt2-support
magician336 Sep 8, 2026
06c0414
fix(pnnx): restore PT2 test raw strings
magician336 Sep 8, 2026
2da8323
apply code-format changes
magician336 Sep 8, 2026
30ee52a
test(pnnx): guard PT2 fixture formatting
magician336 Sep 8, 2026
a81ce57
apply code-format changes
magician336 Sep 8, 2026
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
36 changes: 36 additions & 0 deletions .github/workflows/pnnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ jobs:
cd tools/pnnx
cd build && ctest -C Release --output-on-failure -R test_nn_Conv

pt2-test:
name: pt2-tests
runs-on: ubuntu-latest
env:
PYTHONUSERBASE: ${{ github.workspace }}/pt2-python
steps:
- uses: actions/checkout@v7

- uses: actions/setup-python@v7
with:
python-version: '3.12'

- name: setup-pytorch
run: |
python3 -m pip config set global.break-system-packages true
pip3 install --user torch==2.13.0+cpu --index-url https://download.pytorch.org/whl/cpu
pip3 install --user numpy packaging

- name: python-ncnn
run: |
export PATH=${{ env.PYTHONUSERBASE }}/bin:$PATH
pip3 install --user . --verbose

- name: build-pnnx
run: |
cd tools/pnnx
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release -j 4

- name: pt2-tests
run: |
export PATH=${{ env.PYTHONUSERBASE }}/bin:$PATH
cd tools/pnnx/build
ctest -R 'test_ncnn_pt2_' --output-on-failure -j 1

build:
runs-on: [self-hosted, linux, ubuntu25]

Expand Down
57 changes: 57 additions & 0 deletions tools/pnnx/local_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""本地诊断 sweep 的 DIFF:直接比对已落盘的 sw_*.ncnn.param 与 sw_*_ts.ncnn.param。
复用 pt2_crosscheck.py 的 normalize_param,保证与 sweep 判定一致。无需跑 pnnx。"""
import os
import re
import sys
from collections import Counter

HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(HERE, "tests", "ncnn"))
from pt2_crosscheck import normalize_param # noqa: E402

D = HERE # 与 sweep 的 CWD 一致(tools/pnnx/)

pairs = []
for f in sorted(os.listdir(D)):
if f.startswith("sw_") and f.endswith("_ts.ncnn.param"):
ts = f
pt2 = f.replace("_ts.ncnn.param", ".ncnn.param")
if os.path.exists(os.path.join(D, pt2)):
pairs.append((f[len("sw_"):-len("_ts.ncnn.param")], pt2, ts))

print(f"# {len(pairs)} pairs\n")

diffs = []
for name, p2, pts in pairs:
a = normalize_param(os.path.join(D, p2))
b = normalize_param(os.path.join(D, pts))
if a == b:
continue
first = None
for i, (la, lb) in enumerate(zip(a, b)):
if la != lb:
first = (i, la, lb)
break
if first is None:
first = (None, f"len pt2={len(a)}", f"len pt={len(b)}")
diffs.append((name, first, len(a), len(b)))

print(f"# DIFF count = {len(diffs)}\n")
# 按首处差异的 op 类型归类
kind = Counter()
for name, (i, la, lb), _, _ in diffs:
toks = (la or "").split()
op = toks[0] if toks else "?"
if op == "7767517" or re.match(r"^\d+ \d+$", la or ""):
op = "HEADER(count/len)"
kind[op] += 1

print("==== DIFF 首处差异所在 op 分布 ====")
for op, c in kind.most_common():
print(f" {op}: {c}")

print("\n==== DIFF 明细(首处差异)====")
for name, (i, la, lb), na, nb in diffs:
print(f"\n[{name}] pt2={na}L pt={nb}L line{i}")
print(f" pt2: {(la or '')[:150]}")
print(f" pt : {(lb or '')[:150]}")
Loading