[Enhance] Use PyTorch HSwish implementation.#1709
[Enhance] Use PyTorch HSwish implementation.#1709zhouzaida merged 4 commits intoopen-mmlab:masterfrom
Conversation
|
Hardswish in PyTorch 1.6 does not support inplace. |
|
When exporting to ONNX, the OP may change. Waiting MMDeploy to check. |
May leave this comment in the code to indicate the reason why we check for 1.7 rather than 1.6. |
Please @grimoire have a check. |
|
HardSwish node is only available since op-set version 14. And some backends would unpack it (for example Torch-TensorRT) even when you export it as an independent node. It is ok if the exporter transforms it to other nodes. |
So can we merge this PR? |
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Replace naive HSwish with PyTorch official HSwish implementation. In some models, it will improve inference speed by around 30%.
Modification
Use PyTorch official HSwish when torch>=1.7 (Hardswish in PyTorch 1.6 does not support inplace.)
BC-breaking (Optional)
None
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
Checklist
Before PR:
After PR: