Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onnxsim to peephole optimizer #1602

Closed
wants to merge 4 commits into from
Closed

Add onnxsim to peephole optimizer #1602

wants to merge 4 commits into from

Conversation

xiaoyu-work
Copy link
Contributor

Describe your changes

Add onnxsim to peephole optimizer.

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.
  • Is this PR including examples changes? If yes, please remember to update example documentation in a follow-up PR.

(Optional) Issue link

@@ -120,7 +120,7 @@
"supported_providers": [ "*" ],
"supported_accelerators": [ "*" ],
"supported_precisions": [ "*" ],
"extra_dependencies": [ "onnxoptimizer", "onnxscript" ]
"extra_dependencies": [ "onnxoptimizer", "onnxscript", "onnxsmi" ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

return

self.model, check = simplify(self.model)
if not check:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the source code, check is a Boolean whether the outputs of the original and simplified model match. So the message doesn't count correct.
Since it uses the default value of 0 for check_n, this is probably always be True.

@@ -265,6 +276,7 @@ def _run_for_config(

# optimize model
peephole_optimizer = ModelOptimizer(model.model_path)
peephole_optimizer.onnxsimplifier_optimize()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to move it after onnxscript. I don't think onnx simplifier handles dynamo exported model? If so, it's safer to put it after onnxscript.

@@ -28,8 +28,8 @@ onnx-graphsurgeon
onnxconverter_common
onnxmltools
onnxoptimizer
onnxsim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetical order

# setup
input_model = get_onnx_model()
p = create_pass_from_dict(OnnxPeepholeOptimizer, {}, disable_search=True)
mock_onnxsim.return_value = input_model.load_model()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expects a tuple of model and Boolean

@xiaoyu-work
Copy link
Contributor Author

Closing as will add implementation ourselves.

@xiaoyu-work xiaoyu-work closed this Feb 8, 2025
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.

2 participants