Skip to content

pnnx: Add version 20260526 - #3264

Merged
github-actions[bot] merged 2 commits into
mainfrom
pnnx
Oct 25, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
pnnx

Conversation

@luhenry

@luhenry luhenry commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Compiles the pnnx CLI (PyTorch TorchScript -> pnnx IR / ncnn conversion), linking libtorch. Upstream publishes no riscv64 wheel.

Mirrors the import torch-probed CMake path upstream's own quick-test/test jobs use (.github/workflows/pnnx.yml), not the build job's from-scratch patched static-mobile libtorch + torchvision + onnxruntime rebuild, which is far too heavy to replicate for a new arch.

Differs from upstream

  • Links torch dynamically from our riscv64 wheel, auditwheel-bundled - no from-source libtorch build.
  • No ONNX import/export or TorchVision-op fusion - both optional in CMakeLists.txt, neither wired up here.
  • Ships normal cp3xx-manylinux_riscv64 tags, not upstream's hand-set py3-none-<platform>.

Testing

  • Runs upstream's own python/tests (test_convert, test_export, and the dynamic/naive-input variants) via CIBW_TEST_SOURCES - same cases upstream's python-pnnx CI step runs, minus ONNX/TorchVision-only tests this build doesn't carry.

License: Wheel bundles torch's libtorch/libc10/libgomp via auditwheel, same as any other port here linking our torch wheel; ncnn's top-level BSD-3-Clause LICENSE.txt is staged into the wheel since it lives three directories above setup.py.

Patches

  • 0001-cmake-require-c-20-for-pytorch-2.13.patch - Backport [https://github.com/Tencent/ncnn/commit/61ea75123d0ea71e4b029742664e3d49b7c8eec6]. Without it, torch>=2.13 headers (the only riscv64 torch we host) fail with "C++20 or later compatible compiler is required to use ATen"; reproduces on x86_64 too, confirmed locally against PyPI's CPU torch.

Built and tested locally on x86_64 against PyPI's CPU torch 2.14.1: the patched CMake configure finds Torch, skips TorchVision/onnxruntime gracefully, and the built binary passes all 6 of upstream's own python/tests cases plus an end-to-end pnnx.convert numerical check.

luhenry added a commit that referenced this pull request Oct 15, 2026
@luhenry
luhenry marked this pull request as draft October 15, 2026 12:13
All four build jobs of run 38676705597 built and repaired the wheel, then
failed every test with FileNotFoundError on the *_pnnx.py the converter
should have written: the bundled pnnx executable never ran (no stderr,
although main() prints its parameters first).

The executable is non-PIE, linked at riscv64's default base 0x10000. When
auditwheel grafts libtorch/libc10/libtorch_cpu it rewrites the executable
with patchelf, which prepends a segment at 0xe000, below the runners'
vm.mmap_min_addr, so the kernel kills it at exec without output (gotcha
595). Link it with -Wl,-Ttext-segment=0x200000 via LDFLAGS.

Once the executable runs, the generated *_pnnx.py modules import numpy
unconditionally, so add numpy to the test requirements (binary-only:
PyPI's newest numpy has no riscv64 wheel), as upstream's own test job
does.

Also pass the release version to setup.py, which otherwise stamps the
wheel with the build date (the run above built pnnx-20261015).
@github-actions
github-actions Bot marked this pull request as ready for review October 25, 2026 00:17
@github-actions
github-actions Bot merged commit 511a9c6 into main Oct 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant