You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by an...@apache.org on 2022/03/24 20:03:15 UTC
[tvm] branch main updated: ONNX Opset 14 Support - HardSwish (#10735)
This is an automated email from the ASF dual-hosted git repository.
andrewzhaoluo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 1c013bc ONNX Opset 14 Support - HardSwish (#10735)
1c013bc is described below
commit 1c013bcbbd5a58872b5fe26d513015d70fff61eb
Author: Brunno Goldstein <51...@users.noreply.github.com>
AuthorDate: Thu Mar 24 17:02:33 2022 -0300
ONNX Opset 14 Support - HardSwish (#10735)
* ONNX Opset 14 - HardSwish
Added hardswish support to TVM CI and fixed unit test.
- Add class HardSwish and added its reference to convert_map in onnx.py;
- Removed test_hardswish entry from test_forward.py;
* ONNX Opset 14 Support - HardSwish
Fixing onnx.py format.
* jostle ci
---
python/tvm/relay/frontend/onnx.py | 13 +++++++++++++
tests/python/frontend/onnx/test_forward.py | 1 -
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/python/tvm/relay/frontend/onnx.py b/python/tvm/relay/frontend/onnx.py
index a56f33f..8b1b152 100644
--- a/python/tvm/relay/frontend/onnx.py
+++ b/python/tvm/relay/frontend/onnx.py
@@ -1841,6 +1841,18 @@ class HardSigmoid(OnnxOpConverter):
return AttrCvt("clip")([transformX], attr)
+class HardSwish(OnnxOpConverter):
+ """Operator converter for HardSwish."""
+
+ @classmethod
+ def _impl_v14(cls, inputs, attr, params):
+ alpha = attr.get("alpha", 1 / 6)
+ beta = attr.get("beta", 0.5)
+ transformX = inputs[0] * _expr.const(alpha) + _expr.const(beta)
+ attr = {"a_min": 0, "a_max": 1}
+ return inputs[0] * AttrCvt("clip")([transformX], attr)
+
+
class Reduce(OnnxOpConverter):
"""Operator converter for reduce ops."""
@@ -4676,6 +4688,7 @@ def _get_convert_map(opset):
"PRelu": Prelu.get_converter(opset),
"Sigmoid": Renamer("sigmoid"),
"HardSigmoid": HardSigmoid.get_converter(opset),
+ "HardSwish": HardSwish.get_converter(opset),
"Max": Maximum.get_converter(opset),
"Min": Minimum.get_converter(opset),
"Sum": Sum.get_converter(opset),
diff --git a/tests/python/frontend/onnx/test_forward.py b/tests/python/frontend/onnx/test_forward.py
index 5a995cd..4ab3e81 100644
--- a/tests/python/frontend/onnx/test_forward.py
+++ b/tests/python/frontend/onnx/test_forward.py
@@ -5043,7 +5043,6 @@ unsupported_onnx_tests = [
"test_dropout_default_mask_ratio",
"test_dropout_default_ratio",
"test_gru_batchwise",
- "test_hardswish",
"test_identity_sequence",
"test_if_seq",
"test_loop11",