Skip to content

Replace onnxruntime.tools.symbolic_shape_infer with onnx-shape-inference#2562

Draft
justinchuby with Copilot wants to merge 3 commits into
mainfrom
copilot/replace-onnxruntime-symbolic-shape-infer
Draft

Replace onnxruntime.tools.symbolic_shape_infer with onnx-shape-inference#2562
justinchuby with Copilot wants to merge 3 commits into
mainfrom
copilot/replace-onnxruntime-symbolic-shape-infer

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

Swaps onnxruntime.tools.symbolic_shape_infer.SymbolicShapeInference for the onnx-shape-inference package — a port and improvement of the onnxruntime symbolic shape inference engine (as used by mobius) that operates on ONNX IR without serialization overhead.

Following review feedback, the branch was brought up to date with main (#2558, which migrated OnnxDAG usage to onnx_ir) and the helper now operates directly on the IR.

  • Shared helper — added run_symbolic_shape_inference(ir_model) in olive/passes/onnx/common.py, which takes and returns an ir.Model and calls infer_symbolic_shapes directly on the IR.
def run_symbolic_shape_inference(ir_model: ir.Model) -> ir.Model:
    from onnx_shape_inference import infer_symbolic_shapes

    return infer_symbolic_shapes(ir_model)
  • Call sitesSplitModel (split.py) runs inference directly on the IR (no proto round-trip). _fix_output_shapes (common.py) and scripts/transform_dla_model.py remain proto-oriented and adapt at the proto boundary via ir.from_proto / ir.to_proto.
  • Dependencies — added onnx-shape-inference; bumped onnx_ir to >=0.2.0 (its minimum).
  • Out of scopemixed_precision.py uses a different engine (onnxruntime.transformers.shape_infer_helper), left unchanged.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

(Optional) Issue link

Copilot AI changed the title [WIP] Replace onnxruntime.tools.symbolic_shape_infer with onnx-shape-inference Replace onnxruntime.tools.symbolic_shape_infer with onnx-shape-inference Jul 6, 2026
Comment thread olive/passes/onnx/common.py Outdated
Copilot AI requested a review from justinchuby July 6, 2026 17:52
@justinchuby

Copy link
Copy Markdown
Contributor

@copilot rebase from main then operate directly on the ir

…untime-symbolic-shape-infer

# Conflicts:
#	olive/passes/onnx/split.py

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot rebase from main then operate directly on the ir

Done in dbbd9f1. Merged latest main (#2558) and run_symbolic_shape_inference now takes/returns an ir.Model, calling infer_symbolic_shapes directly on the IR. SplitModel runs inference directly on the IR (no proto round-trip); _fix_output_shapes and scripts/transform_dla_model.py only adapt at the proto boundary.

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.

Replace onnxruntime.tools.symbolic_shape_infer with onnx-shape-inference

2 participants