Fix use of ONNX optimizer by Caffe2 backend#75718
Closed
thiagocrepaldi wants to merge 1 commit intopytorch:masterfrom
Closed
Fix use of ONNX optimizer by Caffe2 backend#75718thiagocrepaldi wants to merge 1 commit intopytorch:masterfrom
thiagocrepaldi wants to merge 1 commit intopytorch:masterfrom
Conversation
Contributor
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 83f6441 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
c1d6c54 to
83f6441
Compare
BowenBao
reviewed
Apr 14, 2022
Contributor
|
@msaroufim has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
malfet
approved these changes
Apr 14, 2022
Contributor
|
@pytorchbot merge this |
Contributor
|
@msaroufim has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
facebook-github-bot
pushed a commit
that referenced
this pull request
Apr 16, 2022
Summary: Fixes #69674 The fix is Back Compatible with any Caffe2 build. It simply tries to use `onnxptimizer` module when `onnx.optimizer` is not available. `onnx.optimizer` does not exist since ONNX 1.9 (April 2021) as the code was moved to a different [repo](https://github.com/onnx/onnxoptimizer) If both `onnx<1.9` and `onnxoptimizer` are not found, the current fallback behavior is maintained (no ONNX optimization happens). Otherwise, the ONNX optimization pass will run from whatever module it is found. This PR does not require or enforce a direct package dependency to work Pull Request resolved: #75718 Approved by: https://github.com/BowenBao, https://github.com/malfet Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/950dc1b45738e0cf0b341e0594cf517668b406a0 Reviewed By: mehtanirav Differential Revision: D35658271 fbshipit-source-id: e10d7b55f39783b661f998d800e83482bb978824
thiagocrepaldi
pushed a commit
to thiagocrepaldi/detectron2
that referenced
this pull request
May 27, 2022
This commit fixes Caffe2Tracer.export_caffe2 API for the latest pytorch repo Before this change, all tests at tests/test_export_caffe2.py fail because the latest onnx releases does not have onnx.optimizer namespace anymore and detectron2 code tried to use fuse_bn_into_conv from it. However, fuse_bn_into_conv optimization previously present in onnx.optimizer is already performed by torch.onnx.export. Therefore it wwas removed from detectron2 code. Depends on pytorch/pytorch#75718 Fixes facebookresearch#3488 Fixes pytorch/pytorch#69674 (PyTorch repo)
thiagocrepaldi
pushed a commit
to thiagocrepaldi/detectron2
that referenced
this pull request
May 27, 2022
This commit fixes Caffe2Tracer.export_caffe2 API for the latest pytorch repo Before this change, all tests at tests/test_export_caffe2.py fail because the latest onnx releases does not have onnx.optimizer namespace anymore and detectron2 code tried to use fuse_bn_into_conv from it. However, fuse_bn_into_conv optimization previously present in onnx.optimizer is already performed by torch.onnx.export. Therefore it wwas removed from detectron2 code. Depends on pytorch/pytorch#75718 Fixes facebookresearch#3488 Fixes pytorch/pytorch#69674 (PyTorch repo)
thiagocrepaldi
pushed a commit
to thiagocrepaldi/detectron2
that referenced
this pull request
Jun 1, 2022
Before this change, all tests at tests/test_export_caffe2.py fail because the latest onnx releases does not have onnx.optimizer namespace anymore and detectron2 code tried to use fuse_bn_into_conv from it. However, fuse_bn_into_conv optimization previously present in onnx.optimizer is already performed by torch.onnx.export. Therefore it wwas removed from detectron2 code. Caffe2 export tests only run if onnx is installed Depends on pytorch/pytorch#75718 Fixes facebookresearch#3488 Fixes pytorch/pytorch#69674 (PyTorch repo)
facebook-github-bot
pushed a commit
to facebookresearch/detectron2
that referenced
this pull request
Jul 15, 2022
Summary: Currently all Caffe2 export tests (under `tests/test_export_caffe2.py`) fail because the latest `onnx` releases do not have `onnx.optimizer` submodule anymore (instead, a new module `onnxoptimizer` was created from it) However, `fuse_bn_into_conv` optimization previously implemented within `onnx.optimizer` is already performed by `torch.onnx.export` too ruing ONNX export. Therefore `onnx.optimizer` dependency can be safely removed from detectron2 code. Depends on pytorch/pytorch#75718 Fixes #3488 Fixes pytorch/pytorch#69674 (PyTorch repo) ps: Although `Caffe2` support is/will be deprecated, this PR relies on the fact that [contributions are welcome as stated at docs/tutorials/deployment.md](https://github.com/facebookresearch/detectron2/blob/main/docs/tutorials/deployment.md) Pull Request resolved: #4295 Reviewed By: wat3rBro Differential Revision: D37152773 Pulled By: mcimpoi fbshipit-source-id: 56ff8cda67814890d800834977fe4582f1a19761
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #69674
The fix is Back Compatible with any Caffe2 build. It simply tries to use
onnxptimizermodule whenonnx.optimizeris not available.onnx.optimizerdoes not exist since ONNX 1.9 (April 2021) as the code was moved to a different repoIf both
onnx<1.9andonnxoptimizerare not found, the current fallback behavior is maintained (no ONNX optimization happens). Otherwise, the ONNX optimization pass will run from whatever module it is found.This PR does not require or enforce a direct package dependency to work