Download onnxscript/tests/models/loops_while.py from Dorothydu/gitrepo_top_sample_50: direct link, hf CLI and curl.
- Browser
- Download file 689 Bytes
-
https://huggingface.co/datasets/Dorothydu/gitrepo_top_sample_50/resolve/main/onnxscript/tests/models/loops_while.py
- Command line
-
hf download hf://datasets/Dorothydu/gitrepo_top_sample_50/onnxscript/tests/models/loops_while.py
-
curl -L -o loops_while.py https://huggingface.co/datasets/Dorothydu/gitrepo_top_sample_50/resolve/main/onnxscript/tests/models/loops_while.py
689 Bytes
| # Copyright (c) Microsoft Corporation. | |
| # Licensed under the MIT License. | |
| from onnx import TensorProto | |
| from onnx.helper import make_tensor | |
| from onnxscript import script | |
| from onnxscript.onnx_opset import opset15 as op | |
| from onnxscript.onnx_types import FLOAT | |
| # same variable assigned multiple times | |
| def loop1(A: FLOAT["N"]) -> FLOAT["N"]: | |
| T = A | |
| for i in range(10): | |
| T = T + A * op.Cast(i, to=TensorProto.FLOAT) | |
| return T | |
| def loop_range_cond_only(A: FLOAT["N"]) -> FLOAT["N"]: | |
| T = A | |
| cond = op.Constant(value=make_tensor("true", TensorProto.BOOL, [], [1])) | |
| while cond: | |
| T = T + A | |
| cond = op.ReduceSum(T) > -10 | |
| return T | |