From 8a3ba8f4d0edaf028e5fac15b2ac1075c102a65a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:35:04 -0800 Subject: [PATCH 1/2] chore(deps): bump actions/setup-python from 4 to 5 (#1213) --- .github/workflows/lint.yaml | 2 +- .github/workflows/main.yaml | 6 +++--- .github/workflows/pages.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 66b5413c6..6add729fa 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -45,7 +45,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset. python-version: "3.10" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d6770e515..f2398c4d9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -62,7 +62,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install nox @@ -97,7 +97,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" cache: pip @@ -121,7 +121,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 - name: Update readme run: | python docs/update_readme.py diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 28363443c..ddb7f1519 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -29,7 +29,7 @@ jobs: - name: Setup Pages uses: actions/configure-pages@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" - uses: actions/checkout@v4 From 9edefbb4ff937a5811dc631002796ee4d43292b4 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Mon, 11 Dec 2023 17:04:10 -0800 Subject: [PATCH 2/2] Implement hardsigmoid and hardswish | feat(torchlib) (#1216) Fixes https://github.com/microsoft/onnxscript/issues/1210. For hardsigmoid, `y = max(0, min(1, alpha * x + beta))` where `alpha=1/6` and `beta=0.5` is equivalent with the pytorch definition ![image](https://github.com/microsoft/onnxscript/assets/11205048/8b9c7240-f0bb-4181-9018-3165bf9e521f) --- onnxscript/function_libs/torch_lib/ops/nn.py | 10 ++++++---- .../tests/function_libs/torch_lib/ops_test_data.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/onnxscript/function_libs/torch_lib/ops/nn.py b/onnxscript/function_libs/torch_lib/ops/nn.py index a37ec84c6..80d18d416 100644 --- a/onnxscript/function_libs/torch_lib/ops/nn.py +++ b/onnxscript/function_libs/torch_lib/ops/nn.py @@ -596,10 +596,11 @@ def aten_glu_jvp(glu: TensorType, x: TensorType, dx: TensorType, dim: int) -> Te raise NotImplementedError() -def aten_hardsigmoid(self: TensorType) -> TensorType: +@torch_op("aten::hardsigmoid") +def aten_hardsigmoid(self: TFloat) -> TFloat: """hardsigmoid(Tensor self) -> Tensor""" - raise NotImplementedError() + return op.HardSigmoid(self, alpha=1 / 6, beta=1 / 2) def aten_hardsigmoid_backward(grad_output: TensorType, self: TensorType) -> TensorType: @@ -608,10 +609,11 @@ def aten_hardsigmoid_backward(grad_output: TensorType, self: TensorType) -> Tens raise NotImplementedError() -def aten_hardswish(self: TensorType) -> TensorType: +@torch_op("aten::hardswish") +def aten_hardswish(self: TFloat) -> TFloat: """hardswish(Tensor self) -> Tensor""" - raise NotImplementedError() + return op.HardSwish(self) def aten_hardswish_backward(grad_output: TensorType, self: TensorType) -> TensorType: diff --git a/onnxscript/tests/function_libs/torch_lib/ops_test_data.py b/onnxscript/tests/function_libs/torch_lib/ops_test_data.py index 2d5b1ab72..1e181fc44 100644 --- a/onnxscript/tests/function_libs/torch_lib/ops_test_data.py +++ b/onnxscript/tests/function_libs/torch_lib/ops_test_data.py @@ -1177,6 +1177,8 @@ def _where_input_wrangler( core_ops.aten_embedding, input_wrangler=_embedding_input_wrangler, ), + TorchLibOpInfo("nn.functional.hardsigmoid", nn_ops.aten_hardsigmoid), + TorchLibOpInfo("nn.functional.hardswish", nn_ops.aten_hardswish), TorchLibOpInfo("nn.functional.hardtanh", nn_ops.aten_hardtanh), TorchLibOpInfo("nn.functional.leaky_relu", nn_ops.aten_leaky_relu), TorchLibOpInfo(