| Files | Last commit | Last update |
|---|---|---|
fix(exported_custom_op): Annotate output types and discover pypto nodes in nested onnx graphs Co-authored-by: Nikita Larichev<nikita.larichev@h-partners.com> # message auto-generated for no-merge-commit merge: !6848 merge prototype/nested-graph-discovery-3502 into master fix(exported_custom_op): Annotate output types and discover pypto nodes in nested onnx graphs Created-by: Nikita17 Commit-by: Nikita Larichev Merged-by: cann-robot Description: Fixes #3502. The filed defect is one of four seams that break the export of a scripted model with a pypto op inside a conditional: 1. **Root-only discovery.** find_pypto_nodes returns **0** on a nested model before and **1** after; zero nodes means no .so, so atc fails with E13010. Still root-only at node_reader.py:44 on master. 2. **onnx.checker rejects the nested export** — the synthesized output declares no type. 3. **A second root-only scan** in the GE standard-domain rewrite, leaving 2 empty-domain nodes in the subgraphs — the GE mixed-domain failure condition. 4. **Silently skipped opset stamping**, masked because torch writes ('pypto', 1) and our default is also 1. ## Why seam 2 needs the whole type Torch stamps the root output's type from the trace, so flat exports were always complete. Nested, it becomes a subgraph output nothing stamps, and the model output's type is merged from the If branch types — where a standard-op branch supplies the shape and no element type, so neither half suffices alone. Both nested topologies fail on the base commit. The annotation reads the op's own infer funcs, asking infer_shape twice under dynamic_axes and declaring only the dimensions that hold still. ## Changes 17 files, +1385 / -84. Four production files: - onnx/node_reader.py — one shared walk, iter_all_onnx_nodes, recursing on **attribute type** rather than op_type, so it covers containers nobody has enumerated yet. - onnx/export.py — annotate each output from the op's own infer funcs; warn rather than raise when an operand defeats it. - common/discovery.py and export/onnx_export.py — reuse that walk instead of a second root-only scan. - A demo at examples/03_advanced/exported_custom_op_litenpu/onnx/nested_control_flow/, shaped if A then add else if B then sub else mul. ## Verification of the exported behaviour A 6-topology by 2-axes matrix exports under onnx.checker — flat through depth 3, all-pypto branches included, static and dynamic_axes: **12 of 12 pass**, discovered-node count correct in every cell, nested cells failing on the base commit. Both UT suites pass with nothing lost by name: extension 339 to 342, tools 275 unchanged. On a 910B3 box with CANN 9.2.0, through a fresh build_ci.py install of this tip: the demo reaches ATC run success, markers balanced 3 of 3, .omc 62,450 bytes, and GE dispatches all 3 ops from below the root graph, 2 of them two levels down. The flat add floor still passes. A 3-cell A/B there shows GE never reads the declared shape: it is declared for onnx.checker, which gates whether a file is written. Related Issues: [#3502](https://gitcode.com/cann/pypto/issues/3502) See merge request: cann/pypto!6848 | 18 days ago |