Repository navigation
refactor(rknn): read the sliced graph through one shared helper - #983
Merged
Merged
Conversation
The Piper vocoder and Inflect v2 decoder converters each carried a private copy of the same two ONNX graph reads: the input-name list of the sliced graph and the latent channel count read back from its `z`. One copy of each now lives in `tools/rknn/rknn_graph.py`, imported by both converters. The Piper path keeps its message shape (`<path>: input z must be ...`) by threading the path into the graph reader as its `where` label; the Inflect slice stage keeps reading the in-memory graph it just renamed. The same-named function in the CosyVoice3 converter is not a reader -- it validates the export's feeder set against the expected ladder -- so it is renamed to `check_graph_inputs` and stays in its converter, where the one name can no longer read as the other. Validated in the toolkit venv (rknn-toolkit2 2.3.2, onnx 1.22): all six `tools/rknn` scripts import; `graph_input_names`/`decoder_channels` read `['z']` and 192 from the sliced `en_US-lessac-medium` decoder; `check_graph_inputs` still validates the flow estimator export as `['x', 'mask', 'mu', 't', 'spks', 'cond']`; the Piper converter's full self-check on the real voice reports `global_snr=105.5 dB` with the tail at 33.6 dB, as before the move.
Owner
|
@wOvAN Merged! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
tools/rknn/prepare_piper_tts_rknn_vocoder.pyandtools/rknn/prepare_inflect_v2_rknn_decoder.pyeach carried a private copy of the same two ONNX graph reads:graph_input_names(onnx_path)— the input-name list of the sliced graph;decoder_channels— the latent channel count read back fromz, with the message naming the path (#961was the first dedup pass; this is the second, smaller layer of the same audit).One copy of each now lives in
tools/rknn/rknn_graph.py, imported by both converters. The Piper spelling's message (which names the path) wins: the graph reader takes awherelabel, and the path wrapper passes the path through it.The same-named function in
prepare_cosyvoice3_rknn_flow.pyis not a reader — it validates the export's feeder set against the expected ladder and refuses an export whose names differ. It stays in its converter, renamed tocheck_graph_inputs, so the one name no longer reads as the other.No behavior change: the moved code is the same loop, the same
SystemExittexts (modulo the path prefix Piper already had), and the qwen3/kokoro converters are untouched.Validation (PC, rknn-toolkit2 2.3.2 venv, onnx 1.22)
decoder_z.onnx, sliceden_US-lessac-medium):graph_input_names -> ['z'],decoder_channels -> 192.check_graph_inputson the real CosyVoice3 export (flow.decoder.estimator.fp32.onnx) still returns['x', 'mask', 'mu', 't', 'spks', 'cond'].RKNN.inferenceon the PC simulator, max abs diff 0.000e+00) — the compiler is deterministic, so nothing in the moved reads perturbed the compiled graph.python3 tools/check_loader_catalog_sync.py --self-test && python3 tools/check_loader_catalog_sync.py— ok (untouched surfaces, run per repo ritual).