Skip to content

refactor(tools/rknn): one report line and one bootstrap per converter - #990

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
wOvAN:rknn-converters-shared
Oct 19, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
wOvAN:rknn-converters-shared

Conversation

@wOvAN

@wOvAN wOvAN commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

What

Finishes the layer #983 started in tools/rknn/: after the graph-inspection readers moved into rknn_graph.py, what stayed duplicated was the reporting and the module bootstrap.

  • One summary line per written artefact. Five converters printed six hand-shaped variants — wrote {output}, wrote {output} ({size} MB, inputs ...), saved {out} ({size} MB) — each caller reformatting stat().st_size. rknn_build.report_engine(output, *details) is that line now: wrote <path> (<size> MB[, details...]).
  • One bootstrap per file. The files that import rknn_graph at the top (prepare_piper_tts_rknn_vocoder.py, prepare_inflect_v2_rknn_decoder.py) also repeated sys.path.insert(0, ...) inside convert_rknn — a no-op second insert of the same directory; it is gone. The files whose only import of the shared modules is the lazy one inside the build function keep exactly that one insert (the slice stages must run in an export venv that has no toolkit, so the lazy import itself is load-bearing), and prepare_qwen3_tts_rknn_vocoder.py keeps its os.path spelling — it never imports pathlib at the top.

No behaviour change beyond the printed summaries: the slice/convert/check/gate sequence, the gate wiring, the file naming and the argv surface are untouched.

Validation

PC (x86_64, converter venv: rknn-toolkit2 2.3.2, onnx 1.16.1): all six scripts under tools/rknn/ py_compile clean; the piper converter ran end to end on en_US-lessac-medium.onnx:

$ <venv>/bin/python tools/rknn/prepare_piper_tts_rknn_vocoder.py --voice-onnx en_US-lessac-medium.onnx --skip-rknn --output decoder_z.onnx
... seam at slice 135: depop shift=0; slices[180:210] snr=138.9 dB (tail)
$ <venv>/bin/python tools/rknn/prepare_piper_tts_rknn_vocoder.py --onnx decoder_z.onnx --target rk3588
wrote /tmp/p11/decoder_z.rknn (19.6 MB, inputs ['z', 'y_mask'], window 93)

The rebuilt engine was then run on the RK3588 board against the production w93 engine built from the same voice by the same toolkit before this change: same graph contract (z [1,192,93], y_mask [1,1,93]), and with fixed-seed inputs the 23808-sample PCM outputs are bit-identical (np.array_equal true; equal size 19,602,065 bytes, differing md5 is the embedded build path, not the graph).

Every converter ended its phases by printing a hand-shaped summary --
wrote/saved, with or without the size, each caller reformatting
stat().st_size -- and re-added the module directory to sys.path at every
function that lazily imports rknn_build, twice in the files that already
bootstrap it at the top. rknn_build.report_engine() is now that one line
(wrote <path> (<size> MB, details...)), and each converter keeps exactly the
one bootstrap its import placement needs (lazy imports stay: the slice stages
must run in an export venv without the toolkit).

Validated on PC: all six scripts py_compile; the piper converter ran end to
end in the 2.3.2 converter venv (slice self-check 138.9 dB, build gated), and
the rebuilt w93 engine decodes bit-identically on RK3588 to the production
lessac w93 2.3.2 engine (23808 samples, np.array_equal true; equal size,
different md5 -- embedded build path).
@0xShug0
0xShug0 merged commit 548e5af into 0xShug0:main Oct 19, 2026
0 of 7 checks passed
@0xShug0

0xShug0 commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Merged!

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.

2 participants