Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: isdanni <leedanni@gmail.com>
- Loading branch information
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) ONNX Project Contributors | ||
Check warning Code scanning / lintrunner RUFF/I002 Warning
Missing required import: from \_\_future\__ import annotations.
See https://docs.astral.sh/ruff/rules/missing-required-import Check warning Code scanning / lintrunner RUFF/format Warning
Run lintrunner -a to apply this patch.
|
||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import numpy as np | ||
|
||
import onnx | ||
from onnx.backend.test.case.base import Base | ||
from onnx.backend.test.case.node import expect | ||
|
||
|
||
def swish(x: np.ndarray, alpha: np.float16) -> np.ndarray: | ||
return x * 1 / (1 + np.exp(np.negative(x * alpha))) | ||
|
||
|
||
class Swish(Base): | ||
@staticmethod | ||
def export() -> None: | ||
node = onnx.helper.make_node( | ||
"Swish", | ||
inputs=["x"], | ||
outputs=["y"], | ||
) | ||
|
||
x = np.array([3, 4, 5]).astype(np.float32) | ||
y = swish(x, alpha=1.0) | ||
|
||
expect(node, inputs=[x], outputs=[y], name="test_swish") | ||
This file contains 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
This file contains 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
This file contains 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