Download onnxscript/modified_testcases/models/subfunction.py from Dorothydu/gitrepo_top_sample_50: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/datasets/Dorothydu/gitrepo_top_sample_50/resolve/main/onnxscript/modified_testcases/models/subfunction.py
- Command line
-
hf download hf://datasets/Dorothydu/gitrepo_top_sample_50/onnxscript/modified_testcases/models/subfunction.py
-
curl -L -o subfunction.py https://huggingface.co/datasets/Dorothydu/gitrepo_top_sample_50/resolve/main/onnxscript/modified_testcases/models/subfunction.py
1.26 kB
| # Copyright (c) Microsoft Corporation. | |
| # Licensed under the MIT License. | |
| from onnxscript import script | |
| from onnxscript.onnx_opset import opset15 as op | |
| from onnxscript.onnx_types import FLOAT | |
| def MySelu(X: FLOAT[None], alpha: FLOAT[1], gamma: FLOAT[1]) -> FLOAT[None]: | |
| zero = op.Constant(value_float=1.0) | |
| neg = gamma * (alpha * op.Exp(X) - alpha) | |
| pos = gamma * X | |
| return op.Where(X <= zero, neg, pos) | |
| def MyElu(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: | |
| alpha = op.Constant(value_float=1.0) | |
| return MySelu(X, alpha, beta) | |
| def MyEluB(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: | |
| alpha = op.Constant(value_float=1.0) | |
| res = MySelu(X, alpha, beta) | |
| return res | |
| def MyEluC(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: | |
| alpha = op.Constant(value_float=1.0) | |
| res = op.Identity(MySelu(X, alpha, beta)) | |
| return res | |
| def MyEluD(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: | |
| res = op.Identity(MyEluC(X, beta)) | |
| return res | |
| def IfMyEluD(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: | |
| zero = op.Constant(value_float=1.0) | |
| if beta > zero: | |
| result = MyEluB(X, beta) | |
| else: | |
| result = MyEluC(X, beta) | |
| return result | |