Fix split_predict generating invalid ONNX models with missing elem_type #244
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.



The
split_predictpass generates invalid ONNX models when intermediate values lack explicitvalue_info. Graph inputs end up with UNDEFINED elem_type (value 0), causing validation failures inonnx.checkerand ONNX Runtime load errors.Changes
Core fix in
onnxoptimizer/passes/split.h:inferElemType()helper that infers type from producing node's inputs when elem_type is UNDEFINEDcopyMetadata()Type inference heuristic:
Tests:
test_split_predict_preserves_elem_type()SplitPredictPreservesElemTypeBoth tests verify optimized models pass ONNX validation and have valid elem_type for all inputs.
Limitations
Type inference works for common operators where output type matches input type. Operators with different output types (Shape, Cast) require proper value_info in the original model.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.