Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
export【部署与运维】Export, profile, and prepare NanoTrack split backbone/head models for ONNX and deployment handoff with explicit shape, artifact, and benchmark safeguards.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill for NanoTrack requests involving:
This guidance covers the maintained NanoTrack workflow. Treat other SiamTrackers snapshots as catalog entries unless another sub-skill explicitly owns them.
inference sub-skill.training sub-skill.evaluation sub-skill.The source export intent is a two-graph NanoTrackV3 contract:
| Graph | Inputs | Outputs | Opset |
|---|---|---|---|
| backbone | input: [1,3,255,255] | output: [1,96,16,16] | 14 |
| head | input1: [1,96,8,8]; input2: [1,96,16,16] | output1: [1,2,15,15]; output2: [1,4,15,15] | 14 |
output1 is the classification tensor and output2 is the positive
localization tensor returned by the NanoTrackV3 head. Read
export-reference.md before changing graph
boundaries, spatial axes, head variant, or preprocessing assumptions.
This is an evidence-backed intended contract, not a claim that an export was successfully run or validated. A compatible configuration and trusted weights are required. No weights are bundled with this skill.
Run the no-write checker from this sub-skill directory:
python scripts/export_shape_check.py
To inspect already-created ONNX graphs, install onnx in the caller-controlled
environment and pass both files:
python scripts/export_shape_check.py \
--backbone-model artifacts/backbone.onnx \
--head-model artifacts/head.onnx
The paths above are placeholders for caller-owned artifacts. The checker never downloads, exports, creates directories, or overwrites files.
Use a caller-owned staging directory and relative names. Names are examples, not required filenames:
python scripts/export_shape_check.py \
--artifact-root artifacts \
--backbone-name release/backbone-v3.onnx \
--head-name release/head-v3.onnx
The checker rejects absolute artifact names, .. traversal, duplicate targets,
non-ONNX suffixes, and existing targets unless explicitly acknowledged.
Read export-reference.md for export,
validation, simplification, and manifest gates.
Validate a benchmark plan without importing PyTorch or running long loops:
python scripts/profile_shape_check.py \
--device cpu --timer wall --warmup 100 --iterations 1000 --repeats 5
For wall-clock CUDA timing, require synchronization around each timed region:
python scripts/profile_shape_check.py \
--device cuda --timer wall --synchronize \
--warmup 100 --iterations 1000 --repeats 5
Read performance.md before interpreting MACs as FLOPs, comparing model file sizes, or reporting FPS.
127x127, search image 255x255,
backbone features 96x8x8 and 96x16x16, and head outputs 2x15x15 and
4x15x15 for NanoTrackV3.A backbone exported only from [1,3,255,255] without dynamic axes is normally a
static search graph. The head nevertheless needs a template feature of
[1,96,8,8], which comes from the 127x127 template path in PyTorch. Do not
assume one static 255x255 ONNX backbone also accepts 127x127. Choose and
validate one explicit design: dynamic spatial axes, separate template/search
backbone artifacts, or a deployment pipeline with an independently justified
template-feature path.
torch is needed to instantiate and export the model.onnx is optional but required for structural graph checking.onnxruntime is optional and useful for numerical parity.onnxsim is optional; simplification is not an automatic success gate.thop is optional and provides MAC/parameter estimates, not universal FLOP
semantics.No dataset benchmark, full tracker run, training run, ONNX export, numerical
parity run, NCNN conversion, or mobile build is proven by this sub-skill. The
source export workflow used snapshots, hard-coded output paths, and automatic
CUDA selection. Its speed loop warmed up 100 times and timed 1000 track calls;
that is methodology evidence, not a safe construction-time smoke test.
Use troubleshooting.md for missing weights, variant mismatches, shape errors, optional dependencies, CUDA timing, ONNX simplification, and deployment-boundary failures.