Commit 5ae26d9
authored
Fix version converter regression (#2799)
This pull request improves the ONNX version converter by enabling direct
opset version conversion for models containing functions, and ensures
that version conversion now correctly applies to function nodes and
their subgraphs. The changes also update the internal APIs to handle
both models and functions, and expand test coverage for these scenarios.
Enhancements to version conversion logic:
* Removed the requirement to inline functions before version conversion,
allowing `_ConvertVersionPass` to process models with functions directly
(`onnxscript/version_converter/__init__.py`).
[[1]](diffhunk://#diff-e2693e79e7e645175e987e44ba3432063a21003bf4aa50119c1a786925f6e042L41-R41)
[[2]](diffhunk://#diff-e2693e79e7e645175e987e44ba3432063a21003bf4aa50119c1a786925f6e042L55-R54)
[[3]](diffhunk://#diff-e2693e79e7e645175e987e44ba3432063a21003bf4aa50119c1a786925f6e042L76-L81)
* Updated the internal API (`_set_onnx_opset_version`) to support both
models and functions, so opset imports are set correctly for functions
as well as models
(`onnxscript/version_converter/_version_converter.py`).
Support for function and subgraph conversion:
* Modified traversal logic to process nodes inside functions and
subgraphs within control flow nodes, ensuring that all relevant nodes
are version-converted
(`onnxscript/version_converter/_version_converter.py`).
[[1]](diffhunk://#diff-b6c70f90bafaee79b30e43c90bc0fd5192fb3de7ccc4cf9d48a209798dd775faL277-R280)
[[2]](diffhunk://#diff-b6c70f90bafaee79b30e43c90bc0fd5192fb3de7ccc4cf9d48a209798dd775faL306-R307)
[[3]](diffhunk://#diff-b6c70f90bafaee79b30e43c90bc0fd5192fb3de7ccc4cf9d48a209798dd775faL324-R324)
[[4]](diffhunk://#diff-b6c70f90bafaee79b30e43c90bc0fd5192fb3de7ccc4cf9d48a209798dd775faL334-R337)
Expanded test coverage:
* Added tests to verify that nodes inside functions and subgraphs within
control flow nodes (e.g., `If` branches) are correctly
version-converted, and that opset imports are updated for functions
(`onnxscript/version_converter/_version_converter_test.py`).1 parent 0d460ff commit 5ae26d9
File tree
2 files changed
+15
-7
lines changed- onnxscript/version_converter
2 files changed
+15
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| |||
293 | 296 | | |
294 | 297 | | |
295 | 298 | | |
296 | | - | |
| 299 | + | |
297 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
298 | 305 | | |
299 | 306 | | |
300 | 307 | | |
| |||
0 commit comments