Skip to content

pnnx fix sanitize op from convert.py - #6379

Merged
nihui merged 2 commits into
Tencent:masterfrom
glenn-jocher:patch-1
Oct 31, 2025
Merged

pnnx fix sanitize op from convert.py#6379
nihui merged 2 commits into
Tencent:masterfrom
glenn-jocher:patch-1

Conversation

@glenn-jocher

@glenn-jocher glenn-jocher commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Fix: preserve hyphens in export paths

  • Remove the “sanitize” line that strips - from output paths (breaks valid dirs/files).
  • Hyphens are valid cross-platform; path mangling surprises users and breaks scripts.

Repro

from ultralytics import YOLO
YOLO("yolo11n.pt").export(format="ncnn", project="runs/export", name="my-model-v1.2")
# before: runs/export/my_model_v1.2/
# after:  runs/export/my-model-v1.2/

Impact

  • Paths preserved verbatim; no conversion changes.

Tests

  • Add export test to tmpdir/"my-model-v1.2" and assert outputs exist in that exact dir.

Notes

@tencent-adm

tencent-adm commented Oct 30, 2025

Copy link
Copy Markdown
Member

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ glenn-jocher
❌ nihui
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

Copy link
Copy Markdown

The binary size change of libncnn.so (bytes)

architecture base size pr size difference
x86_64 15208240 15208240 0 😘
armhf 6210540 6210540 0 😘
aarch64 9523592 9523592 0 😘

Sanitize file names by replacing dashes with underscores.
@nihui

nihui commented Oct 31, 2025

Copy link
Copy Markdown
Member

Because pnnx automatically renames xxx-pnnx.py to xxx_pnnx.py to ensure it can be imported in Python code, I've modified it to keep the folder name part and only replace the hyphens in the .py filename.

@nihui nihui changed the title Remove sanitize op from convert.py pnnx fix sanitize op from convert.py Oct 31, 2025
@nihui
nihui merged commit 9b86753 into Tencent:master Oct 31, 2025
26 of 27 checks passed
@nihui

nihui commented Oct 31, 2025

Copy link
Copy Markdown
Member

Thanks for your contribution !

@glenn-jocher

Copy link
Copy Markdown
Contributor Author

Thanks @nihui!

@Y-T-G does this fix the blocker we had using the NCNN python package?

@glenn-jocher
glenn-jocher deleted the patch-1 branch October 31, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants