├── VERSION ├── opgen ├── __init__.py └── README.md ├── onnxscript ├── utils │ ├── __init__.py │ └── timing_utils.py ├── _internal │ └── __init__.py ├── py.typed ├── backend │ └── __init__.py ├── rewriter │ ├── rules │ │ ├── __init__.py │ │ ├── fusion │ │ │ └── __init__.py │ │ └── common │ │ │ ├── _gemm_to_matmul_add.py │ │ │ └── _no_op.py │ ├── onnxruntime │ │ ├── README.md │ │ └── __init__.py │ ├── onnx_fusions │ │ └── __init__.py │ ├── ort_fusions │ │ ├── __init__.py │ │ ├── rms_normalization_test.py │ │ ├── erfgelu.py │ │ ├── rotary_embedding_test.py │ │ ├── _test_utils.py │ │ └── gelu.py │ └── pattern.py ├── _thirdparty │ └── README.md ├── _framework_apis │ ├── __init__.py │ ├── torch_2_7.py │ ├── torch_2_8.py │ └── torch_2_9.py ├── ir │ ├── README.md │ ├── __init__.py │ ├── convenience.py │ └── passes │ │ ├── __init__.py │ │ └── common │ │ └── __init__.py ├── function_libs │ └── torch_lib │ │ ├── _constants.py │ │ ├── __init__.py │ │ ├── ops │ │ ├── __init__.py │ │ ├── nested.py │ │ ├── sparse.py │ │ └── vision.py │ │ └── graph_building │ │ └── __init__.py └── tools │ └── __init__.py ├── tests ├── function_libs │ ├── __init__.py │ └── torch_lib │ │ └── __init__.py ├── __init__.py ├── models │ ├── __init__.py │ ├── m1.py │ ├── multi.py │ ├── attrref.py │ ├── eager_op.py │ ├── dropout.py │ ├── renaming.py │ ├── sequences.py │ ├── loops_while.py │ ├── loops_break.py │ ├── eg1.py │ ├── different_opset.py │ └── subfunction.py ├── common │ └── __init__.py ├── README.md ├── functions │ ├── gemmgelu.py │ ├── ort_custom_ops.py │ └── if_test.py ├── version_converter │ └── version_conversion_test.py ├── operator_test.py ├── ir │ └── graph_view_test.py ├── loop_test.py └── if_test.py ├── docs ├── examples │ ├── README.txt │ ├── 03_export_lib.py │ ├── 01_plot_selu.py │ ├── 05_plot_model_props.py │ └── 04_plot_eager_mode_evaluation.py ├── _static │ ├── logo.ai │ ├── logo-dark.png │ ├── logo_main.png │ ├── logo-light.png │ └── css │ │ └── custom.css ├── tutorial │ ├── optimizer │ │ └── index.md │ ├── rewriter │ │ ├── index.md │ │ ├── examples │ │ │ └── img │ │ │ │ ├── erfgelu_01.png │ │ │ │ ├── erfgelu_02.png │ │ │ │ ├── broadcast_01.png │ │ │ │ ├── broadcast_02.png │ │ │ │ ├── erfgelu_03_commute.png │ │ │ │ ├── erfgelu_04_commute.png │ │ │ │ ├── erfgelu_05_commute.png │ │ │ │ ├── erfgelu_06_commute.png │ │ │ │ └── erfgelu_07_commute.png │ │ ├── or_pattern.md │ │ ├── attributes.md │ │ └── allow_other_inputs.md │ └── examples │ │ ├── firstdim.py │ │ ├── tensor_attr_short.py │ │ ├── leaky_relu.py │ │ ├── leaky_relu_attr_promoted.py │ │ ├── forloop.py │ │ ├── tensor_attr.py │ │ ├── softplus.py │ │ ├── scanloop.py │ │ ├── omitted_input.py │ │ ├── dropout.py │ │ ├── forwhileloop.py │ │ ├── whileloop.py │ │ ├── tensor_attr2.py │ │ └── outerscope_redef_error.py ├── api │ ├── decorator.md │ ├── testing.md │ ├── converter.md │ ├── values.md │ ├── index.md │ ├── optimizer.md │ ├── rewriter.md │ ├── version_converter.md │ ├── rewriter_pattern.md │ └── opsets.md ├── articles │ ├── index.md │ └── 2023-06-20-introducing-onnx-script │ │ ├── ten_chunks_model.png │ │ ├── debugging_screenshot.png │ │ └── intellisense_screenshot.png ├── ir │ └── index.md ├── _templates │ ├── functiontemplate.rst │ ├── classtemplate.rst │ └── classtemplate_inherited.rst └── update_readme.py ├── requirements ├── ci │ ├── requirements-onnx-weekly.txt │ ├── requirements-pytorch-nightly.txt │ └── requirements-ort-nightly.txt └── lintrunner │ └── requirements.txt ├── .gitattributes ├── .vscode └── extensions.json ├── .editorconfig ├── codecov.yml ├── testdata ├── dort_models │ └── llama_forward.onnx ├── unittest_models │ ├── sdpa_yi_0 │ │ ├── sdpa_yi_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_7.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── sdpa_yi_1 │ │ ├── sdpa_yi_1.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_7.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── ln_llama2_0 │ │ ├── ln_llama2_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ ├── ln_llama2_1 │ │ ├── ln_llama2_1.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ ├── ln_llama2_2 │ │ ├── ln_llama2_2.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ ├── ln_llama2_3 │ │ ├── ln_llama2_3.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ ├── attn_phi_1_5_0 │ │ ├── attn_phi_1_5_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_12.pb │ │ │ ├── input_4.pb │ │ │ ├── input_6.pb │ │ │ ├── input_8.pb │ │ │ ├── input_0.pb │ │ │ ├── input_10.pb │ │ │ ├── input_11.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_5.pb │ │ │ ├── input_7.pb │ │ │ ├── input_9.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_phi_1_5_1 │ │ ├── attn_phi_1_5_1.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_12.pb │ │ │ ├── input_4.pb │ │ │ ├── input_6.pb │ │ │ ├── input_8.pb │ │ │ ├── input_0.pb │ │ │ ├── input_10.pb │ │ │ ├── input_11.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_5.pb │ │ │ ├── input_7.pb │ │ │ ├── input_9.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_phi_1_5_2 │ │ ├── attn_phi_1_5_2.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_12.pb │ │ │ ├── input_4.pb │ │ │ ├── input_6.pb │ │ │ ├── input_8.pb │ │ │ ├── input_0.pb │ │ │ ├── input_10.pb │ │ │ ├── input_11.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_5.pb │ │ │ ├── input_7.pb │ │ │ ├── input_9.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_phi_1_5_3 │ │ ├── attn_phi_1_5_3.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_12.pb │ │ │ ├── input_4.pb │ │ │ ├── input_6.pb │ │ │ ├── input_8.pb │ │ │ ├── input_0.pb │ │ │ ├── input_10.pb │ │ │ ├── input_11.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_5.pb │ │ │ ├── input_7.pb │ │ │ ├── input_9.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_yi_4_37_0 │ │ ├── attn_yi_4_37_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_7.pb │ │ │ ├── input_8.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── gelu_phi_1_5_0 │ │ ├── gelu_phi_1_5_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ ├── gelu_phi_1_5_1 │ │ ├── gelu_phi_1_5_1.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ ├── gelu_phi_1_5_2 │ │ ├── gelu_phi_1_5_2.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ ├── gelu_phi_1_5_3 │ │ ├── gelu_phi_1_5_3.onnx │ │ └── test_data_set_0 │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ ├── sdpa_llama2_0 │ │ ├── sdpa_llama2_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_7.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── sdpa_llama2_1 │ │ ├── sdpa_llama2_1.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_7.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── sdpa_llama2_2 │ │ ├── sdpa_llama2_2.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_7.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── sdpa_llama2_3 │ │ ├── sdpa_llama2_3.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_7.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── sdpa_yi_4_38_0 │ │ ├── sdpa_yi_4_38_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_3.pb │ │ │ ├── input_7.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_8.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_llama2_4_34_0 │ │ ├── attn_llama2_4_34_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_2.pb │ │ │ ├── input_0.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_7.pb │ │ │ ├── input_8.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_llama2_4_34_1 │ │ ├── attn_llama2_4_34_1.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_2.pb │ │ │ ├── input_0.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_7.pb │ │ │ ├── input_8.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_llama2_4_36_0 │ │ ├── attn_llama2_4_36_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_2.pb │ │ │ ├── input_6.pb │ │ │ ├── input_7.pb │ │ │ ├── input_0.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_8.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── sdpa_llama2_4_38_0 │ │ ├── sdpa_llama2_4_38_0.onnx │ │ └── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_3.pb │ │ │ ├── input_7.pb │ │ │ ├── input_0.pb │ │ │ ├── input_2.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_8.pb │ │ │ ├── output_0.pb │ │ │ ├── output_1.pb │ │ │ └── output_2.pb │ ├── attn_stable_diffusion_unet_0 │ │ ├── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ │ └── attn_stable_diffusion_unet_0.onnx │ ├── attn_stable_diffusion_unet_1 │ │ ├── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_6.pb │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ │ └── attn_stable_diffusion_unet_1.onnx │ ├── geglu_stable_diffusion_unet_0 │ │ ├── test_data_set_0 │ │ │ ├── input_2.pb │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ │ └── geglu_stable_diffusion_unet_0.onnx │ ├── geglu_stable_diffusion_unet_1 │ │ ├── test_data_set_0 │ │ │ ├── input_2.pb │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ │ └── geglu_stable_diffusion_unet_1.onnx │ ├── geglu_stable_diffusion_unet_2 │ │ ├── test_data_set_0 │ │ │ ├── input_2.pb │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ │ └── geglu_stable_diffusion_unet_2.onnx │ ├── geglu_stable_diffusion_unet_3 │ │ ├── test_data_set_0 │ │ │ ├── input_2.pb │ │ │ ├── input_0.pb │ │ │ ├── input_1.pb │ │ │ └── output_0.pb │ │ └── geglu_stable_diffusion_unet_3.onnx │ ├── attn_stable_diffusion_unet_without_encoder_hidden_states_0 │ │ ├── test_data_set_0 │ │ │ ├── input_1.pb │ │ │ ├── input_2.pb │ │ │ ├── input_3.pb │ │ │ ├── input_4.pb │ │ │ ├── input_5.pb │ │ │ ├── input_0.pb │ │ │ └── output_0.pb │ │ └── attn_stable_diffusion_unet_without_encoder_hidden_states_0.onnx │ └── attn_stable_diffusion_unet_without_encoder_hidden_states_1 │ │ ├── test_data_set_0 │ │ ├── input_1.pb │ │ ├── input_2.pb │ │ ├── input_3.pb │ │ ├── input_4.pb │ │ ├── input_5.pb │ │ ├── input_0.pb │ │ └── output_0.pb │ │ └── attn_stable_diffusion_unet_without_encoder_hidden_states_1.onnx └── e2e_models │ ├── resnet18 │ └── dynamo │ │ ├── resnet18_dynamo.onnx │ │ └── test_data_set_0 │ │ ├── input_0.pb │ │ └── output_0.pb │ ├── torchscript_model │ └── torchscript_model.onnx │ ├── mobilenetv2_100 │ └── dynamo │ │ ├── test_data_set_0 │ │ ├── input_0.pb │ │ └── output_0.pb │ │ └── mobilenetv2_100_dynamo.onnx │ └── Speech2Text2ForCausalLM │ └── dynamo │ ├── test_data_set_0 │ ├── input_0.pb │ ├── input_1.pb │ ├── output_0.pb │ ├── output_1.pb │ ├── output_10.pb │ ├── output_11.pb │ ├── output_12.pb │ ├── output_13.pb │ ├── output_2.pb │ ├── output_3.pb │ ├── output_4.pb │ ├── output_5.pb │ ├── output_6.pb │ ├── output_7.pb │ ├── output_8.pb │ └── output_9.pb │ └── Speech2Text2ForCausalLM_dynamo.onnx ├── .github ├── copilot-instructions.md ├── codeql │ └── codeql-config.yml ├── release.yml ├── dependabot.yaml └── workflows │ └── pages.yaml ├── MANIFEST.in ├── .azure-pipelines ├── stages │ ├── release-stage.yml │ └── jobs │ │ └── steps │ │ └── release-steps.yml ├── release-dev.yml └── release.yml ├── CODE_OF_CONDUCT.md ├── requirements-dev.txt ├── tools ├── onnx2external.py └── optimize.py ├── LICENSE ├── ROADMAP.md ├── pyproject_pylint.toml ├── setup.py ├── SUPPORT.md └── CONTRIBUTING.md /VERSION: -------------------------------------------------------------------------------- 1 | 0.5.7 2 | -------------------------------------------------------------------------------- /opgen/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /onnxscript/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /onnxscript/_internal/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/function_libs/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/function_libs/torch_lib/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/examples/README.txt: -------------------------------------------------------------------------------- 1 | Example Gallery 2 | =============== 3 | -------------------------------------------------------------------------------- /onnxscript/py.typed: -------------------------------------------------------------------------------- 1 | # Marker file for PEP-561 (inline types) 2 | -------------------------------------------------------------------------------- /requirements/ci/requirements-onnx-weekly.txt: -------------------------------------------------------------------------------- 1 | onnx-weekly==1.21.0.dev20251103 2 | -------------------------------------------------------------------------------- /docs/_static/logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/_static/logo.ai -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /docs/tutorial/optimizer/index.md: -------------------------------------------------------------------------------- 1 | # Optimizer Tutorials 2 | 3 | ```{toctree} 4 | optimize 5 | ``` 6 | -------------------------------------------------------------------------------- /docs/_static/logo-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/_static/logo-dark.png -------------------------------------------------------------------------------- /docs/_static/logo_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/_static/logo_main.png -------------------------------------------------------------------------------- /docs/api/decorator.md: -------------------------------------------------------------------------------- 1 | # Decorator 2 | 3 | ```{eval-rst} 4 | .. autofunction:: onnxscript.script 5 | ``` 6 | -------------------------------------------------------------------------------- /docs/tutorial/rewriter/index.md: -------------------------------------------------------------------------------- 1 | # Rewriter Tutorial 2 | 3 | ```{toctree} 4 | rewrite_patterns 5 | ``` 6 | -------------------------------------------------------------------------------- /tests/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | **/*.pb filter=lfs diff=lfs merge=lfs -text 2 | **/*.onnx filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /docs/_static/logo-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/_static/logo-light.png -------------------------------------------------------------------------------- /onnxscript/backend/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "editorconfig.editorconfig" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /onnxscript/rewriter/rules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /docs/api/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | ```{eval-rst} 4 | .. automodule:: onnxscript.testing 5 | :members: 6 | ``` 7 | -------------------------------------------------------------------------------- /onnxscript/_thirdparty/README.md: -------------------------------------------------------------------------------- 1 | # Third-party 2 | 3 | Third-party vendored libraries. License in respective packages. 4 | -------------------------------------------------------------------------------- /onnxscript/rewriter/rules/fusion/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /docs/api/converter.md: -------------------------------------------------------------------------------- 1 | # Converter 2 | 3 | ```{eval-rst} 4 | .. autoclass:: onnxscript.converter.Converter 5 | :members: 6 | ``` 7 | -------------------------------------------------------------------------------- /docs/articles/index.md: -------------------------------------------------------------------------------- 1 | # Articles 2 | 3 | ```{toctree} 4 | :maxdepth: 1 5 | 6 | 2023-06-20-introducing-onnx-script/index 7 | ``` 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | indent_style = space 8 | -------------------------------------------------------------------------------- /onnxscript/rewriter/onnxruntime/README.md: -------------------------------------------------------------------------------- 1 | This folder (and function_rule based rewrites) are deprecated. The folder will be removed soon. 2 | -------------------------------------------------------------------------------- /requirements/ci/requirements-pytorch-nightly.txt: -------------------------------------------------------------------------------- 1 | --index-url=https://download.pytorch.org/whl/nightly/cpu 2 | --pre 3 | torch 4 | torchvision 5 | -------------------------------------------------------------------------------- /tests/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Shared components for testing.""" 4 | -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_01.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_02.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/broadcast_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/broadcast_01.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/broadcast_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/broadcast_02.png -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | informational: true 6 | patch: 7 | default: 8 | informational: true 9 | -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_03_commute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_03_commute.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_04_commute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_04_commute.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_05_commute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_05_commute.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_06_commute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_06_commute.png -------------------------------------------------------------------------------- /docs/tutorial/rewriter/examples/img/erfgelu_07_commute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/tutorial/rewriter/examples/img/erfgelu_07_commute.png -------------------------------------------------------------------------------- /testdata/dort_models/llama_forward.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6de32573c9127923c867dc047ea5c886042573c3f9383e22299dea42f18a4306 3 | size 27225 4 | -------------------------------------------------------------------------------- /onnxscript/_framework_apis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Semi-private stable APIs for framework-specific usage only.""" 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/sdpa_yi_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ea8d7fc76d15329678f93c32d4c4b8c0b1fef583104369daa27d239f3e7f2021 3 | size 802629 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/sdpa_yi_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ef0002880be094d3b8401a9154f06ca4a592fa96412550fd80ed905609c565d0 3 | size 802731 4 | -------------------------------------------------------------------------------- /docs/articles/2023-06-20-introducing-onnx-script/ten_chunks_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/articles/2023-06-20-introducing-onnx-script/ten_chunks_model.png -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_0/ln_llama2_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7bb94d323af9d7c16e5b1e16e1775c906ecac60b10387057a8f34c8f07c31c88 3 | size 3618 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_1/ln_llama2_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0ef31dabf73e8517de32e8abb0523558a147ae8f35c914a09e75713a814e7d77 3 | size 3675 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_2/ln_llama2_2.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:60664ba124291396bf97dd4fcaac75614b9d0f04826fde2f483337d0704527f2 3 | size 3630 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_3/ln_llama2_3.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:afa920c4388c2ca721e796b155e3b334a03471a49c6a0a7098827863241e1851 3 | size 3695 4 | -------------------------------------------------------------------------------- /docs/articles/2023-06-20-introducing-onnx-script/debugging_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/articles/2023-06-20-introducing-onnx-script/debugging_screenshot.png -------------------------------------------------------------------------------- /testdata/e2e_models/resnet18/dynamo/resnet18_dynamo.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:12d24be13a03ea8ddebcc5ea229390d49fb0da08ad1df896b03703c664e2def1 3 | size 46921843 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/torchscript_model/torchscript_model.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6519a87ecf89132a9d39c59c47a442ae5833faf14811575d0b2323e8d13e30a8 3 | size 313873 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/attn_phi_1_5_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6620dce87374e515078354c52059ee5f4fb80e6f3f755dca3736d70097171f5a 3 | size 1131586 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/attn_phi_1_5_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f3e631386757f0ecc674dc955c2e04922f82bbf9d86edb9f5043eba9b801ad1d 3 | size 1131684 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/attn_phi_1_5_2.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2abfbaa33ecfad724c84ace6853a7791d9224e61115b044e7d3e68bd09721e1d 3 | size 1131742 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/attn_phi_1_5_3.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fd0873efdc58c3d2eb549c86ea68ec909585aeec4fd18b32c8281ae217f71095 3 | size 1131758 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/attn_yi_4_37_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22df78044fab14e44844aeb62cbf81325ea638e7570d6e12c1a6da9d32b592d1 3 | size 806387 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_0/gelu_phi_1_5_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:73ad4152d9d07634ae1a0b4972ded7a8ae2610fa88279b4383d2ca57fbfe7ad2 3 | size 3122 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_1/gelu_phi_1_5_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2d4cf937ac9813a7d936cd12666c222f5a256c604ad74b4aa8047e2756434256 3 | size 3147 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_2/gelu_phi_1_5_2.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1a48fa9ebb495c4bec7ed175bdd1d8c639d727528ad2eb0de4f4b53128306a36 3 | size 3159 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_3/gelu_phi_1_5_3.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:de65cdeb463aa1844ff4bc0da8ed5051be1e7eac42af5250f324384c28f4f801 3 | size 3163 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/sdpa_llama2_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a16731ed446341ee45d728881d0e1605464a3f050469a8eef47a0b70615df462 3 | size 798936 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/sdpa_llama2_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:530265630aea82f5d40955b0351abe39abcf81ac88946d92b5be91c28da71ef0 3 | size 799028 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/sdpa_llama2_2.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:13fb16901400a2ab02aefbd0478f49cf71a0047140b7c5b91ad1ccfdf11871f8 3 | size 799058 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/sdpa_llama2_3.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a5866fa751bae100e7742fd1d2dbd0530e962ba9de0555d41bbf645967bbc3a3 3 | size 799066 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/sdpa_yi_4_38_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:be2a8476c605bad08d6e774d5af77fb64548fc08d4e002b66d91cb00498ceecd 3 | size 278064 4 | -------------------------------------------------------------------------------- /docs/articles/2023-06-20-introducing-onnx-script/intellisense_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/onnxscript/HEAD/docs/articles/2023-06-20-introducing-onnx-script/intellisense_screenshot.png -------------------------------------------------------------------------------- /onnxscript/ir/README.md: -------------------------------------------------------------------------------- 1 | # Where is the code? 2 | 3 | The ONNX IR has migrated to https://github.com/onnx/ir-py as a standalone project. The original onnxscript APIs are aliased here for compatibility. 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/resnet18/dynamo/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:144678f435f995960b1debb8b7c9125b2f68f65d5b175dee9c355be59949b199 3 | size 602128 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/resnet18/dynamo/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4936df2381104ffe50ad98d42fadba95fbd295308a17766f4929db4f59957e29 3 | size 4010 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_12.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_12.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_12.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_12.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:393e3d65cf8454705fdc60b67a114edf6f2608c5f16e7f92292cff4b9c7d623d 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2baee9fd173155738cfd0629f851e14d134d677f28d87e856905f1370391f0e3 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bca889d73daeeecbcbb56a6c58f65a7538715b65de5f55ee505c96cd1fff121c 3 | size 8200 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:707e2139fa3b9db89e8667ad7b1829fbf1c05c678f064dbbdc855e77cee50b32 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5f7588cb2aee5caf1f67ecf93e1d8742405ca4094bd931785d8b277c389879a7 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bca889d73daeeecbcbb56a6c58f65a7538715b65de5f55ee505c96cd1fff121c 3 | size 8200 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:62e46bc9154924a08494a7968e62f169db7fd1c8f26ba87e0d446712dfae1ea4 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_2/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:62d5182ff70cdeb1e82bccb6fcfe1d6a54151586c35645d62e0c5211fd48d125 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_2/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bca889d73daeeecbcbb56a6c58f65a7538715b65de5f55ee505c96cd1fff121c 3 | size 8200 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_2/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fdace10343a44a6c0d71d2bfb3a0f9c27df1f787120eb40e62d5f10c967a187f 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_3/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7804812f1235a04652e679dbbcc700fad2639a546ec6fe01e72c781bab69a1c6 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_3/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bca889d73daeeecbcbb56a6c58f65a7538715b65de5f55ee505c96cd1fff121c 3 | size 8200 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/ln_llama2_3/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2e674beb11054441c229ddb7a027c64392411df0cdf4257738483ed79a4110aa 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a44bf5864390eef1f1b54f464b619a7a283041dd6ce5da65150af5c708051f9 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d15975f1d254f650321ccdd14c3157d9eac1ca2cf3567e6c159bcdd278488f82 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a44bf5864390eef1f1b54f464b619a7a283041dd6ce5da65150af5c708051f9 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d15975f1d254f650321ccdd14c3157d9eac1ca2cf3567e6c159bcdd278488f82 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a44bf5864390eef1f1b54f464b619a7a283041dd6ce5da65150af5c708051f9 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d15975f1d254f650321ccdd14c3157d9eac1ca2cf3567e6c159bcdd278488f82 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a44bf5864390eef1f1b54f464b619a7a283041dd6ce5da65150af5c708051f9 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d15975f1d254f650321ccdd14c3157d9eac1ca2cf3567e6c159bcdd278488f82 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3e82a1c4ff1754d1fe9e470b56c14e91ba6837713c840d8a51b73a0c797f3823 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fe0ecdda5d8aa3579ba6a1d3a70e9527a0c9482eb3f28c06771fe9fff6780731 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b35459131cf1408e9a34589ce199cd7505c77ca1b6c36f387abddf025af2c4f6 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c4cc6c3459eaf88b7f4666ab404d9a834e76484d3436246ccfcf0d2fa9886951 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8f1e30a65367a08ab0718ad3516bc12c2f033ff8899fc119c19b6165ea48c2be 3 | size 1048588 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e17201583d346161ca6872298552ab05e0c3d0e1cecbc67adba0848a240cdfc4 3 | size 1048588 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:323a3642f548314af50de9c5e88e25de7aeb435ed10cd44086bbc55f44d50ebe 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a12d32a2fc58002ec4d17364d4e4584ae3fc9605fd916fa0a5ed5981ae20560e 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:71e19eb3a6b3380b73d5bb7e20305ac26e956adf6008b0a4538ebdde7e2724a2 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0af23d5fe016b5a835af49472c3bc85f1967600bdc37440836332c200467c966 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ff146382a59cae41d59167e77d9392b03331945426f34ad34c47a775d661631c 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a707fc005c43a316ef7654e5a04fc8c682dbf5559bbb7e8314d9582047f68e51 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:35a747a52ddaa8c95dda2880b79a2947c78c44889b3f7559bf41cf3ae8e06c0a 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8f568141851f62cc7887af55a9e63cc4500965f9b21763a60241b9e39f7fcd5c 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8f1e30a65367a08ab0718ad3516bc12c2f033ff8899fc119c19b6165ea48c2be 3 | size 1048588 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e17201583d346161ca6872298552ab05e0c3d0e1cecbc67adba0848a240cdfc4 3 | size 1048588 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4bb415c586a70f56152ae09f6e5395c17efd82c6f16b2e86d9d4edb4dd8e5acc 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8b7099a734e5be6876d05506c4062cfa94a6a4782eedb3a5e240f7cb6816a775 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5d150a541d3723b5973eaadf2116221bff263f0744a271389de271f5fdc21f16 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_1/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8054c4d9bd772f419dc2ca0c649c441f4eb435df4d84503fde7df648e2a06cb1 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:20c03c1962748bb752bcf3e44c719f0c4723ce2f0e2d4654566dd858b3fe90e0 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e23d23d0b4793b8b4b676086d18d8eddde4a2396a55b65c3bae93b66177a0e0c 3 | size 135 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/mobilenetv2_100/dynamo/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e9b234da9285eb41d80ba90c483e725c7fbe8fbf3323eb513a1c57468e89d5b1 3 | size 602128 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/mobilenetv2_100/dynamo/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2a50d91a03784ec6a6f650b58b62f6ca3bdef9483f94cbb62911b86991680f3a 3 | size 4010 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/attn_llama2_4_34_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22c54ffbd19ec835f054ce4da66c34605654cdaeaab7e4cddb7afdf5daaa9e77 3 | size 30233 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/attn_llama2_4_34_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7ed91e90b6f53c400de9576f9e3cd148575d836e4e0326e1775acf9e7462b8cc 3 | size 30349 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/attn_llama2_4_36_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:791944ad35bae89819a0a3448c8cb8a733a0a9bdeefff085af5cb3028bebdf16 3 | size 800895 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a44bf5864390eef1f1b54f464b619a7a283041dd6ce5da65150af5c708051f9 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d15975f1d254f650321ccdd14c3157d9eac1ca2cf3567e6c159bcdd278488f82 3 | size 524300 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5941ca97ca1ca39a863353b19409ddca9bfda4da0e1f471e82e449207f5afcf7 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_10.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c500808f88f0c089b75163ca6677921f617e391736f13365471b3dc6fe199e84 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_11.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2e44bb9d0e8473fcc87d68760c92df021cae64b82fc0f73507e38ed8de2096aa 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:83c167b37147b1773b7aaa680be07baae7c3dd7adbf7c0eb2e33e15deecbe97e 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1abc4e3deaa0e5c79c2e0501e82dd8d42af85e79c9ba9d12fee672e8b506f785 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:77b2a9c58e03d0cea4a130e2c93af40ca5522e809b505a788116c42f10a0bb6e 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/input_9.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:df68178de6799d7bd70879efd224c66eab433d71cd7396bd66f046ed5902bf6c 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f5ea134d4b49c784a9b44cce0e6396515cb0cde3e5c5e44f3d93e7ee8aa81146 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:73f8e4c8da4389e456f9685732550ac52575e2789799837c36106b7564f376a9 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e08d3f65d45c98eaede04a47f5e1fec8917d19f8c84ad8ae720f29a7ca1bc26a 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9658a3943b84436266dffac8e1c3db88d3789da3f9311984c9160f12874e7c1c 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_10.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c500808f88f0c089b75163ca6677921f617e391736f13365471b3dc6fe199e84 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_11.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b381fb61a0f133b247d2b48fc9ae6d4539b19b73104b64784ba6c85527cf8fc9 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:590b7408923d0def097d718cf3d9128a81c7f2fd17058730752d6a891bf6ced6 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6262fda6a541a87aa383723ba045bef516dd5fe7a52619bdd59e9fe2ef4c9c1f 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d984f4273cd80fc37ff15e4bb08de8562059fdfdeffbf74c419015c729af6a1c 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/input_9.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:df68178de6799d7bd70879efd224c66eab433d71cd7396bd66f046ed5902bf6c 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:43f5c6c09e8e2db1e20152aa0ae22aed6ab516a99dabb33f1029b83bb42706fc 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ff1c4e67ccb447e6031ceba071b505992aae7c45165b420a93cd981904b5b1ce 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_1/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b031bddd7df63733371c82e48278c1f42d5051759a081981c9b86a1c74accabd 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b3236b6abb79011d00aae3042eb9b17df2682011ae37746b8919d9c0cbf869b3 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_10.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c500808f88f0c089b75163ca6677921f617e391736f13365471b3dc6fe199e84 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_11.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:41d90523a8dcccc88d0443c0e7bd5d4cb8b85b4548910dfea63e5c9bc0cef70b 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:38176fdc53d14638c91e46de47f3f3472bc3145e1782a1cd8c0b5decc1afe3d3 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a6ce1210a9fc318fd9578c3ac94632114bf7fb67eb701620b60b125fc7b9231 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:82747fcde0ec8dcbc77dcad5b8917502b37ea85b3cef04cec3fbec1ffed12813 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/input_9.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:df68178de6799d7bd70879efd224c66eab433d71cd7396bd66f046ed5902bf6c 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ae3b921f6da0f0afd4e5780d2179576c6567b8dabae0909161efee85bb5cd1f3 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bb1c41ef18b7bcba3eb2e2f4ffb52bed556b0c90287ea07c8e5d6fcc059282ca 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_2/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6299375755089f487d590d4e989a644920b6f184b038fd94f5c7c4ee372af003 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a68df946202c3c8d04414d13fd344f57fbf5e9b7190e3918b66672e88c5be127 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_10.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c500808f88f0c089b75163ca6677921f617e391736f13365471b3dc6fe199e84 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_11.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5d06afa33b56aaa12620a9881a9665fe75509f3efe7cb5ff1ae7987ffb7e6ccc 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:220b8f93f6f0337545121af549580672514477098edb64d6a63253c82c807cb9 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:60fca48da78a1feafb31d4b3c3bbedec56a5b0d99c47f35c2c080338e80e780f 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:84e261119d5c0ef87d12263774805937b4ec9848e78cc08c042dae142764cbfe 3 | size 8388621 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/input_9.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:df68178de6799d7bd70879efd224c66eab433d71cd7396bd66f046ed5902bf6c 3 | size 131083 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b05aac6e6f39644f01328190b4cda3be2f735125b13b929a1cba9ab9bef86a99 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f4cb6e3668905e8136ae1a4523295f15eb4b2db9b9c4844e0766cfa62b46d762 3 | size 2097168 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_phi_1_5_3/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:19c82d7dac70715375b0055e8e480304ce344217d76734b3719f942c06525ca1 3 | size 2097167 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3e82a1c4ff1754d1fe9e470b56c14e91ba6837713c840d8a51b73a0c797f3823 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d77af46feb251c72b7df238f10c3f2e3bd9baf84813dd0efd415105948e2adb8 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fe0ecdda5d8aa3579ba6a1d3a70e9527a0c9482eb3f28c06771fe9fff6780731 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b35459131cf1408e9a34589ce199cd7505c77ca1b6c36f387abddf025af2c4f6 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c4cc6c3459eaf88b7f4666ab404d9a834e76484d3436246ccfcf0d2fa9886951 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8f1e30a65367a08ab0718ad3516bc12c2f033ff8899fc119c19b6165ea48c2be 3 | size 1048588 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e17201583d346161ca6872298552ab05e0c3d0e1cecbc67adba0848a240cdfc4 3 | size 1048588 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:323a3642f548314af50de9c5e88e25de7aeb435ed10cd44086bbc55f44d50ebe 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a12d32a2fc58002ec4d17364d4e4584ae3fc9605fd916fa0a5ed5981ae20560e 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:71e19eb3a6b3380b73d5bb7e20305ac26e956adf6008b0a4538ebdde7e2724a2 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_yi_4_37_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b9aaca1e11d01b536c0f6246f1850cfc07ecf6c02c319253ccfe9b267bdbce86 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1eb70478bc7ff108daa03523ba309fd7ba6029160a67360b4e5bd8b3015e41fb 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a9ab6fa6a35446500dff970a00ee60dee0791664c09e33ee9c19eaa246983ac1 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7af424dbc83aee3fbd3e181b1b17d2d5dbc96a969687aef01830820b4e451242 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f9692832fc46ed0f14fc0986be75579e55abde433a831b256f9bd1be6b20a06f 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_2/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e9f0098eeac6bdefa568d9f392111c60fe2ccd6e5613c244912d3cd175b18a61 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_2/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0611a4cf6b215e467fd1021749d7b9f9c6bcfcdc0fe071fdd0a9a0d8166a66c6 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_3/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:11233c9d4a4f43e93b5d046346c992da00a49a7db7ced1179ce70b44df5f3664 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/gelu_phi_1_5_3/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5a4ee9b1cef233ad5bd6ed49d01cd369fee05024e41662dcf2f20b5273784d98 3 | size 8388623 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:778b4cdb9a8da368ed72d53e069a8ddf9a0830d51e21d6d3633824ea5d3a1e59 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dcbb1bfe97bb59144e109dc32f00dbc7c6782691da11e841b150775d73c0e4e9 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c21e9d621732c18df7a97d6f0e09c040ad25e59921265c5b5f2865166dccbd0d 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:373639b07d8966f9aaf2ad40bd21ecf1b501fbce44982324a66b3571fd87c04e 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b38092781e2fdbd15794b253e331285aed57305e1639f8fb0da83fedf6f1110a 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7b6872fcb8348cce2cd37199979c9ef5fa046660f8c5f30ac68167c130b02283 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b4ecc3c6db5513df9e1d36cc96d671e1e1606fc26f10f3a05b0229d13f962306 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:847df9acbc6d8ae0542420c32fb0b7eaee3c4f460b7b0f850a405586e9bac479 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6f438ee4996790f71091a1d411b27691a80eedc365b2b019a0cfedb05b9adc2f 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:93dd9424a7dcffdeb1dc9323215afa04394d885a96f02168336b1499a5a2ce7b 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:21d7d26f218433bf1ce7d00dae722a55ded01e2f2215b00111c87912a1f25493 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:34f5cb05c1e0b2f205c97ee0bc2fb6ca8660dd6f6d2e2ccc425d09043fdb9b08 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:86b6d05cdabf287de5bd1a0100b943cc0a3279ae1e68b692c27071feeb3a7ded 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:16c69fdb0853b67c0b8db326391ee74b70708feecd1150e628abf25b4a080b42 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a2a7d6d62d0b7cbd671f9003b66b65debe5d3100bb43a4342ac87fc9de0cf27f 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_1/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:512c99995fb05e846f2f437e1d02f4594f53536986bfeb660e88bb97994ec5cc 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cc8d9eea571158d4c0926be5ecbb9b749d6fdd4a9f48d9e5fb04ebb4d343f07c 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4d75cc8150f705405f5a98b6ecbf49de0ca0a732124e60a56e4cea9b8c0aa73e 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:33c01d9c6ef6427e8a680a810dc17944efe9aec5bccd0a67ba38abb2213f2d21 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c48cafb2ba842be9bb90f206056b4b78812cebfa3f66986dca0a697aff4ac8dd 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:101c20fe6e507456307fb25c583672fd163444df7468856823523d09427fc1b9 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:97fa244b848212ffb598698dc6c6d865bcb80234946c804e751fd3e8739520af 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:683587dcabb2862944bea11c6b55e950b7e5c0c7732daf8e3fe8b05a7e015453 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_2/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5972eb073f74f7599e9c0fdc348d2196fe5f448787d923346ad3bdd55752ed16 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:37b6432a636da58197893e78a34b7db33770f165ee4534b3c6ff1023d7747d2a 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aded299cc07e16816e2641e7245845296233948b432394894ee89c8f0e4a5173 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6c57896892bda7fc78d66afd6f2af2f229912ca02e662192fe0d4629e094f405 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:efa03ee5d35e6c46164b0ecad3045c0f09a282e55ce71d281e3866babdc57b30 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8a47b688521256d24da5f1c8da624ddd439cc401755ea6e8b84ede14fe9b2e33 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dfebdb51021c7fa776577e6629adea74d46a0e9a7ca76604e7433c054457ed55 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9d1313b293d4c8fea2622f3ce4350bc420394af9e9c7fd700b8476341f391d92 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_3/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:51408621625025e6fb828f9712a9da6f56d9d6e50d2660d38c168abbca4a83d8 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/sdpa_llama2_4_38_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:32a29a23df6eb1dda62e073d80d0b42aa4d9506ac0d732a5857870f8282dc926 3 | size 274363 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:04286eebdadde98ff59ca4ebcbcb6aad797aa995728cd6b76f5948a8a7586fa9 3 | size 4106 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:20c03c1962748bb752bcf3e44c719f0c4723ce2f0e2d4654566dd858b3fe90e0 3 | size 4104 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9c60c6ca7c4386b6b76700b348fb75d0d42b23463fff73eaa4a106d23d801dde 3 | size 135 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3e82a1c4ff1754d1fe9e470b56c14e91ba6837713c840d8a51b73a0c797f3823 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:199ec6dcdba5dd17b7b36b221b0808db110eab945081f814a6f185e82b51950c 3 | size 33554449 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fe0ecdda5d8aa3579ba6a1d3a70e9527a0c9482eb3f28c06771fe9fff6780731 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b35459131cf1408e9a34589ce199cd7505c77ca1b6c36f387abddf025af2c4f6 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c4cc6c3459eaf88b7f4666ab404d9a834e76484d3436246ccfcf0d2fa9886951 3 | size 4194317 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:323a3642f548314af50de9c5e88e25de7aeb435ed10cd44086bbc55f44d50ebe 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a12d32a2fc58002ec4d17364d4e4584ae3fc9605fd916fa0a5ed5981ae20560e 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2ec009fdc25a78ee3d6d7e0da303f60ff5312a87c6f1f2d4cc1dd144303b15ab 3 | size 524304 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_yi_4_38_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:73e21e6c015872857614dd6f3682a6abcda3680e1bfebea41b95f7b47eb4ca6e 3 | size 4194319 4 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Shared constants for the library.""" 4 | 5 | DOMAIN = "pkg.onnxscript.torch_lib" 6 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e3134f09a4c5b06cbdf29158ccf758554f8844403c616c2905bfa26a99a8d0a0 3 | size 1034 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:951a7cddaed4a979aadd89c63f90517920f1b2ba5ad008393ef502b58b88535b 3 | size 1034 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f5f4d3b73ebce58ef8baa8b74f2aabff8b31337baf133fbd4db7be028d824b39 3 | size 8 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/mobilenetv2_100/dynamo/mobilenetv2_100_dynamo.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ba424976b53bf2f141bfd001b48c0cc1c5c798b49def51f39a72f17e1f74e3a2 3 | size 14673089 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:707e2139fa3b9db89e8667ad7b1829fbf1c05c678f064dbbdc855e77cee50b32 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2d34d627c716ad6e7cf2a302c29605655d94cd7bbceba7b02741612acdafbe27 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6fd6f8eb0ae294d2885e027e7c842377b48a95d4abfe0f4b4a0a191d9c846207 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:83ac8df43b3731643c69f628c9842a0b4b9c1a97d544a15906743a3071eca3f9 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c5a18f5d0f1f88bc8d5a403763a11354846870bf8dee98d4fd5aed3eeb3c919a 3 | size 1048592 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:23b0dfc60d794b1291cf52f9b65b9190485e3c07976947467c1bdba6cc283443 3 | size 1048592 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:983c5ebdb5e94954b10bb9dc90d9f21dc1b0d0618a6563db48b7dadcf5697f57 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d5cc227ef6865239083c47b73ad5b051fb8b348f61d6b0b56cdf7eafc56618ee 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:74999e531bab9143795421abf912611699e976c95458c98f0c11236b3a6fd935 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7fe871ab7d24854fb3e216dbbb9e150204594685c1babdeb3debedd380ea605c 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fdace10343a44a6c0d71d2bfb3a0f9c27df1f787120eb40e62d5f10c967a187f 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6516581d07d3c0128caf311423f81ac04a11ed791126d68cfedc60bf0b5116bf 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:276c7a6a379955acf2c6bf1fbb69e7b1914ff420801e280d359f5f264415e981 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ca7d1ae2782defbe040a7129d40c1594783f282e4ffb63500269176d76a52743 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c5a18f5d0f1f88bc8d5a403763a11354846870bf8dee98d4fd5aed3eeb3c919a 3 | size 1048592 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:23b0dfc60d794b1291cf52f9b65b9190485e3c07976947467c1bdba6cc283443 3 | size 1048592 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d4aca46405c62018d694d58f3b65eaad75bad998f3452a1c11a3310062e637f4 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dbc69d1383d85f23721912806104a8e74157bd11113da70c2c737f1eabccb77b 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:70706688fd0d87108dedd615e7b32c4009c0821d9022701df3c3dd52c0c7a0a1 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_34_1/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c766421e7c87ed4d3be345aab6b1c32bcb229a8d122b683279cef9b123069beb 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dcf6c8416670332de11f3fe6efc6e41197ba7c175394c0fc38a98710bfc4ff43 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a994e919c415c5b8acdca27fb87fcd06d7036d646fc0a770929d09024e6d96ae 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0e2fa19eab256f8a81b4757e37f99c49aaba1333a55a2c96fabc989d4de2d0f3 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:db733c3917275c5341cba7bc2a64b5a2dc1abb1c4c01ae5852031eb94e0e2f0c 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aad340617afb9b743c37a1c6fd08ec2e509c4b22642a81bb60aa29d9f27d5c1c 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e85913fc823ad2058c3c339a2aad4160e1fcbcab5a9881c46ca390256c1f17be 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:416bb2a6eb20bc2312862c6ff475b23a9975935f4de0f520e7e5dcff604a37ac 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_llama2_4_36_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c04d8c70045f317d2e4603ea3737a2e82bdb4335a7e13bea37c09ee2ba8e9388 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dcf6c8416670332de11f3fe6efc6e41197ba7c175394c0fc38a98710bfc4ff43 3 | size 4194319 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:259cd77fb1aa09aa4b06224754bdcbcecceda18dddb98dbb09301c79c0c06409 3 | size 8388625 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a994e919c415c5b8acdca27fb87fcd06d7036d646fc0a770929d09024e6d96ae 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0e2fa19eab256f8a81b4757e37f99c49aaba1333a55a2c96fabc989d4de2d0f3 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:db733c3917275c5341cba7bc2a64b5a2dc1abb1c4c01ae5852031eb94e0e2f0c 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/input_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aad340617afb9b743c37a1c6fd08ec2e509c4b22642a81bb60aa29d9f27d5c1c 3 | size 33554445 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e85913fc823ad2058c3c339a2aad4160e1fcbcab5a9881c46ca390256c1f17be 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ae24404fde2f02499993f7ba93fa23d5b8fc801791a0be85a46251a6722e66b9 3 | size 4194321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/sdpa_llama2_4_38_0/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:759f063994330e61e4aa715dc0fb734e7e416c0c822f84b2d695ec73e218b8a1 3 | size 4194319 4 | -------------------------------------------------------------------------------- /onnxscript/ir/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | # pylint: disable=wildcard-import,unused-wildcard-import 4 | from onnx_ir import * # type: ignore # noqa: F403 5 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:27c22e64073f98615cf492bf813a6c0ae44261094dbe368f47eeb91a14f8a7f3 3 | size 5120015 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_10.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5d599ff9f092e837ee9825af7b0f5f0239c43bbde485834fc971e4a10e5d6315 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_11.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:400d856a814258cbf95320dfcb36ecc8a5b47f8295fe034944ba51a14bc036c1 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_12.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4c00b77782b8793a2dc8b3af42578c3ff3467248e536ee1cb7f85859da085b8b 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_13.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:58ba0f2a898467cd5143c46a3389b7a7d572ebd4a7264c2264833ec69d14c803 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:015c8d9c96efbb22043be290f9a73ea1a74dcb3cf33d2e8fe6c13b7f6cb3f92c 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9b8fedb07987d6d782b3fa8d4dc07b1c91eafbb4059bc78cbf3b78a2f6759d4e 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1024114644e9c56161245fe9bfcc92a4b5788f6edd19278d50d6234b3b314cfa 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:63b19f4cf067fd128e37d5acde172f292ff4cd25aabaeeaf94e2dbff982d0583 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ff2e579758329f7c0b44d2dcaca4b8afda5bdd9b169409ba20a83bb2aed495d5 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_7.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:12c7bbb02f1da162fd425fa59e82e8f783e79e0f0f849b42a7853dbf582c017b 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_8.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:18665f3e0925a5d16cdb953cd6b3739e077e5713fbabdfcf987cdedde8f8c661 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/test_data_set_0/output_9.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d078a9178afaaefb2a87aaed53558b7b560b02f37d747c9bd82d61cb67eb5ab5 3 | size 131087 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a9123c6554ff4d7314551d483f9094d87242a7f4c37244e749db9d4645e4b297 3 | size 2060 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:253f5e6539e7f85ea8b3e62c253308f8309e836099d2bc80e4b349bba4198a71 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a7b87c3af883c4914b77dac7f4eaa0d5c0537ca208e003ceaa8c8458a430b79e 3 | size 655372 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d0a14710d96f88687271c91010609c9767741282c8736d410e65776f055d9022 3 | size 655372 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ccce625f60f9b8a22752b14efc04ddfbb4b1b86d7cd158de8bb738ba592529d3 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c987816fb124802ffcb8e454d1775760419c3a589f400963b34e638da4f03264 3 | size 648 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a9123c6554ff4d7314551d483f9094d87242a7f4c37244e749db9d4645e4b297 3 | size 2060 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:75b8a9ff46821223424751ea8623f28fa874a08078a20e824ac64cdbe4f4f080 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:85c736a78bc193939361a1a5c70f15d485a5f3b195e392895476129c11268bec 3 | size 655372 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ba47a7b359e8e83e0992c5379bd8aebed1829c5b9e076c1f83cfbfdf802ae4e4 3 | size 655372 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:179d9b92f75a1f49da5ab08d120a8e368b4b8328ae33cbb246a153ceac394d9e 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_6.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:db4fe0a2c9df70cf78bb9c3ae5ba56ee5dc2bd97182035cf8281b4e6eb505c35 3 | size 648 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e15919ec6e9fb9bf14ceab8ef1b86141df826a041abb2afd708c6742e3187545 3 | size 5128 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5f4d7e42c0517cf3b3fe3eb81f7d2feb51ccfef98858f54a8d77791bbaf200a1 3 | size 5128 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_2/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5d82266d095fd70f7769fcf1a17d02dbeea6d654570726d5cc0a9df940a8f84d 3 | size 10248 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_3/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:41dfa32228969ffb5df855c9eb3493bfb03582d15f4c4d762f897cfe8f6a1fce 3 | size 10248 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7cbd3a7ebe268f4c5133dd4260f7a584f928f4bc234b94acfaa28477aedf4e8c 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:45b669a398c141036e6c3dac09740f875211d19a0e753bd11463db03914141bb 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:613695863f84e1ea2f7ed2c40b48f1cfc90aa019c7f5c9a13dc058a3350ba56a 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22fa6a580cb5b09c666822f0885bd74e9cf1a9ce20a32cc88b962c1bb8456bf6 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:98e824d25685964e3a3f560f244622c4e8e203d200e49b09df6763526e594851 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ffd8964762910ea6df29048a3d6a7a87b67977da593142447a8a8698c1c6500b 3 | size 1638412 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:78d79391169402755077e40f0c52aead8a42676e0dc5da72b9b65f063c22a2fa 3 | size 41943056 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f0e975942dfa6109813e0c36977764eb32fb2a85adf907481e3279d8bf84d79d 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cbce1330aebb786fe6e2c1ab29fbf381033d46b2c8fc8c22e87729f6134c0b30 3 | size 1638412 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f4c575f295201e48ae8d072ff9b182728ba72711e27d13982906c4ed5aeed0fa 3 | size 41943056 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_2/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a08c8375ce70e3083c87befd339da05d73fe82cbdb92f7af2d5676613ee3a6ba 3 | size 5242895 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_2/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7f647797d31adebe7ae5a7b54afa9d87550e2516a077266b916bdbc8ef0d3977 3 | size 6553613 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_2/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:56b4cf21c438271157e7c26e26a4f9249620c9c5a71696c496703643e24509bb 3 | size 20971535 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_3/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7dfb8f99b2d2542425b7530d4feb73f46b8814931cda9a2df9d40df833244358 3 | size 5242895 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_3/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f4a6739cfc2a451cba85a8fd298483fbe488a2cce75a1b61ba25f2efa670c5a6 3 | size 6553613 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_3/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0305e96c396ccd3ccefd014f9705348ff50540f16a4730de1ead4560b9c484d8 3 | size 20971535 4 | -------------------------------------------------------------------------------- /testdata/e2e_models/Speech2Text2ForCausalLM/dynamo/Speech2Text2ForCausalLM_dynamo.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6dcf6976f8e324c497b0b74b2b9733c4b454f2c259488f5544bbc1aaaf57714c 3 | size 43091738 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_0/attn_stable_diffusion_unet_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:29d233e3bd288d34719ded40b44ea4049858144a6563418caa74faa49a94aabe 3 | size 1730321 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_1/attn_stable_diffusion_unet_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a87363b7b2c6dddbfd72adb5e22a165729b8756ff95e4d2f3c5abf01ad42ab91 3 | size 1730335 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_0/geglu_stable_diffusion_unet_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:00a1a44a1ca33b46dc009e092b9d1a99afbed0f9ed3e1f2e96d1dd447d48dbc3 3 | size 4591 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_1/geglu_stable_diffusion_unet_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:26fc7bcf1eaf5a546b37ec8cd196f00e76bbea69ff5c8275e412fb4f847d708d 3 | size 4600 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_2/geglu_stable_diffusion_unet_2.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:59512157d98bcbc2d15fd91ba477b9e0e31697de1fd319807dba5892d06e881d 3 | size 4592 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/geglu_stable_diffusion_unet_3/geglu_stable_diffusion_unet_3.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:61534fa7078c32b2ccb7e4a8ff0bb54b9bcb0ce3bb60662576570f60efff0d88 3 | size 4603 4 | -------------------------------------------------------------------------------- /onnxscript/ir/convenience.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | # pylint: disable=wildcard-import,unused-wildcard-import 4 | from onnx_ir.convenience import * # type: ignore # noqa: F403 5 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d6f6ee7a66f70abbb4eeb09dcaefcee989107e75e75fd10ee88047a335ef2f99 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:774e3826110d1042bbdabc63bef06bf34ba4835dd53592cf48fdad8c0500cacf 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ed4b34f65ae24ee2513c6aeacac76b6ae1da36e273949ddb89abf1aaf3ddbf27 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dd578ddf3c26faee41e5e3f63039b6c133d9a7561c75ecd39c8f0ade1ebee5ac 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:80b564d4c454130e226d9e6eb736fd6daf1d7dfb59a98ecc0231b4475faa867d 3 | size 648 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/input_1.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a4d7c62f9fbfb149662a81015333b573e2cee7cb2f0c512c9ac244a33dabebc7 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/input_2.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cf8d49cc028ae7df828200b3907e3c2a3229d23e1893eb5d50eb2e6aa57e01d5 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/input_3.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a08b23c744b92bc8fd7461d294e8bd05884f72939d65a44d38a3602c2069090d 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/input_4.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0bd9e0fa1651f9fc3758e8ac0996aa6fd78ad9e8d0a9511b67714da74963b7f7 3 | size 204812 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/input_5.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a0479dcf1030c4d21f8d03e9f519249a5e995a75875199cb42f2c6660dd07f2d 3 | size 648 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a155c68af7b5f774e8cd35367f8a64b3d2e710b2fb855654eea3b1f295eea88f 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:87ebf96028626265bb70249cb7b962d769530daeef8248f38fc26368584f0ca3 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/input_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7b433b528495798e9322a9df690e5a8d50d93f0c1c948cdbbd19d2276a4957bc 3 | size 10485776 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/test_data_set_0/output_0.pb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1b0c59e7f76909f0f04ac65827515b41f235715721400a3912a5cccf2015ea96 3 | size 10485776 4 | -------------------------------------------------------------------------------- /.github/copilot-instructions.md: -------------------------------------------------------------------------------- 1 | ## Code Standards 2 | 3 | ### Required Before Each Commit 4 | - Run `lintrunner -a` before committing any changes to ensure proper code formatting 5 | - This will run lintrunner on all updated files to maintain consistent style 6 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | # include 2 | include *.rst 3 | include LICENSE 4 | include README.md 5 | include VERSION 6 | include MANIFEST.in 7 | 8 | # exclude from sdist 9 | recursive-exclude onnxscript *.onnx 10 | recursive-exclude onnxscript *_test.py 11 | prune */__pycache__ 12 | -------------------------------------------------------------------------------- /docs/ir/index.md: -------------------------------------------------------------------------------- 1 | # ONNX IR 2 | 3 | ONNX IR is now an official ONNX project! Documentation has been migrated to [onnx.ai/ir-py/](https://onnx.ai/ir-py/). 4 | 5 | You may continue to use `onnxscript.ir` unchanged for compatibility with older (<0.3) versions of ONNX Script. 6 | -------------------------------------------------------------------------------- /requirements/ci/requirements-ort-nightly.txt: -------------------------------------------------------------------------------- 1 | # https://aiinfra.visualstudio.com/PublicPackages/_artifacts/feed/ORT-Nightly/PyPI/onnxruntime/overview 2 | --index-url=https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ 3 | onnxruntime==1.23.2 4 | -------------------------------------------------------------------------------- /docs/tutorial/examples/firstdim.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def FirstDim(X): 9 | return op.Shape(X, start=0, end=1) 10 | -------------------------------------------------------------------------------- /docs/tutorial/examples/tensor_attr_short.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def tensor_attr(x): 9 | return op.Mul(0.5, x) 10 | -------------------------------------------------------------------------------- /docs/_templates/functiontemplate.rst: -------------------------------------------------------------------------------- 1 | .. role:: hidden 2 | :class: hidden-section 3 | .. currentmodule:: {{ module }} 4 | 5 | 6 | {{ name | underline}} 7 | 8 | .. autofunction:: {{ name }} 9 | 10 | 11 | .. 12 | autogenerated from docs/_templates/functiontemplate.rst 13 | -------------------------------------------------------------------------------- /onnxscript/rewriter/onnx_fusions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | from onnxscript.rewriter.onnx_fusions._onnx_fusions import fuse 6 | 7 | __all__ = [ 8 | "fuse", 9 | ] 10 | -------------------------------------------------------------------------------- /onnxscript/tools/__init__.py: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | # -------------------------------------------------------------------------- 5 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_0/attn_stable_diffusion_unet_without_encoder_hidden_states_0.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:26b1befffc3399801cb147081ed137182bc0b5f08c1a3c4d2a8b5d9685e53e91 3 | size 828870 4 | -------------------------------------------------------------------------------- /testdata/unittest_models/attn_stable_diffusion_unet_without_encoder_hidden_states_1/attn_stable_diffusion_unet_without_encoder_hidden_states_1.onnx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5e74b7617b0d12722078667564d66d29f4dfee8b52c129509e54e1965084099d 3 | size 828905 4 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # tests 2 | 3 | This directory contains integration tests and common test utilities (`common/`). 4 | Module unit tests should be created next to the module source with the name `_test.py`. 5 | This makes them easy to discover and obvious when unit tests are missing. 6 | -------------------------------------------------------------------------------- /docs/tutorial/examples/leaky_relu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def LeakyRelu(X, alpha: float): 9 | return op.Where(X < 0.0, alpha * X, X) 10 | -------------------------------------------------------------------------------- /requirements/lintrunner/requirements.txt: -------------------------------------------------------------------------------- 1 | # This file is auto updated by dependabot 2 | lintrunner-adapters>=0.8.0 3 | # RUFF, RUFF-FIX 4 | ruff==0.14.7 5 | # MYPY 6 | mypy==1.10.1 7 | types-PyYAML==6.0.12.20250915 8 | # PYLINT 9 | pylint==3.3.9 10 | # EDITORCONFIG-CHECKER 11 | editorconfig-checker==3.4.1 12 | -------------------------------------------------------------------------------- /tests/models/m1.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript.onnx_opset import opset15 as op 5 | from onnxscript.onnx_types import FLOAT 6 | 7 | 8 | def cadd(A: FLOAT[1, 2], B: FLOAT[1, 2]) -> FLOAT[1, 4]: 9 | return op.Concat(A, B, axis=-1) 10 | -------------------------------------------------------------------------------- /docs/api/values.md: -------------------------------------------------------------------------------- 1 | # Values 2 | 3 | ```{eval-rst} 4 | .. autoclass:: onnxscript.values.Opset 5 | :members: 6 | ``` 7 | 8 | ```{eval-rst} 9 | .. autoclass:: onnxscript.values.Op 10 | :members: 11 | ``` 12 | 13 | ```{eval-rst} 14 | .. autoclass:: onnxscript.values.OnnxFunction 15 | :members: 16 | ``` 17 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """A torch function library for onnxscript. 4 | 5 | The modules are named after the torch module names for grouping: 6 | 7 | - core 8 | - nn 9 | - fft 10 | - vision 11 | - etc. 12 | """ 13 | -------------------------------------------------------------------------------- /opgen/README.md: -------------------------------------------------------------------------------- 1 | # Generator for onnx_opset 2 | 3 | Use this module the generate onnx_opset implementations when new opsets are introduced with new ONNX versions. 4 | 5 | ## Generate 6 | 7 | ```sh 8 | python opgen 9 | ``` 10 | 11 | Run 12 | 13 | ```sh 14 | python opgen -h 15 | ``` 16 | 17 | for more information. 18 | -------------------------------------------------------------------------------- /tests/models/multi.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript.onnx_opset import opset15 as op 5 | from onnxscript.onnx_types import FLOAT 6 | 7 | 8 | def multi(A: FLOAT["N"]) -> FLOAT["N"]: 9 | x, y = op.Split(A) 10 | x, y = op.Split(x) 11 | return x + y 12 | -------------------------------------------------------------------------------- /docs/_templates/classtemplate.rst: -------------------------------------------------------------------------------- 1 | .. role:: hidden 2 | :class: hidden-section 3 | .. currentmodule:: {{ module }} 4 | 5 | 6 | {{ name | underline}} 7 | 8 | .. autoclass:: {{ name }} 9 | :members: 10 | :undoc-members: 11 | :member-order: bysource 12 | 13 | .. 14 | autogenerated from docs/_templates/classtemplate.rst 15 | -------------------------------------------------------------------------------- /docs/tutorial/examples/leaky_relu_attr_promoted.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def LeakyRelu(X, alpha: float): 9 | alpha_value = op.Constant(value_float=alpha) 10 | return op.Where(X < 0.0, alpha_value * X, X) 11 | -------------------------------------------------------------------------------- /onnxscript/rewriter/ort_fusions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Fusion optimizations for ORT backend.""" 4 | 5 | __all__ = [ 6 | "optimize_for_ort", 7 | "ORT_PATTERN_REWRITE_RULES", 8 | ] 9 | 10 | 11 | from onnxscript.rewriter.ort_fusions._core import ORT_PATTERN_REWRITE_RULES, optimize_for_ort 12 | -------------------------------------------------------------------------------- /docs/_templates/classtemplate_inherited.rst: -------------------------------------------------------------------------------- 1 | .. role:: hidden 2 | :class: hidden-section 3 | .. currentmodule:: {{ module }} 4 | 5 | 6 | {{ name | underline}} 7 | 8 | .. autoclass:: {{ name }} 9 | :members: 10 | :undoc-members: 11 | :inherited-members: 12 | :member-order: bysource 13 | 14 | 15 | .. 16 | autogenerated from docs/_templates/classtemplate.rst 17 | -------------------------------------------------------------------------------- /.github/codeql/codeql-config.yml: -------------------------------------------------------------------------------- 1 | query-filters: 2 | - exclude: 3 | id: py/import-and-import-from 4 | - exclude: 5 | # Module level cyclic import, although should be avoided, is not a problem 6 | # from the perspective of functionality. Follow advice on 7 | # https://codeql.github.com/codeql-query-help/python/py-cyclic-import/ to break the cycle if needed. 8 | id: py/cyclic-import 9 | -------------------------------------------------------------------------------- /docs/tutorial/examples/forloop.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def sumprod(x, N): 9 | sum = op.Identity(x) 10 | prod = op.Identity(x) 11 | for _ in range(N): 12 | sum = sum + x 13 | prod = prod * x 14 | return sum, prod 15 | -------------------------------------------------------------------------------- /docs/tutorial/examples/tensor_attr.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnx import TensorProto, helper 4 | 5 | from onnxscript import opset15 as op 6 | from onnxscript import script 7 | 8 | 9 | @script() 10 | def tensor_attr(x): 11 | c = op.Constant(value=helper.make_tensor("scalar_half", TensorProto.FLOAT, (), [0.5])) 12 | return op.Mul(c, x) 13 | -------------------------------------------------------------------------------- /docs/api/index.md: -------------------------------------------------------------------------------- 1 | # API 2 | 3 | ## Author Models 4 | 5 | ```{toctree} 6 | :maxdepth: 1 7 | 8 | decorator 9 | opsets 10 | converter 11 | values 12 | ``` 13 | 14 | ## Model transformation 15 | 16 | ```{toctree} 17 | :maxdepth: 1 18 | 19 | optimizer 20 | rewriter 21 | rewriter_pattern 22 | version_converter 23 | ``` 24 | 25 | ## Testing 26 | 27 | ```{toctree} 28 | :maxdepth: 1 29 | 30 | testing 31 | ``` 32 | -------------------------------------------------------------------------------- /tests/models/attrref.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript.onnx_opset import opset15 as op 5 | 6 | 7 | def float_attr_ref_test(X, alpha: float): 8 | return op.Add(X, alpha) 9 | 10 | 11 | def int_attr_ref_test(X, alpha: int): 12 | return op.Add(X, alpha) 13 | 14 | 15 | def str_attr_ref_test(X, alpha: str): 16 | return op.Concat(X, alpha, axis=0) 17 | -------------------------------------------------------------------------------- /docs/api/optimizer.md: -------------------------------------------------------------------------------- 1 | # onnxscript.optimizer 2 | 3 | ```{eval-rst} 4 | .. automodule::onnxscript.optimizer 5 | .. currentmodule:: onnxscript 6 | ``` 7 | 8 | ```{eval-rst} 9 | .. autosummary:: 10 | :toctree: generated 11 | :template: functiontemplate.rst 12 | :nosignatures: 13 | 14 | optimizer.optimize 15 | optimizer.inline 16 | optimizer.basic_constant_propagation 17 | optimizer.fold_constants 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/tutorial/examples/softplus.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | # We use ONNX opset 15 to define the function below. 4 | from onnxscript import opset15 as op 5 | from onnxscript import script 6 | 7 | 8 | # We use the script decorator to indicate that the following function is meant 9 | # to be translated to ONNX. 10 | @script() 11 | def Softplus(X): 12 | return op.Log(op.Exp(X) + 1.0) 13 | -------------------------------------------------------------------------------- /.azure-pipelines/stages/release-stage.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - stage: Stage 3 | jobs: 4 | - job: Job 5 | steps: 6 | - template: jobs/steps/release-steps.yml 7 | # Test the wheels. This needs to happen after PublishBuildArtifacts 8 | # to avoid interference with the artifacts 9 | - script: python -m pip install dist/*.whl --no-deps 10 | displayName: 'Install wheel' 11 | condition: eq(variables['ONNX_SCRIPT_RELEASE'], 1) 12 | -------------------------------------------------------------------------------- /tests/models/eager_op.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | 5 | from onnxscript import script 6 | from onnxscript.onnx_opset import opset15 as op 7 | from onnxscript.onnx_types import FLOAT 8 | 9 | 10 | @script(default_opset=op) 11 | def eager_op(X: FLOAT[...]) -> FLOAT[...]: 12 | return X % 1.5 13 | 14 | 15 | @script() 16 | def eager_abs(X: FLOAT[...]) -> FLOAT[...]: 17 | return op.Abs(X) + 1 18 | -------------------------------------------------------------------------------- /docs/tutorial/examples/scanloop.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import graph, script 4 | from onnxscript import opset15 as op 5 | 6 | 7 | @script() 8 | def CumulativeSum(X): 9 | @graph() 10 | def Sum(sum_in, next): 11 | sum_out = sum_in + next 12 | return sum_out, sum_out 13 | 14 | _all_sum, cumulative_sum = op.Scan(0, X, body=Sum, num_scan_inputs=1) 15 | return cumulative_sum 16 | -------------------------------------------------------------------------------- /docs/tutorial/examples/omitted_input.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def omitted_input(x): 9 | # The following two statements are equivalent: 10 | y1 = op.Clip(x) 11 | y2 = op.Clip(x, None, None) 12 | # The following example shows an omitted optional input, followed by another input 13 | y3 = op.Clip(x, None, 1.0) 14 | return y1 + y2 + y3 15 | -------------------------------------------------------------------------------- /docs/api/rewriter.md: -------------------------------------------------------------------------------- 1 | # onnxscript.rewriter 2 | 3 | ```{eval-rst} 4 | .. automodule::onnxscript.rewriter 5 | .. currentmodule:: onnxscript 6 | ``` 7 | 8 | ```{eval-rst} 9 | .. autosummary:: 10 | :toctree: generated 11 | :template: functiontemplate.rst 12 | :nosignatures: 13 | 14 | rewriter.rewrite 15 | ``` 16 | 17 | ## IR passes 18 | 19 | ```{eval-rst} 20 | .. autosummary:: 21 | :toctree: generated 22 | :template: classtemplate.rst 23 | :nosignatures: 24 | 25 | rewriter.RewritePass 26 | ``` 27 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | __all__ = [ 4 | "core", 5 | "fft", 6 | "linalg", 7 | "nested", 8 | "nn", 9 | "prims", 10 | "quantized_decomposed", 11 | "sparse", 12 | "special", 13 | "vision", 14 | ] 15 | 16 | from . import ( 17 | core, 18 | fft, 19 | linalg, 20 | nested, 21 | nn, 22 | prims, 23 | quantized_decomposed, 24 | sparse, 25 | special, 26 | vision, 27 | ) 28 | -------------------------------------------------------------------------------- /tests/models/dropout.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript.onnx_opset import opset15 as op 5 | 6 | 7 | def Dropout(data, ratio, training_mode, seed: int): 8 | if training_mode: 9 | rand = op.RandomUniformLike(data, dtype=1, seed=seed) 10 | mask = rand >= ratio 11 | output = op.Where(mask, data, 0) / (1.0 - ratio) 12 | else: 13 | mask = op.ConstantOfShape(op.Shape(data), value=True) 14 | output = data 15 | return (output, mask) 16 | -------------------------------------------------------------------------------- /onnxscript/_framework_apis/torch_2_7.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Stable APIs for PyTorch 2.7.""" 4 | 5 | from __future__ import annotations 6 | 7 | __all__ = [ 8 | "check_model", 9 | "convert_version", 10 | "get_torchlib_ops", 11 | "optimize", 12 | "save_model_with_external_data", 13 | ] 14 | 15 | from onnxscript._framework_apis.torch_2_6 import ( 16 | check_model, 17 | convert_version, 18 | get_torchlib_ops, 19 | optimize, 20 | save_model_with_external_data, 21 | ) 22 | -------------------------------------------------------------------------------- /tests/models/renaming.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript.onnx_opset import opset15 as op 5 | from onnxscript.onnx_types import FLOAT 6 | 7 | # same variable assigned multiple times 8 | 9 | 10 | def renaming(A: FLOAT["N"]) -> FLOAT["N"]: 11 | T = op.Abs(A) 12 | T = op.Neg(A) 13 | return T 14 | 15 | 16 | # clash between generated-name and pre-existing name 17 | 18 | 19 | def renaming2(A: FLOAT["N"]) -> FLOAT["N"]: 20 | T_0 = op.Relu(A) 21 | T = op.Abs(A) 22 | T = op.Neg(A) 23 | return T 24 | -------------------------------------------------------------------------------- /docs/tutorial/examples/dropout.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def Dropout(data, ratio, training_mode, seed: float): 9 | if training_mode: 10 | rand = op.RandomUniformLike(data, dtype=1, seed=seed) 11 | mask = rand >= ratio 12 | output = op.Where(mask, data, 0) / (1.0 - ratio) 13 | else: 14 | mask = op.ConstantOfShape(op.Shape(data), value=True) 15 | output = data 16 | return (output, mask) 17 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | - Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support) 11 | -------------------------------------------------------------------------------- /docs/api/version_converter.md: -------------------------------------------------------------------------------- 1 | # onnxscript.version_converter 2 | 3 | ```{eval-rst} 4 | .. automodule::onnxscript.version_converter 5 | .. currentmodule:: onnxscript 6 | ``` 7 | 8 | ## Functions 9 | 10 | ```{eval-rst} 11 | .. autosummary:: 12 | :toctree: generated 13 | :template: functiontemplate.rst 14 | :nosignatures: 15 | 16 | version_converter.convert_version 17 | ``` 18 | 19 | ## IR passes 20 | 21 | ```{eval-rst} 22 | .. autosummary:: 23 | :toctree: generated 24 | :template: classtemplate.rst 25 | :nosignatures: 26 | 27 | version_converter.ConvertVersionPass 28 | ``` 29 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | setuptools>=61.0.0 2 | numpy 3 | onnx-weekly>=1.17.0.dev20240325 4 | onnxruntime>=1.17.0 5 | typing_extensions>=4.10 6 | rich>=13.7.1 7 | 8 | # Docs site 9 | furo 10 | jax[cpu] 11 | matplotlib 12 | myst-parser[linkify] 13 | sphinx-copybutton 14 | sphinx-exec-code 15 | sphinx-gallery 16 | sphinx>=6 17 | myst_nb 18 | chardet 19 | 20 | # Testing 21 | expecttest==0.1.6 22 | hypothesis 23 | parameterized 24 | pytest-cov 25 | pytest-randomly 26 | pytest-subtests 27 | pytest-xdist 28 | pytest!=7.1.0 29 | pyyaml 30 | torch>=2.3 31 | torchvision>=0.18.0 32 | transformers>=4.37.2 33 | 34 | # Lint 35 | lintrunner>=0.10.7 36 | lintrunner_adapters>=0.12.0 37 | -------------------------------------------------------------------------------- /onnxscript/ir/passes/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | __all__ = [ 5 | "PassBase", 6 | "PassResult", 7 | "PassManager", 8 | "Sequential", 9 | "InPlacePass", 10 | "FunctionalPass", 11 | # Errors 12 | "InvariantError", 13 | "PreconditionError", 14 | "PostconditionError", 15 | "PassError", 16 | ] 17 | 18 | from onnx_ir.passes import ( 19 | FunctionalPass, 20 | InPlacePass, 21 | InvariantError, 22 | PassBase, 23 | PassError, 24 | PassManager, 25 | PassResult, 26 | PostconditionError, 27 | PreconditionError, 28 | Sequential, 29 | ) 30 | -------------------------------------------------------------------------------- /docs/tutorial/examples/forwhileloop.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import opset15 as op 4 | from onnxscript import script 5 | 6 | 7 | @script() 8 | def sumprod_break(x, N): 9 | sum = op.Identity(x) 10 | prod = op.Identity(x) 11 | for _ in range(N): 12 | sum = sum + x 13 | prod = prod * x 14 | cond = op.ReduceSum(prod) > 1e7 15 | # ONNX does not support break instruction. 16 | # onnxscript can only convert example if the break 17 | # instruction is placed at the end of the loop body. 18 | if cond: 19 | break 20 | return sum, prod 21 | -------------------------------------------------------------------------------- /docs/tutorial/examples/whileloop.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnx import TensorProto 4 | from onnx.helper import make_tensor 5 | 6 | from onnxscript import opset15 as op 7 | from onnxscript import script 8 | 9 | 10 | @script() 11 | def sumprod(x, N): 12 | sum = op.Identity(x) 13 | prod = op.Identity(x) 14 | cond = op.Constant(value=make_tensor("true", TensorProto.BOOL, [1], [1])) 15 | i = op.Constant(value=make_tensor("i", TensorProto.INT64, [1], [0])) 16 | while cond: 17 | sum = sum + x 18 | prod = prod * x 19 | i = i + 1 20 | cond = i < 10 21 | return sum, prod 22 | -------------------------------------------------------------------------------- /docs/tutorial/examples/tensor_attr2.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnx import TensorProto, helper 4 | 5 | from onnxscript import opset15 as op 6 | from onnxscript import script 7 | 8 | script_const = helper.make_tensor("scalar_half", TensorProto.FLOAT, (), [0.5]) 9 | 10 | 11 | @script() 12 | def tensor_attr(x): 13 | c = op.Constant(value=script_const) 14 | return c * x 15 | 16 | 17 | # The following assignment has no effect on the ONNX FunctionProto 18 | # generated from tensor_attr: 19 | 20 | 21 | script_const = helper.make_tensor("scalar_one", TensorProto.FLOAT, (), [1.0]) 22 | 23 | fp = tensor_attr.to_function_proto() 24 | -------------------------------------------------------------------------------- /docs/tutorial/examples/outerscope_redef_error.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript import graph, script 4 | from onnxscript import opset15 as op 5 | 6 | try: 7 | 8 | @script() 9 | def CumulativeSum(X): 10 | g = op.Constant(value=0) 11 | 12 | @graph() 13 | def Sum(sum_in, next): 14 | sum_out = sum_in + next + g 15 | return sum_out, sum_out 16 | 17 | g = op.Constant(value=1) 18 | _all_sum, cumulative_sum = op.Scan(0, X, body=Sum, num_scan_inputs=1) 19 | return cumulative_sum 20 | 21 | except Exception as e: 22 | assert "Outer scope variable" in str(e) 23 | -------------------------------------------------------------------------------- /.azure-pipelines/stages/jobs/steps/release-steps.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: UsePythonVersion@0 3 | inputs: 4 | versionSpec: '3.11' 5 | displayName: 'Set Up Python' 6 | - script: python -m pip install --upgrade pip build wheel 7 | displayName: 'Install Python build dependencies' 8 | - script: python -m build 9 | displayName: 'Build ONNX Script wheel' 10 | - task: CopyFiles@2 11 | displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)' 12 | inputs: 13 | SourceFolder: 'dist' 14 | Contents: '*.*' 15 | TargetFolder: '$(Build.ArtifactStagingDirectory)' 16 | - task: 1ES.PublishPipelineArtifact@1 17 | displayName: 'Publish Python Wheel' 18 | inputs: 19 | ArtifactName: 'onnxscript' 20 | targetPath: '$(Build.ArtifactStagingDirectory)' 21 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/graph_building/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | __all__ = [ 6 | "TorchScriptTensor", 7 | "TorchScriptGraph", 8 | "TorchScriptTracingEvaluator", 9 | ] 10 | 11 | 12 | class _RemovedClass: 13 | """A onnxscript tensor that wraps a torchscript Value.""" 14 | 15 | def __init__(self, *_, **__): 16 | raise NotImplementedError( 17 | "Support for dynamo_export has been dropped since onnxscript 0.4.0. " 18 | "Please use `torch.onnx.export(..., dynamo=True)`, or downgrade to onnxscript<0.4" 19 | ) 20 | 21 | 22 | TorchScriptTensor = _RemovedClass 23 | TorchScriptGraph = _RemovedClass 24 | TorchScriptTracingEvaluator = _RemovedClass 25 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | authors: 4 | - dependabot 5 | categories: 6 | - title: Breaking Changes 7 | labels: 8 | - "topic: breaking changes" 9 | - title: Core ONNX Script 10 | labels: 11 | - "topic: onnxscript core" 12 | - "topic: ast converter" 13 | - title: Optimizer and rewriter 14 | labels: 15 | - "module: rewriter" 16 | - "module: optimizer" 17 | - "topic: ort-fusions" 18 | - title: ONNX IR 19 | labels: 20 | - "module: IR" 21 | - "topic: passes" 22 | - title: Torch Lib 23 | labels: 24 | - "module: torchlib" 25 | - title: Documentation 26 | labels: 27 | - "topic: documentation" 28 | - title: Other Changes 29 | labels: 30 | - "*" 31 | -------------------------------------------------------------------------------- /tests/models/sequences.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript import script 5 | from onnxscript.onnx_opset import opset15 as op 6 | 7 | 8 | @script() 9 | def make_sequence_tensor(A): 10 | # If replaced by [], attribute dtype can not be easily changed. 11 | seq = op.SequenceEmpty() 12 | B = A 13 | for i in range(5): 14 | seq = op.SequenceInsert(seq, B) 15 | B = B * 2 16 | return op.ConcatFromSequence(seq, axis=0) 17 | 18 | 19 | @script() 20 | def make_sequence_tensor_accumulated(A): 21 | seq = op.SequenceEmpty() 22 | B = A 23 | C = A * 0 24 | for i in range(5): 25 | seq = op.SequenceInsert(seq, B) 26 | B = B * 2 27 | C = C + B + 1 28 | return op.ConcatFromSequence(seq, axis=0) - C 29 | -------------------------------------------------------------------------------- /docs/tutorial/rewriter/or_pattern.md: -------------------------------------------------------------------------------- 1 | # OR Patterns 2 | 3 | *Note* : This feature is work-in-progress. 4 | 5 | Consider the following pattern: 6 | 7 | ```{literalinclude} examples/or_pattern.py 8 | :pyobject: scaled_matmul 9 | ``` 10 | 11 | This pattern will successfully match against the sequence "MatMul => Mul => Relu" as 12 | well as the sequence "MatMul => Div => Relu". The matcher will bind the variable 13 | specified in `tag_var` (`op_type` in the above example) to a value from those 14 | listed in `tag_values` to indicate which of the alternatives was used for a 15 | successful match. We can use this in the rewrite function to determine how 16 | we want to rewrite the matched sub-graph, as illustrated by the following code: 17 | 18 | ```{literalinclude} examples/or_pattern.py 19 | :pyobject: scaled_matmul_replacement 20 | ``` 21 | -------------------------------------------------------------------------------- /tests/models/loops_while.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnx import TensorProto 5 | from onnx.helper import make_tensor 6 | 7 | from onnxscript import script 8 | from onnxscript.onnx_opset import opset15 as op 9 | from onnxscript.onnx_types import FLOAT 10 | 11 | # same variable assigned multiple times 12 | 13 | 14 | @script() 15 | def loop1(A: FLOAT["N"]) -> FLOAT["N"]: 16 | T = A 17 | for i in range(10): 18 | T = T + A * op.Cast(i, to=TensorProto.FLOAT) 19 | return T 20 | 21 | 22 | @script() 23 | def loop_range_cond_only(A: FLOAT["N"]) -> FLOAT["N"]: 24 | T = A 25 | cond = op.Constant(value=make_tensor("true", TensorProto.BOOL, [], [1])) 26 | while cond: 27 | T = T + A 28 | cond = op.ReduceSum(T) > -10 29 | return T 30 | -------------------------------------------------------------------------------- /onnxscript/_framework_apis/torch_2_8.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Stable APIs for PyTorch 2.8.""" 4 | 5 | from __future__ import annotations 6 | 7 | __all__ = [ 8 | "check_model", 9 | "convert_version", 10 | "get_torchlib_ops", 11 | "optimize", 12 | "save_model_with_external_data", 13 | ] 14 | 15 | import onnx_ir as ir 16 | 17 | import onnxscript.optimizer 18 | import onnxscript.rewriter.onnx_fusions 19 | from onnxscript._framework_apis.torch_2_6 import ( 20 | check_model, 21 | convert_version, 22 | get_torchlib_ops, 23 | save_model_with_external_data, 24 | ) 25 | 26 | 27 | def optimize(model: ir.Model) -> ir.Model: 28 | """Optimize the model.""" 29 | onnxscript.optimizer.optimize_ir(model) 30 | onnxscript.rewriter.onnx_fusions.fuse(model) 31 | return model 32 | -------------------------------------------------------------------------------- /tests/models/loops_break.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnx import TensorProto 5 | from onnx.helper import make_tensor 6 | 7 | from onnxscript import script 8 | from onnxscript.onnx_opset import opset15 as op 9 | from onnxscript.onnx_types import FLOAT 10 | 11 | 12 | @script() 13 | def loop1(A: FLOAT["N"]) -> FLOAT["N"]: 14 | T = A 15 | for i in range(10): 16 | T = T + A * op.Cast(i, to=TensorProto.FLOAT) 17 | return T 18 | 19 | 20 | @script() 21 | def loop_range_cond(A: FLOAT["N"]) -> FLOAT["N"]: 22 | T = A 23 | cond = op.Constant(value=make_tensor("condcst", TensorProto.BOOL, [1], [1])) 24 | for i in range(10): 25 | T = T + A * op.Cast(i, to=TensorProto.FLOAT) 26 | cond = op.ReduceSum(T) <= -10 27 | if cond: 28 | break 29 | return T 30 | -------------------------------------------------------------------------------- /onnxscript/utils/timing_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | import time 4 | 5 | import onnx 6 | 7 | from onnxscript import optimizer 8 | 9 | 10 | def timeit(f, message): 11 | def timed(*args, **kw): 12 | ts = time.time() 13 | result = f(*args, **kw) 14 | te = time.time() 15 | print(f"{message} time: {te - ts}") 16 | return result 17 | 18 | return timed 19 | 20 | 21 | load = timeit(onnx.load, "Load") 22 | 23 | save = timeit(onnx.save, "Save") 24 | 25 | infer = timeit(onnx.shape_inference.infer_shapes, "Infer") 26 | 27 | fold_constants = timeit(optimizer.fold_constants, "Fold Constants") 28 | 29 | remove_unused = timeit(optimizer.remove_unused_nodes, "Remove Unused") 30 | 31 | optimize = timeit(optimizer.optimize, "Optimize") 32 | 33 | # rewrite = timeit(all_rules.apply_to_model, "Rewrite") 34 | -------------------------------------------------------------------------------- /tests/functions/gemmgelu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript import script 5 | from onnxscript.onnx_opset import opset15 as op 6 | from onnxscript.onnx_types import FLOAT 7 | 8 | 9 | @script() 10 | def gemmgelu( 11 | A: FLOAT["M", "K"], # noqa: F821 12 | W: FLOAT["K", "N"], # noqa: F821 13 | Bias: FLOAT["N"], # noqa: F821 14 | ) -> FLOAT["M", "N"]: # noqa: F821 15 | a = op.Constant(value_float=0.5) 16 | b = op.Constant(value_float=0.797885) 17 | c = op.Constant(value_float=0.035677) 18 | one = op.Constant(value_float=1.0) 19 | P1 = op.MatMul(A, W) 20 | X = op.Add(P1, Bias) 21 | T1 = op.Mul(X, X) 22 | T2 = op.Mul(c, T1) 23 | T3 = op.Add(b, T2) 24 | T4 = op.Mul(X, T3) 25 | T5 = op.Tanh(T4) 26 | T6 = op.Add(one, T5) 27 | T7 = op.Mul(X, T6) 28 | Y = op.Mul(a, T7) 29 | return Y 30 | -------------------------------------------------------------------------------- /tests/version_converter/version_conversion_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | import pathlib 6 | import unittest 7 | 8 | from onnxscript import ir, version_converter 9 | 10 | model_folder_path = pathlib.Path(__file__).resolve().parent.parent.parent / "testdata" 11 | 12 | 13 | class ModelTest(unittest.TestCase): 14 | def test_model_runs_and_matches_accuracy_after_conversion_fallback_true(self): 15 | model_path = model_folder_path / "e2e_models/torchscript_model/torchscript_model.onnx" 16 | model = ir.load(model_path) 17 | 18 | # Down convert the model with the onnx version converter 19 | version_converter.convert_version(model, target_version=16, fallback=True) 20 | self.assertEqual(model.opset_imports[""], 16) 21 | 22 | 23 | if __name__ == "__main__": 24 | unittest.main() 25 | -------------------------------------------------------------------------------- /docs/update_readme.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Script to update end-to-end example in README.md.""" 4 | 5 | updated_readme = [] 6 | with open("README.md", encoding="utf-8") as f: 7 | in_stub = False 8 | readme = f.readlines() 9 | for line in readme: 10 | if not in_stub: 11 | updated_readme.append(line) 12 | if line == "```python update-readme\n": 13 | in_stub = True 14 | with open( 15 | "docs/tutorial/examples/hardmax_end_to_end.py", encoding="utf-8" 16 | ) as example_f: 17 | example_code = example_f.readlines()[2:] # Skip the copyright header 18 | updated_readme += example_code 19 | if line == "```\n" and in_stub: 20 | updated_readme.append(line) 21 | in_stub = False 22 | 23 | with open("README.md", "w", encoding="utf-8") as f: 24 | f.writelines(updated_readme) 25 | -------------------------------------------------------------------------------- /onnxscript/rewriter/rules/common/_gemm_to_matmul_add.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript.rewriter._rewrite_rule import RewriteRule 4 | from onnxscript.rewriter.rules.common._broadcast_to_matmul import check_if_not_need_reshape 5 | 6 | 7 | # Pattern to match against 8 | def reshape_gemm_reshape_pattern(op, input_a, input_b, input_c, shape_a, shape_c): 9 | reshape_a = op.Reshape(input_a, shape_a) 10 | # TODO: Temporary workaround to support benchmodels. 11 | # Tracked by https://github.com/microsoft/onnx-rewriter/issues/197. 12 | gemm = op.Gemm(reshape_a, input_b, input_c, alpha=1.0, beta=1.0) 13 | return op.Reshape(gemm, shape_c) 14 | 15 | 16 | def matmul_add(op, input_a, input_b, input_c, **_): 17 | matmul = op.MatMul(input_a, input_b) 18 | return op.Add(matmul, input_c) 19 | 20 | 21 | gemm_to_matmul_add_rule = RewriteRule( 22 | reshape_gemm_reshape_pattern, matmul_add, check_if_not_need_reshape 23 | ) 24 | -------------------------------------------------------------------------------- /docs/examples/03_export_lib.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """ 4 | Generating a LibProto 5 | ===================== 6 | 7 | The examples below show how we can define a library consisting of multiple functions, 8 | and export it. 9 | 10 | **This is preliminary. Proto extensions are required to fully support LibProto.** 11 | """ 12 | 13 | from onnxscript import export_onnx_lib, script 14 | from onnxscript import opset15 as op 15 | from onnxscript.values import Opset 16 | 17 | # %% 18 | # The domain/version of the library functions defined below 19 | opset = Opset("com.mydomain", 1) 20 | 21 | 22 | # %% 23 | # The definitions of the functions: 24 | @script(opset) 25 | def l2norm(X): 26 | return op.ReduceSum(X * X, keepdims=1) 27 | 28 | 29 | @script(opset) 30 | def square_loss(X, Y): 31 | return l2norm(op.Sub(X, Y)) 32 | 33 | 34 | # %% 35 | # Export the functions as an ONNX library. 36 | export_onnx_lib([l2norm, square_loss], "mylib.onnxlib") 37 | -------------------------------------------------------------------------------- /.azure-pipelines/release-dev.yml: -------------------------------------------------------------------------------- 1 | # Build the dev version of the package and publish to artifacts 2 | 3 | # To configure triggers, see https://github.com/microsoft/onnx-converters-private/wiki/ONNX-Script-release 4 | trigger: none 5 | 6 | variables: 7 | CI: 'true' 8 | 9 | resources: 10 | repositories: 11 | - repository: 1esPipelines 12 | type: git 13 | name: 1ESPipelineTemplates/1ESPipelineTemplates 14 | ref: refs/tags/release 15 | 16 | extends: 17 | # The pipeline extends the 1ES PT which will inject different SDL and compliance tasks. 18 | # For non-production pipelines, use "Unofficial" as defined below. 19 | # For productions pipelines, use "Official". 20 | template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines 21 | parameters: 22 | sdl: 23 | sourceAnalysisPool: 24 | name: onnxruntime-Win-CPU-2022 25 | os: windows 26 | pool: 27 | name: 'onnxruntime-Ubuntu2204-AMD-CPU' 28 | os: 'linux' 29 | stages: 30 | - template: stages/release-stage.yml 31 | -------------------------------------------------------------------------------- /.azure-pipelines/release.yml: -------------------------------------------------------------------------------- 1 | # Build the release version of the package and publish to artifacts 2 | 3 | trigger: none 4 | 5 | variables: 6 | CI: 'true' 7 | # Set the release environment variable to build a release version of the wheel 8 | ONNX_SCRIPT_RELEASE: 1 9 | 10 | resources: 11 | repositories: 12 | - repository: 1esPipelines 13 | type: git 14 | name: 1ESPipelineTemplates/1ESPipelineTemplates 15 | ref: refs/tags/release 16 | 17 | extends: 18 | # The pipeline extends the 1ES PT which will inject different SDL and compliance tasks. 19 | # For non-production pipelines, use "Unofficial" as defined below. 20 | # For productions pipelines, use "Official". 21 | template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines 22 | parameters: 23 | sdl: 24 | sourceAnalysisPool: 25 | name: onnxruntime-Win-CPU-2022 26 | os: windows 27 | pool: 28 | name: 'onnxruntime-Ubuntu2204-AMD-CPU' 29 | os: 'linux' 30 | stages: 31 | - template: stages/release-stage.yml 32 | -------------------------------------------------------------------------------- /onnxscript/_framework_apis/torch_2_9.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """Stable APIs for PyTorch 2.9.""" 4 | 5 | from __future__ import annotations 6 | 7 | __all__ = [ 8 | "check_model", 9 | "convert_version", 10 | "get_torchlib_ops", 11 | "optimize", 12 | "save_model_with_external_data", 13 | ] 14 | 15 | from typing import TYPE_CHECKING 16 | 17 | from onnxscript import version_converter 18 | from onnxscript._framework_apis.torch_2_8 import ( 19 | check_model, 20 | get_torchlib_ops, 21 | optimize, 22 | save_model_with_external_data, 23 | ) 24 | 25 | if TYPE_CHECKING: 26 | import onnx_ir as ir 27 | 28 | 29 | def convert_version(model: ir.Model, target_version: int) -> ir.Model: 30 | """Convert the model to the specified ONNX opset version. 31 | 32 | Starting from PyTorch 2.9, down conversion is turned on and supported. 33 | """ 34 | version_converter.convert_version(model, target_version, fallback=True) 35 | return model 36 | -------------------------------------------------------------------------------- /docs/tutorial/rewriter/attributes.md: -------------------------------------------------------------------------------- 1 | # Specifying attributes in the pattern 2 | 3 | This section demonstrates the use of attribute values in pattern-based rewriting. 4 | First, write a target pattern and replacement pattern in a similar way to the previous examples. 5 | The example pattern below will match successfully only against Dropout nodes with the 6 | attribute value `training_mode` set to `False`. 7 | 8 | The `_allow_other_attributes` option allows the pattern to match nodes that have additional attributes 9 | not specified in the pattern. If it is set to `False`, then the node must have only the specified 10 | attribute values, and no other attributes, for a successful match. The default value for this 11 | option is `True`. 12 | 13 | ```{literalinclude} examples/allow_other_attributes.py 14 | :pyobject: add_pattern 15 | ``` 16 | 17 | ```{literalinclude} examples/allow_other_attributes.py 18 | :pyobject: add_replacement 19 | ``` 20 | 21 | ```{literalinclude} examples/allow_other_attributes.py 22 | :pyobject: apply_rewrite 23 | ``` 24 | -------------------------------------------------------------------------------- /tools/onnx2external.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import argparse 5 | import os 6 | 7 | import onnx 8 | import onnx.external_data_helper 9 | 10 | 11 | def convert2external(input_file_name: str) -> None: 12 | dir_name = os.path.dirname(input_file_name) 13 | base_name, _suffix = os.path.splitext(os.path.basename(input_file_name)) 14 | model = onnx.load(input_file_name) 15 | os.makedirs(os.path.join(dir_name, base_name), exist_ok=True) 16 | onnx.external_data_helper.convert_model_to_external_data( 17 | model, location="external_data.onnx", size_threshold=128 18 | ) 19 | onnx.save(model, os.path.join(dir_name, base_name, "model.onnx")) 20 | 21 | 22 | if __name__ == "__main__": 23 | parser = argparse.ArgumentParser( 24 | description="Convert ONNX model file to external data format" 25 | ) 26 | parser.add_argument("input", help="ONNX model file to convert") 27 | args = parser.parse_args() 28 | 29 | convert2external(args.input) 30 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/ops/nested.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | # -------------------------------------------------------------------------- 5 | # mypy: disable-error-code="misc,arg-type,type-arg,valid-type,assignment,return-value" 6 | """torch.ops.aten operators under the `nested` module. 7 | 8 | - No inplace operators. 9 | - All functions should not have the script() decorator. This is because 10 | we want to delay the compilation of the function. 11 | """ 12 | 13 | from __future__ import annotations 14 | 15 | from typing import Optional 16 | 17 | from onnxscript.onnx_types import TensorType 18 | 19 | 20 | def aten_nested_to_padded_tensor( 21 | self: TensorType, padding: float, output_size: Optional[int] = None 22 | ) -> TensorType: 23 | """nested_to_padded_tensor(Tensor self, float padding, int[]? output_size=None) -> Tensor""" 24 | 25 | raise NotImplementedError() 26 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/ops/sparse.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | # -------------------------------------------------------------------------- 5 | # mypy: disable-error-code="misc,arg-type,type-arg,valid-type,assignment,return-value" 6 | """torch.ops.aten operators under the `sparse` module. 7 | 8 | - No inplace operators. 9 | - All functions should not have the script() decorator. This is because 10 | we want to delay the compilation of the function. 11 | """ 12 | 13 | from __future__ import annotations 14 | 15 | from onnxscript.onnx_types import TensorType 16 | 17 | 18 | def aten_sparse_sampled_addmm( 19 | self: TensorType, mat1: TensorType, mat2: TensorType, beta: float = 1.0, alpha: float = 1.0 20 | ) -> TensorType: 21 | """sparse_sampled_addmm(Tensor self, Tensor mat1, Tensor mat2, *, Scalar beta=1, Scalar alpha=1) -> Tensor""" 22 | 23 | raise NotImplementedError() 24 | -------------------------------------------------------------------------------- /docs/examples/01_plot_selu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """ 4 | Generating a FunctionProto 5 | ========================== 6 | 7 | The example below shows how we can define Selu as a function in onnxscript. 8 | """ 9 | 10 | # %% 11 | # First, import the ONNX opset used to define the function. 12 | from onnxscript import opset15 as op 13 | from onnxscript import script 14 | 15 | # %% 16 | # Next, define Selu as an ONNXScript function. 17 | 18 | 19 | @script() 20 | def Selu(X, alpha: float, gamma: float): 21 | alphaX = op.CastLike(alpha, X) 22 | gammaX = op.CastLike(gamma, X) 23 | neg = gammaX * (alphaX * op.Exp(X) - alphaX) 24 | pos = gammaX * X 25 | zero = op.CastLike(0, X) 26 | return op.Where(zero >= X, neg, pos) 27 | 28 | 29 | # %% 30 | # We can convert the ONNXScript function to an ONNX function (FunctionProto) as below: 31 | 32 | onnx_fun = Selu.to_function_proto() 33 | 34 | # %% 35 | # Let's see what the translated function looks like: 36 | import onnx # noqa: E402 37 | 38 | print(onnx.printer.to_text(onnx_fun)) 39 | -------------------------------------------------------------------------------- /onnxscript/ir/passes/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | __all__ = [ 5 | "AddInitializersToInputsPass", 6 | "CheckerPass", 7 | "ClearMetadataAndDocStringPass", 8 | "CommonSubexpressionEliminationPass", 9 | "InlinePass", 10 | "LiftConstantsToInitializersPass", 11 | "LiftSubgraphInitializersToMainGraphPass", 12 | "RemoveInitializersFromInputsPass", 13 | "RemoveUnusedFunctionsPass", 14 | "RemoveUnusedNodesPass", 15 | "RemoveUnusedOpsetsPass", 16 | "ShapeInferencePass", 17 | "TopologicalSortPass", 18 | ] 19 | 20 | from onnx_ir.passes.common import ( 21 | AddInitializersToInputsPass, 22 | CheckerPass, 23 | ClearMetadataAndDocStringPass, 24 | CommonSubexpressionEliminationPass, 25 | InlinePass, 26 | LiftConstantsToInitializersPass, 27 | LiftSubgraphInitializersToMainGraphPass, 28 | RemoveInitializersFromInputsPass, 29 | RemoveUnusedFunctionsPass, 30 | RemoveUnusedNodesPass, 31 | RemoveUnusedOpsetsPass, 32 | ShapeInferencePass, 33 | TopologicalSortPass, 34 | ) 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "pip" # See documentation for possible values 9 | directory: "/requirements/ci/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | # disable version updates for pip dependencies 13 | open-pull-requests-limit: 5 14 | 15 | - package-ecosystem: "pip" 16 | directory: "/requirements/lintrunner/" # Location of package manifests 17 | schedule: 18 | interval: "weekly" 19 | # disable version updates for pip dependencies 20 | open-pull-requests-limit: 5 21 | 22 | - package-ecosystem: "github-actions" 23 | # Workflow files stored in the 24 | # default location of `.github/workflows` 25 | directory: "/" 26 | schedule: 27 | interval: "weekly" 28 | open-pull-requests-limit: 5 29 | -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 |
⚠️ 5 | NOTE: ONNX Script is in very early 6 | and active development and the team anticipates 7 | breaking changes as the project evolves. 8 | ONNX Script is not ready for production, 9 | but early feedback is welcome. 10 | ⚠️
14 | 15 | ---- 16 | 17 | # ONNX Script Roadmap 18 | 19 | * Improve error-checking and error-handling to identify use of unsupported 20 | Python features/constructs as early as possible and report it. 21 | 22 | * Improve documentation and tutorials 23 | 24 | * Features 25 | - Support nested functions, for use as sub-graphs in ops like Scan 26 | - Generalize support for _break_ statements in loops 27 | - Support indexing notation for slicing/gather/scatter operations 28 | - Improve type-annotation support, especially for tensor shapes 29 | - Improve support for non-tensor types (sequences, maps, and optional) 30 | - Improve checking in eager-mode to ensure its semantics is aligned with ONNX semantics 31 | - Support for variadic inputs/outputs 32 | -------------------------------------------------------------------------------- /tests/models/eg1.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript import opset15 as op 5 | from onnxscript.onnx_types import FLOAT 6 | 7 | # tensor inputs can have ONNX-like type annotations 8 | 9 | 10 | def gemm(A: FLOAT[2048, 124], W: FLOAT[124, 4096], Bias: FLOAT[4096]) -> FLOAT[2048, 4096]: 11 | return op.MatMul(A, W) + Bias 12 | 13 | 14 | # tensors and attributes distinguished by their types 15 | 16 | 17 | def scale(A: FLOAT[...], alpha: float, beta: float) -> FLOAT[...]: 18 | return alpha * A + beta 19 | 20 | 21 | # can return multiple-values 22 | 23 | 24 | def prodsum(A: FLOAT["N"], B: FLOAT["N"]) -> (FLOAT["N"], FLOAT["N"]): 25 | prod = A * B 26 | sum = A + B 27 | return prod, sum 28 | 29 | 30 | # can call ops/functions that return multiple-values 31 | 32 | 33 | def dropout_eg(A: FLOAT[...]) -> FLOAT[...]: 34 | output, mask = op.Dropout(A, 0.7, True, seed=1729) 35 | return output 36 | 37 | 38 | # will rename variable assigned multiple times 39 | 40 | 41 | def renaming(A: FLOAT["N"]) -> FLOAT["N"]: 42 | T = op.Abs(A) 43 | T = op.Neg(T) 44 | return T 45 | -------------------------------------------------------------------------------- /onnxscript/rewriter/ort_fusions/rms_normalization_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | import unittest 6 | 7 | import onnxscript.optimizer 8 | from onnxscript.rewriter.models._smollm_1 import smollm_test_1 9 | from onnxscript.rewriter.ort_fusions._test_utils import assert_allclose, ort_run 10 | from onnxscript.rewriter.ort_fusions.rms_normalization import fuse_rms_normalization 11 | 12 | 13 | class TestRmsNormalization(unittest.TestCase): 14 | def test_smollm(self): 15 | smollm_test = smollm_test_1() 16 | model = smollm_test.get_onnx_model() 17 | onnxscript.optimizer.optimize(model) 18 | inputs = smollm_test.get_ort_inputs() 19 | original_outputs = ort_run("original", model, inputs) 20 | fuse_rms_normalization(model) 21 | op_types = [n.op_type for n in model.graph] 22 | self.assertIn("SimplifiedLayerNormalization", op_types) 23 | new_outputs = ort_run("optimized", model, inputs) 24 | assert_allclose(new_outputs, original_outputs) 25 | 26 | 27 | if __name__ == "__main__": 28 | unittest.main() 29 | -------------------------------------------------------------------------------- /onnxscript/rewriter/ort_fusions/erfgelu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | import math 4 | 5 | from onnxscript.rewriter import _fusion_utils, pattern 6 | 7 | 8 | # Pattern to match against 9 | def erf_gelu_pattern_1(op, x): 10 | # erf_gelu(x) = 0.5 * x * (1 + erf(x / sqrt(2))) 11 | # half = pattern.Constant(0.5) 12 | # sqrt2 = pattern.Constant(1.4142) 13 | # x_div_sqrt2 = op.Div(x, sqrt2) 14 | # erf = op.Erf(x_div_sqrt2) 15 | # one = pattern.Constant(1.0) 16 | # one_plus_erf = op.Add(erf, one) 17 | # x_mul_one_plus_erf = op.Mul(x, one_plus_erf) 18 | # return op.Mul(half, x_mul_one_plus_erf) 19 | return 0.5 * (x * (op.Erf(x / math.sqrt(2)) + 1.0)) 20 | 21 | 22 | def erf_gelu_pattern_2(op, x): 23 | return x * (0.5 * (op.Erf(x / math.sqrt(2)) + 1.0)) 24 | 25 | 26 | # Replacement 27 | def gelu(op, x): 28 | return op.Gelu(x, _domain="com.microsoft") 29 | 30 | 31 | rule1 = pattern.RewriteRule(erf_gelu_pattern_1, gelu) 32 | rule2 = pattern.RewriteRule(erf_gelu_pattern_2, gelu) 33 | 34 | rules = pattern.RewriteRuleSet([rule1, rule2]) 35 | 36 | fuse_erfgelu = _fusion_utils.apply_fusion_rules(rules) 37 | -------------------------------------------------------------------------------- /onnxscript/rewriter/onnxruntime/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | """Deprecated. This module is kept for backward compatibility.""" 5 | 6 | from __future__ import annotations 7 | 8 | from typing import Sequence 9 | 10 | import onnx 11 | 12 | from onnxscript.rewriter import pattern 13 | from onnxscript.rewriter import rewrite as _rewrite 14 | from onnxscript.rewriter.ort_fusions import ORT_PATTERN_REWRITE_RULES 15 | 16 | __all__ = [ 17 | "rewrite", 18 | "ORT_PATTERN_REWRITE_RULES", 19 | ] 20 | 21 | 22 | def rewrite( 23 | model_proto: onnx.ModelProto, 24 | /, 25 | pattern_rules: Sequence[pattern.RewriteRule] | None = None, 26 | ) -> onnx.ModelProto: 27 | """Rewrite the model using the given rules. 28 | 29 | Args: 30 | model_proto: The model to rewrite. 31 | pattern_rules: The pattern rewrite rules to apply. If None, the default rules 32 | for onnxruntime are used. 33 | 34 | Returns: 35 | The rewritten model. 36 | """ 37 | pattern_rules = pattern_rules or ORT_PATTERN_REWRITE_RULES 38 | return _rewrite(model_proto, pattern_rewrite_rules=pattern_rules) 39 | -------------------------------------------------------------------------------- /docs/examples/05_plot_model_props.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """ 4 | ModelProto Properties 5 | ===================== 6 | 7 | A ModelProto, in ONNX, usually stores extra information beyond the 8 | computational graph, such as `ir_version` or `producer_name`. 9 | Such properties of a generated ModelProto can be set by passing in extra named 10 | parameters to the call to script (or the call to `to_model_proto`), 11 | as illustrated by the example below. 12 | Only the valid fields defined in the protobuf message ModelProto should 13 | be specified in this fashion. 14 | 15 | """ 16 | 17 | # %% 18 | # First, we define the implementation of a square-loss function in onnxscript. 19 | 20 | import onnx 21 | 22 | from onnxscript import FLOAT, script 23 | from onnxscript import opset15 as op 24 | 25 | 26 | @script(ir_version=7, producer_name="OnnxScript", producer_version="0.1") 27 | def square_loss(X: FLOAT["N"], Y: FLOAT["N"]) -> FLOAT[1]: # noqa: F821 28 | diff = X - Y 29 | return op.ReduceSum(diff * diff, keepdims=1) 30 | 31 | 32 | # %% 33 | # Let's see what the generated model looks like. 34 | model = square_loss.to_model_proto() 35 | print(onnx.printer.to_text(model)) 36 | -------------------------------------------------------------------------------- /onnxscript/rewriter/ort_fusions/rotary_embedding_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | import unittest 6 | 7 | from parameterized import parameterized 8 | 9 | import onnxscript.optimizer 10 | from onnxscript.rewriter.models import _rotary_embedding_models, _smollm_1 11 | from onnxscript.rewriter.ort_fusions import rotary_embedding 12 | 13 | 14 | class TestRotaryEmbedding(unittest.TestCase): 15 | @parameterized.expand( 16 | [ 17 | ( 18 | "test_case_1", 19 | _rotary_embedding_models.test_case_1, 20 | ), 21 | ( 22 | "smollm_test_1", 23 | _smollm_1.smollm_test_1, 24 | ), 25 | ] 26 | ) 27 | def test_rotary_embedding_fusion(self, _: str, test_data_constructor): 28 | test = test_data_constructor() 29 | model = test.get_onnx_model() 30 | onnxscript.optimizer.optimize(model) 31 | rotary_embedding.fuse_rotary_embedding(model) 32 | op_types = [n.op_type for n in model.graph] 33 | self.assertIn("RotaryEmbedding", op_types) 34 | 35 | 36 | if __name__ == "__main__": 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /pyproject_pylint.toml: -------------------------------------------------------------------------------- 1 | # Relax pylint for lintrunner 2 | 3 | [tool.pylint.messages_control] 4 | disable = [ 5 | "arguments-differ", # TODO: abstract methods in Rewriter 6 | "attribute-defined-outside-init", # TODO: mostly in onnxscript/converter.py 7 | "cell-var-from-loop", # Bugbear B023 8 | "consider-using-from-import", 9 | "cyclic-import", 10 | "duplicate-code", 11 | "fixme", 12 | "format", 13 | "import-error", 14 | "invalid-name", # TODO: Add naming guidance and enable this check. 15 | "line-too-long", 16 | "missing-docstring", 17 | "no-else-return", 18 | "no-member", 19 | "no-name-in-module", 20 | "redefined-builtin", # TODO: should we avoid redefined-builtin? 21 | "too-few-public-methods", 22 | "too-many-ancestors", 23 | "too-many-arguments", 24 | "too-many-branches", 25 | "too-many-instance-attributes", 26 | "too-many-lines", 27 | "too-many-locals", 28 | "too-many-positional-arguments", 29 | "too-many-public-methods", 30 | "too-many-return-statements", 31 | "too-many-statements", # TODO: we should work on these: too-many-xxx series 32 | "unnecessary-ellipsis", 33 | "use-dict-literal", # Sometime it is preferable when we construct kwargs 34 | ] 35 | -------------------------------------------------------------------------------- /onnxscript/rewriter/pattern.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | from onnxscript.ir import _tape 6 | from onnxscript.rewriter._basics import MatchingTracer, MatchResult, MatchStatus 7 | from onnxscript.rewriter._matcher import PatternMatcher, SimplePatternMatcher 8 | from onnxscript.rewriter._pattern_ir import ( 9 | ANY_VALUE, 10 | AttrVar, 11 | Constant, 12 | OpsetPatternBuilder, 13 | OrValue, 14 | Var, 15 | pattern_builder, 16 | torch_module_op, 17 | ) 18 | from onnxscript.rewriter._rewrite_rule import ( 19 | Pattern, 20 | PatternBase, 21 | RewriteRule, 22 | RewriteRuleClassBase, 23 | RewriteRuleSet, 24 | ) 25 | 26 | RewriterContext = _tape.Builder 27 | 28 | __all__ = [ 29 | "ANY_VALUE", 30 | "AttrVar", 31 | "OrValue", 32 | "Constant", 33 | "OpsetPatternBuilder", 34 | "pattern_builder", 35 | "PatternBase", 36 | "Pattern", 37 | "RewriteRule", 38 | "RewriteRuleClassBase", 39 | "RewriteRuleSet", 40 | "RewriterContext", 41 | "MatchingTracer", 42 | "MatchResult", 43 | "MatchStatus", 44 | "PatternMatcher", 45 | "SimplePatternMatcher", 46 | "torch_module_op", 47 | "Var", 48 | ] 49 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """NOTE: Put all metadata in pyproject.toml. Do not include complex logic in setup.py.""" 4 | 5 | import datetime 6 | import os 7 | import pathlib 8 | import subprocess 9 | 10 | import setuptools 11 | 12 | # Logic for computing the development version number. 13 | ROOT_DIR = pathlib.Path(__file__).parent 14 | VERSION_FILE = ROOT_DIR / "VERSION" 15 | version = VERSION_FILE.read_text().strip() 16 | 17 | project_urls = { 18 | "Homepage": "https://microsoft.github.io/onnxscript/", 19 | "Repository": "https://github.com/microsoft/onnxscript", 20 | } 21 | if os.environ.get("ONNX_SCRIPT_RELEASE") != "1": 22 | date = datetime.date.today().strftime("%Y%m%d") 23 | version = f"{version}.dev{date}" 24 | 25 | commit_hash_cmd = subprocess.run( 26 | ["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=False 27 | ) 28 | if commit_hash_cmd.returncode == 0: 29 | project_urls["Commit"] = ( 30 | f"https://github.com/microsoft/onnxscript/tree/{commit_hash_cmd.stdout.decode('utf-8').strip()}" 31 | ) 32 | 33 | # NOTE: Do not include other metadata in setup.py. Put it in pyproject.toml. 34 | setuptools.setup(version=version, project_urls=project_urls) 35 | -------------------------------------------------------------------------------- /onnxscript/function_libs/torch_lib/ops/vision.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | # -------------------------------------------------------------------------- 5 | # mypy: disable-error-code="misc,arg-type,type-arg,valid-type,assignment,return-value" 6 | """torchvision operators.""" 7 | 8 | from __future__ import annotations 9 | 10 | from onnxscript.function_libs.torch_lib.registration import torch_op 11 | from onnxscript.onnx_opset import opset18 as op 12 | from onnxscript.onnx_types import FLOAT, INT64 13 | 14 | _INT64_MAX = 0x7FFFFFFFFFFFFFFF 15 | 16 | 17 | @torch_op("torchvision::nms") 18 | def torchvision_nms(boxes: FLOAT, scores: FLOAT, iou_threshold: float) -> INT64: 19 | # boxes: [num_batches, spatial_dimension, 4] 20 | boxes = op.Unsqueeze(boxes, [0]) 21 | # scores: [num_batches, num_classes, spatial_dimension] 22 | scores = op.Unsqueeze(scores, [0, 1]) 23 | # nms_out: [num_selected_indices, 3] where each column is [batch_index, class_index, box_index] 24 | nms_out = op.NonMaxSuppression(boxes, scores, _INT64_MAX, iou_threshold) 25 | return op.Reshape(op.Slice(nms_out, axes=[1], starts=[2], ends=[3]), [-1]) 26 | -------------------------------------------------------------------------------- /tests/functions/ort_custom_ops.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | import math 4 | 5 | from onnxscript import script 6 | from onnxscript.onnx_opset import opset16 as op 7 | 8 | M_SQRT1_2 = math.sqrt(0.5) 9 | 10 | 11 | @script() 12 | def Gelu(X): 13 | phiX = 0.5 * (op.Erf(M_SQRT1_2 * X) + 1.0) 14 | return X * phiX 15 | 16 | 17 | M_2_SQRTPI = 2.0 / math.sqrt(math.pi) 18 | ALPHA = M_2_SQRTPI * M_SQRT1_2 * 0.5 19 | 20 | 21 | @script() 22 | def GeluGrad(dY, X): 23 | phiX = 0.5 * (op.Erf(M_SQRT1_2 * X) + 1.0) 24 | XGradPhiX = ALPHA * X * op.Exp(-0.5 * X * X) 25 | grad = phiX + XGradPhiX 26 | dX = dY * grad 27 | return dX 28 | 29 | 30 | K_ALPHA = M_2_SQRTPI * M_SQRT1_2 31 | K_GAMMA = 0.044715 32 | K_BETA = K_GAMMA * K_ALPHA * 3.0 33 | 34 | 35 | @script() 36 | def FastGeluGrad(dY, X): 37 | XCube = X * X * X 38 | tanh = op.Tanh(K_ALPHA * (X + K_GAMMA * XCube)) 39 | sech_square = 1.0 - tanh * tanh 40 | sum = ALPHA * X + K_BETA * XCube 41 | grad = 0.5 * (tanh + sech_square * sum + 1.0) 42 | return dY * grad 43 | 44 | 45 | @script(default_opset=op) 46 | def SigmoidGrad(dY, Y): 47 | dX = dY * Y * (1.0 - Y) 48 | return dX 49 | 50 | 51 | @script(default_opset=op) 52 | def TanhGrad(dY, Y): 53 | return dY * (1.0 - Y * Y) 54 | -------------------------------------------------------------------------------- /docs/api/rewriter_pattern.md: -------------------------------------------------------------------------------- 1 | # onnxscript.rewriter.pattern 2 | 3 | ```{eval-rst} 4 | .. automodule::onnxscript.rewriter.pattern 5 | .. currentmodule:: onnxscript 6 | ``` 7 | 8 | ```{eval-rst} 9 | .. autosummary:: 10 | :toctree: generated 11 | :template: classtemplate.rst 12 | :nosignatures: 13 | 14 | rewriter.pattern.Pattern 15 | rewriter.pattern.StringPattern 16 | rewriter.pattern.StringConstantPattern 17 | rewriter.pattern.PrefixPattern 18 | rewriter.pattern.AttrPattern 19 | rewriter.pattern.AttrConstantPattern 20 | rewriter.pattern.OpsetPatternBuilder 21 | rewriter.pattern.OpPatternBuilder 22 | rewriter.pattern.MatchResult 23 | rewriter.pattern.ValuePattern 24 | rewriter.pattern.NodePattern 25 | rewriter.pattern.NodeOutputPattern 26 | rewriter.pattern.AnyValue 27 | rewriter.pattern.Constant 28 | rewriter.pattern.OrValue 29 | rewriter.pattern.GraphPattern 30 | rewriter.pattern.ReplacementSubgraph 31 | rewriter.pattern.ReplacementPatternFunction 32 | rewriter.pattern.PatternMatcher 33 | rewriter.pattern.SimplePatternMatcher 34 | rewriter.pattern.RewriteRule 35 | rewriter.pattern.RewriteRuleSet 36 | rewriter.pattern.RewriteRuleClassBase 37 | rewriter.pattern.MatchStatus 38 | rewriter.pattern.MatchInfo 39 | rewriter.pattern.MatchingTracer 40 | ``` 41 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # TODO: The maintainer of this repo has not yet edited this file 2 | 3 | **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? 4 | 5 | - **No CSS support:** Fill out this template with information about how to file issues and get help. 6 | - **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). 7 | - **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide. 8 | 9 | *Then remove this first heading from this SUPPORT.MD file before publishing your repo.* 10 | 11 | # Support 12 | 13 | ## How to file issues and get help 14 | 15 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 16 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 17 | feature request as a new Issue. 18 | 19 | For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE 20 | FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER 21 | CHANNEL. WHERE WILL YOU HELP PEOPLE?**. 22 | 23 | ## Microsoft Support Policy 24 | 25 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 26 | -------------------------------------------------------------------------------- /docs/api/opsets.md: -------------------------------------------------------------------------------- 1 | # Opsets and Types 2 | 3 | (l-api-opsets)= 4 | 5 | ## Opsets 6 | 7 | ```{eval-rst} 8 | .. automodule:: onnxscript.onnx_opset 9 | 10 | .. autodata:: opset19 11 | :annotation: All operators defined in opset 19 for the main domain. 12 | 13 | .. autodata:: opset18 14 | :annotation: All operators defined in opset 18 for the main domain. 15 | 16 | .. autodata:: opset17 17 | :annotation: All operators defined in opset 17 for the main domain. 18 | 19 | .. autodata:: opset16 20 | :annotation: All operators defined in opset 16 for the main domain. 21 | 22 | .. autodata:: opset15 23 | :annotation: All operators defined in opset 15 for the main domain. 24 | ``` 25 | 26 | ## Types 27 | 28 | ```{eval-rst} 29 | .. automodule:: onnxscript.onnx_types 30 | 31 | .. autodata:: BFLOAT16 32 | 33 | .. autodata:: BOOL 34 | 35 | .. autodata:: COMPLEX64 36 | 37 | .. autodata:: COMPLEX128 38 | 39 | .. autodata:: DOUBLE 40 | 41 | .. autodata:: FLOAT 42 | 43 | .. autodata:: FLOAT16 44 | 45 | .. autodata:: INT8 46 | 47 | .. autodata:: INT16 48 | 49 | .. autodata:: INT32 50 | 51 | .. autodata:: INT64 52 | 53 | .. autodata:: STRING 54 | 55 | .. autodata:: UINT8 56 | 57 | .. autodata:: UINT16 58 | 59 | .. autodata:: UINT32 60 | 61 | .. autodata:: UINT64 62 | ``` 63 | -------------------------------------------------------------------------------- /tests/models/different_opset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnx import TensorProto 5 | from onnx.helper import make_tensor 6 | 7 | from onnxscript.main import script 8 | from onnxscript.onnx_opset import opset14, opset16 9 | from onnxscript.onnx_types import INT64 10 | 11 | 12 | @script() 13 | def shape_A(data, start: INT64[1], end: INT64[1]): 14 | shape = opset16.Shape(data) 15 | zero = opset16.Constant(value=make_tensor("zero", TensorProto.INT64, [1], [0])) 16 | if end == zero: 17 | length = opset16.Shape(opset16.Shape(data)) 18 | res = opset16.Slice(shape, start, length, zero) 19 | else: 20 | res = opset16.Slice(shape, start, end, zero) 21 | return res 22 | 23 | 24 | @script() 25 | def shape_B(data, start: INT64[1], end: INT64[1]): 26 | shape = opset14.Shape(data) 27 | zero = opset14.Constant(value=make_tensor("zero", TensorProto.INT64, [1], [0])) 28 | if end == zero: 29 | length = opset14.Shape(opset14.Shape(data)) 30 | res = opset14.Slice(shape, start, length, zero) 31 | else: 32 | res = opset14.Slice(shape, start, end, zero) 33 | return res 34 | 35 | 36 | @script(default_opset=opset16) 37 | def inc_any(data): 38 | # The converter cannot know which opset to use unless it is specified 39 | # in the decorator. 40 | return data + 1 41 | -------------------------------------------------------------------------------- /docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | .navbar-brand { 2 | padding: 4px 0 2px 0; 3 | } 4 | 5 | .bi { 6 | width: 1em; 7 | height: 1em; 8 | display: inline-block; 9 | vertical-align: -0.125em; 10 | fill: currentcolor; 11 | flex-shrink: 0; 12 | } 13 | 14 | .article-meta { 15 | display: flex; 16 | align-items: first baseline; 17 | opacity: 80%; 18 | } 19 | 20 | .article-meta:not(:last-child) { 21 | margin-bottom: 0.5rem; 22 | } 23 | 24 | .article-meta .bi:first-child { 25 | margin-right: 0.5em; 26 | } 27 | 28 | .article-authors > ul { 29 | display: inline; 30 | list-style: none; 31 | margin: 0; 32 | padding: 0; 33 | } 34 | 35 | .article-authors > ul > li { 36 | display: inline; 37 | } 38 | 39 | .article-authors > ul > li:not(:last-child)::after { 40 | content: " • "; 41 | } 42 | 43 | .article-date > span { 44 | font-style: italic; 45 | font-size: 0.875rem; 46 | opacity: 80%; 47 | } 48 | 49 | .highlight { 50 | overflow-x: auto; 51 | overflow-y: scroll; 52 | } 53 | 54 | .code-title { 55 | text-align: center; 56 | font-weight: normal; 57 | font-style: italic; 58 | margin-top: 1.5em; 59 | } 60 | 61 | @media screen { 62 | .longcode > .highlight { 63 | max-height: 25em; 64 | } 65 | } 66 | 67 | figure.math { 68 | text-align: center; 69 | margin: 1em 0; 70 | } 71 | 72 | figure.math svg { 73 | fill: currentColor; 74 | max-width: max(60%, 400px); 75 | } 76 | -------------------------------------------------------------------------------- /docs/tutorial/rewriter/allow_other_inputs.md: -------------------------------------------------------------------------------- 1 | # Specifying variable inputs in the pattern 2 | 3 | This section demonstrates the use of the `_allow_other_inputs` option in pattern-based rewriting. 4 | The `_allow_other_inputs` option allows the pattern to match nodes that have additional inputs 5 | beyond those specified in the pattern. If it is set to `False` (the default), then the node must 6 | have exactly the specified inputs for a successful match. If set to `True`, the pattern will 7 | match nodes that have the specified inputs plus any number of additional inputs. 8 | 9 | This is particularly useful when matching operations like `Conv` that can have optional inputs 10 | (such as bias), or when creating generic patterns that should work with various input configurations. 11 | 12 | ```{literalinclude} examples/allow_other_inputs.py 13 | :pyobject: conv_pattern 14 | ``` 15 | 16 | ```{literalinclude} examples/allow_other_inputs.py 17 | :pyobject: conv_replacement 18 | ``` 19 | 20 | ```{literalinclude} examples/allow_other_inputs.py 21 | :pyobject: apply_rewrite 22 | ``` 23 | 24 | In this example, the pattern matches `Conv` operations with any number of inputs. A `Conv` operation 25 | might have 2 inputs (input and weight) or 3 inputs (input, weight, and bias). By setting 26 | `_allow_other_inputs=True`, our pattern will match both cases even though we only specify 2 inputs 27 | in the pattern definition. 28 | -------------------------------------------------------------------------------- /docs/examples/04_plot_eager_mode_evaluation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | """ 4 | Eager mode evaluation 5 | ===================== 6 | 7 | An *onnxscript* function can be executed directly as a Python function (for example, 8 | with a Python debugger). This is useful for debugging an *onnxscript* function definition. 9 | This execution makes use of a backend implementation of the ONNX ops used in the function 10 | definition. Currently, the backend implementation uses onnxruntime to execute each op 11 | invocation. This mode of execution is referred to as *eager mode evaluation*. 12 | 13 | The example below illustrates this. We first define an *onnxscript* function: 14 | """ 15 | 16 | import numpy as np 17 | 18 | from onnxscript import FLOAT, script 19 | from onnxscript import opset15 as op 20 | 21 | 22 | @script() 23 | def linear(A: FLOAT["N", "K"], W: FLOAT["K", "M"], Bias: FLOAT["M"]) -> FLOAT["N", "M"]: # noqa: F821 24 | T1 = op.MatMul(A, W) 25 | T2 = op.Add(T1, Bias) 26 | Y = op.Relu(T2) 27 | return Y 28 | 29 | 30 | # %% 31 | # Create inputs for evaluating the function: 32 | 33 | np.random.seed(0) 34 | m = 4 35 | k = 16 36 | n = 4 37 | a = np.random.rand(k, m).astype("float32").T 38 | w = np.random.rand(n, k).astype("float32").T 39 | b = np.random.rand(n).astype("float32").T 40 | 41 | # %% 42 | # Evaluate the function: 43 | print(linear(a, w, b)) 44 | -------------------------------------------------------------------------------- /tests/operator_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | import onnx.helper 7 | 8 | import onnxscript.testing 9 | from onnxscript import script 10 | from onnxscript.onnx_opset import opset15 as op 11 | from onnxscript.onnx_types import FLOAT 12 | 13 | 14 | class TestConverter(unittest.TestCase): 15 | def test_plus_op(self): 16 | """Test that + is translated to Add op.""" 17 | 18 | @script(default_opset=op) 19 | def plus1(x, y): 20 | return x + y 21 | 22 | @script() 23 | def plus2(x, y): 24 | return op.Add(x, y) 25 | 26 | onnxscript.testing.assert_isomorphic_function(plus1, plus2) 27 | 28 | def test_const_promotion(self): 29 | """Test promotion of constant literals to TensorProto.""" 30 | 31 | @script() 32 | def explicit_plus1(A: FLOAT["N"]) -> FLOAT["N"]: # noqa: F821 33 | one = op.Constant(value=onnx.helper.make_tensor("one", 1, [], [1.0])) 34 | one_cast = op.CastLike(one, A) 35 | return op.Add(A, one_cast) 36 | 37 | @script() 38 | def implicit_plus1(A: FLOAT["N"]) -> FLOAT["N"]: # noqa: F821 39 | return op.Add(A, 1.0) 40 | 41 | onnxscript.testing.assert_isomorphic_function(explicit_plus1, implicit_plus1) 42 | 43 | 44 | if __name__ == "__main__": 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /tests/ir/graph_view_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | import pathlib 4 | import unittest 5 | 6 | import onnx 7 | 8 | from onnxscript import ir 9 | 10 | 11 | class GraphViewTest(unittest.TestCase): 12 | def test_it_can_be_serialized_as_graph_proto(self): 13 | data_path = ( 14 | pathlib.Path(__file__).parent.parent.parent 15 | / "testdata/e2e_models/torchscript_model/torchscript_model.onnx" 16 | ) 17 | model_proto = onnx.load(data_path) 18 | model = ir.serde.deserialize_model(model_proto) 19 | 20 | # Obtain a subset of nodes that belong to the first layer 21 | nodes = [ 22 | node 23 | for node in model.graph 24 | if node.name is not None and node.name.startswith("/model/layers.0") 25 | ] 26 | 27 | inputs = set() 28 | outputs = set() 29 | for node in nodes: 30 | inputs.update(node.inputs) 31 | outputs.update(node.outputs) 32 | 33 | graph_inputs = sorted(inputs - outputs, key=lambda val: val.name) 34 | graph_outputs = sorted(outputs - inputs, key=lambda val: val.name) 35 | 36 | graph_view = ir.GraphView(graph_inputs, graph_outputs, nodes=nodes) 37 | model = ir.Model(graph_view, ir_version=8) 38 | _ = ir.serde.serialize_model(model) 39 | # It should succeed 40 | 41 | 42 | if __name__ == "__main__": 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /tests/models/subfunction.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | from onnxscript import script 5 | from onnxscript.onnx_opset import opset15 as op 6 | from onnxscript.onnx_types import FLOAT 7 | 8 | 9 | @script() 10 | def MySelu(X: FLOAT[None], alpha: FLOAT[1], gamma: FLOAT[1]) -> FLOAT[None]: 11 | zero = op.Constant(value_float=1.0) 12 | neg = gamma * (alpha * op.Exp(X) - alpha) 13 | pos = gamma * X 14 | return op.Where(X <= zero, neg, pos) 15 | 16 | 17 | @script() 18 | def MyElu(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: 19 | alpha = op.Constant(value_float=1.0) 20 | return MySelu(X, alpha, beta) 21 | 22 | 23 | @script() 24 | def MyEluB(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: 25 | alpha = op.Constant(value_float=1.0) 26 | res = MySelu(X, alpha, beta) 27 | return res 28 | 29 | 30 | @script() 31 | def MyEluC(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: 32 | alpha = op.Constant(value_float=1.0) 33 | res = op.Identity(MySelu(X, alpha, beta)) 34 | return res 35 | 36 | 37 | @script() 38 | def MyEluD(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: 39 | res = op.Identity(MyEluC(X, beta)) 40 | return res 41 | 42 | 43 | @script() 44 | def IfMyEluD(X: FLOAT[None], beta: FLOAT[1]) -> FLOAT[None]: 45 | zero = op.Constant(value_float=1.0) 46 | if beta > zero: 47 | result = MyEluB(X, beta) 48 | else: 49 | result = MyEluC(X, beta) 50 | return result 51 | -------------------------------------------------------------------------------- /tools/optimize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Microsoft Corporation. 3 | # Licensed under the MIT License. 4 | 5 | """Utility for optimizing ONNX models. 6 | 7 | Usage: 8 | python optimize.py model.onnx optimized_model.onnx 9 | """ 10 | 11 | import argparse 12 | import os 13 | 14 | import onnx 15 | import onnx.inliner 16 | 17 | import onnxscript 18 | 19 | 20 | def main(args) -> None: 21 | path = args.path 22 | output_path = args.output_path 23 | 24 | model = onnx.load(path, load_external_data=False) 25 | # Hack: Change the working directory to the model directory so the optimizer 26 | # can load external data files with relative paths. 27 | # TODO: Remove this hack by fixing the optimizer to handle external data files properly. 28 | pwd = os.getcwd() 29 | model_dir = os.path.dirname(path) 30 | os.chdir(model_dir) 31 | model = onnxscript.optimizer.optimize(model) 32 | model = onnx.inliner.inline_local_functions(model) 33 | # Optimize again in case inlining created new opportunities. 34 | model = onnxscript.optimizer.optimize(model) 35 | 36 | os.chdir(pwd) 37 | onnx.save(model, output_path) 38 | 39 | 40 | if __name__ == "__main__": 41 | parser = argparse.ArgumentParser(description="Optimize an ONNX model.") 42 | parser.add_argument("path", type=str, help="Path to the ONNX model.") 43 | parser.add_argument("output_path", type=str, help="Path to save the optimized model.") 44 | main(parser.parse_args()) 45 | -------------------------------------------------------------------------------- /onnxscript/rewriter/rules/common/_no_op.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from onnxscript.rewriter._rewrite_rule import RewriteRule, RewriteRuleSet 4 | 5 | # TODO: Support 1-D constant tensors 6 | # https://github.com/microsoft/onnx-rewriter/issues/186 7 | 8 | 9 | # Pattern to match against 10 | def mul_by_1(op, x): 11 | return x * 1 12 | 13 | 14 | def add_0(op, x): 15 | return x + 0 16 | 17 | 18 | def sub_0(op, x): 19 | return x - 0 20 | 21 | 22 | def div_by_1(op, x): 23 | return x / 1 24 | 25 | 26 | def dropout_zero(op, x): 27 | return op.Dropout(x, ratio=0.0) 28 | 29 | 30 | def dropout_inference(op, x): 31 | return op.Dropout(x, training_mode=False) 32 | 33 | 34 | # Replacement 35 | def identity(op, x, **_): 36 | return op.Identity(x) 37 | 38 | 39 | mul_by_1_rule = RewriteRule(mul_by_1, identity) 40 | add_0_rule = RewriteRule(add_0, identity) 41 | sub_0_rule = RewriteRule(sub_0, identity) 42 | div_by_1_rule = RewriteRule(div_by_1, identity) 43 | dropout_zero_rule = RewriteRule(dropout_zero, identity) 44 | dropout_inference_rule = RewriteRule(dropout_inference, identity) 45 | # TODO: Include Mul by 0, 0 by Mul, 0 by Div? Those would be 0s, but not no-ops 46 | 47 | rules = RewriteRuleSet( 48 | [ 49 | *mul_by_1_rule.commute(), 50 | *add_0_rule.commute(), 51 | sub_0_rule, 52 | div_by_1_rule, 53 | dropout_zero_rule, 54 | dropout_inference_rule, 55 | ] 56 | ) 57 | -------------------------------------------------------------------------------- /onnxscript/rewriter/ort_fusions/_test_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import onnx_ir as ir 7 | import onnxruntime 8 | import packaging.version 9 | 10 | ORT_VERSION = packaging.version.Version(onnxruntime.__version__) 11 | 12 | 13 | def ort_run(model_name: str, model, inputs): 14 | providers = ["CPUExecutionProvider"] 15 | model_proto = ir.serde.serialize_model(model) 16 | options = onnxruntime.SessionOptions() 17 | options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_DISABLE_ALL 18 | session = onnxruntime.InferenceSession( 19 | model_proto.SerializeToString(), options, providers=providers 20 | ) 21 | return session.run(None, inputs) 22 | 23 | 24 | def assert_allclose(outputs, expected_outputs, rtol=1e-3, atol=1e-3): 25 | for i, (baseline_output, optimized_output) in enumerate(zip(expected_outputs, outputs)): 26 | try: 27 | np.testing.assert_equal(baseline_output.shape, optimized_output.shape) 28 | np.testing.assert_allclose(baseline_output, optimized_output, rtol=rtol, atol=atol) 29 | except AssertionError as e: 30 | diff_mask = ~np.isclose(baseline_output, optimized_output, rtol=rtol, atol=atol) 31 | diff = np.where(diff_mask, "X", " ") 32 | print(diff) 33 | print(f"Failed for output {i} with rtol={rtol} and atol={atol}\n{e}") 34 | raise 35 | -------------------------------------------------------------------------------- /tests/functions/if_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | import numpy as np 7 | 8 | from tests.common import onnx_script_test_case 9 | from tests.models import if_statement 10 | 11 | 12 | class TestOnnxIf(onnx_script_test_case.OnnxScriptTestCase): 13 | def test_if(self): 14 | n = 8 15 | np.random.seed(0) 16 | a = np.random.rand(n).astype("float32").T 17 | b = np.random.rand(n).astype("float32").T 18 | 19 | # FIXME(liqunfu): expected are from ort evaluation. 20 | # needs numpy oxs to provide expected instead. 21 | expected = np.array( 22 | [ 23 | 0.5488135, 24 | 0.71518934, 25 | 0.60276335, 26 | 0.5448832, 27 | 0.4236548, 28 | 0.6458941, 29 | 0.4375872, 30 | 0.891773, 31 | ], 32 | dtype=np.float32, 33 | ) 34 | 35 | cases = [ 36 | onnx_script_test_case.FunctionTestParams(if_statement.maxsum, [a, b], [expected]) 37 | ] 38 | for case in cases: 39 | # FAIL : Node () Op (local_function) [TypeInferenceError] 40 | # GraphProto attribute inferencing is not enabled 41 | # in this InferenceContextImpl instance. 42 | # self.run_converter_test(case) 43 | self.run_eager_test(case) 44 | 45 | 46 | if __name__ == "__main__": 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /tests/loop_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | import unittest 4 | 5 | import numpy as np 6 | 7 | from onnxscript import script 8 | from onnxscript.onnx_opset import opset15 as op 9 | from onnxscript.onnx_types import FLOAT, INT64 10 | from tests.common import testutils 11 | 12 | 13 | class LoopOpTest(testutils.TestBase): 14 | def test_loop(self): 15 | """Basic loop test.""" 16 | 17 | @script() 18 | def sumprod(x: FLOAT["N"], N: INT64) -> (FLOAT["N"], FLOAT["N"]): # noqa: F821 19 | sum = op.Identity(x) 20 | prod = op.Identity(x) 21 | for _ in range(N): 22 | sum = sum + x 23 | prod = prod * x 24 | return sum, prod 25 | 26 | self.validate(sumprod) 27 | x = np.array([2]) 28 | M = 3 29 | sum, prod = sumprod(x, M) 30 | self.assertEqual(sum, np.array([8])) 31 | self.assertEqual(prod, np.array([16])) 32 | 33 | def test_loop_bound(self): 34 | """Test with an expression for loop bound.""" 35 | 36 | @script() 37 | def sumprod(x: FLOAT["N"], N: INT64) -> (FLOAT["N"], FLOAT["N"]): # noqa: F821 38 | sum = op.Identity(x) 39 | prod = op.Identity(x) 40 | for _ in range(2 * N + 1): 41 | sum = sum + x 42 | prod = prod * x 43 | return sum, prod 44 | 45 | self.validate(sumprod) 46 | 47 | 48 | if __name__ == "__main__": 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /.github/workflows/pages.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Docs 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | # Allows you to run this workflow manually from the Actions tab 7 | workflow_dispatch: 8 | 9 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 10 | permissions: 11 | contents: read 12 | pages: write 13 | id-token: write 14 | 15 | # Allow one concurrent deployment 16 | concurrency: 17 | group: "pages" 18 | cancel-in-progress: true 19 | 20 | jobs: 21 | deploy: 22 | environment: 23 | name: github-pages 24 | url: ${{ steps.deployment.outputs.page_url }} 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Checkout 28 | uses: actions/checkout@v6 29 | - name: Setup Pages 30 | uses: actions/configure-pages@v4 31 | - name: Setup Python 32 | uses: actions/setup-python@v6 33 | with: 34 | python-version: "3.10" 35 | - uses: actions/checkout@v6 36 | - name: Install dependencies 37 | run: | 38 | python -m pip install --upgrade pip setuptools wheel 39 | python -m pip install -r requirements-dev.txt 40 | - name: Install package 41 | run: pip install . 42 | - name: Build documentation 43 | run: python -m sphinx docs dist/html 44 | - name: Upload documentation archive 45 | uses: actions/upload-pages-artifact@v4 46 | with: 47 | path: 'dist/html' 48 | - name: Deploy to GitHub Pages 49 | id: deployment 50 | uses: actions/deploy-pages@v4 51 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to ONNX Script 2 | 3 | We're always looking for your help to improve the product (bug fixes, new features, documentation, etc). Currently ONNX Script is under early and heavy development, so we encourage proposing any major changes by [filing an issue](https://github.com/microsoft/onnxscript/issues) to discuss your idea with the team first. 4 | 5 | ## Report a security issue 6 | 7 | **Please do not report security vulnerabilities through public GitHub issues.** 8 | 9 | Please refer to our guidance on filing [Security Issues](SECURITY.md). 10 | 11 | ## Licensing guidelines 12 | 13 | This project welcomes contributions and suggestions. Most contributions require you to 14 | agree to a Contributor License Agreement (CLA) declaring that you have the right to, 15 | and actually do, grant us the rights to use your contribution. For details, visit 16 | https://cla.microsoft.com. 17 | 18 | When you submit a pull request, a CLA-bot will automatically determine whether you need 19 | to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the 20 | instructions provided by the bot. You will only need to do this once across all repositories using our CLA. 21 | 22 | ## Code of conduct 23 | 24 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 25 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 26 | or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 27 | -------------------------------------------------------------------------------- /onnxscript/rewriter/ort_fusions/gelu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | from __future__ import annotations 4 | 5 | import math 6 | 7 | from onnxscript.rewriter import _fusion_utils, pattern 8 | 9 | _SQRT_TWO_OVER_PI = math.sqrt(2.0 / math.pi) 10 | _SQRT_TWO = math.sqrt(2.0) 11 | 12 | 13 | class GeluTanhFusion(pattern.RewriteRuleClassBase): 14 | def pattern(self, op, x): 15 | # GELU(x) = 0.5 * x * {1 + Tanh[\sqrt(2/pi) * (x + 0.044715 * x^3)]} 16 | t1 = op.Pow(x, 3) 17 | t2 = op.Mul(0.044715, t1) 18 | t3 = op.Add(x, t2) 19 | 20 | t4 = op.Mul(_SQRT_TWO_OVER_PI, t3) 21 | t5 = op.Tanh(t4) 22 | t6 = op.Add(t5, 1) 23 | t7 = op.Mul(0.5, t6) 24 | result = op.Mul(x, t7) 25 | return result 26 | 27 | def rewrite(self, op, x): 28 | return op.FastGelu(x, _domain="com.microsoft") 29 | 30 | 31 | class GeluErfFusion(pattern.RewriteRuleClassBase): 32 | def pattern(self, op, x): 33 | # GELU(x) = 0.5 * x * (1 + erf(x / sqrt(2))) 34 | t1 = op.Div(x, _SQRT_TWO) 35 | t2 = op.Erf(t1) 36 | t3 = op.Add(t2, 1.0) 37 | t4 = op.Mul(x, t3) 38 | result = op.Mul(t4, 0.5) 39 | return result 40 | 41 | def rewrite(self, op, x): 42 | return op.Gelu(x, _domain="com.microsoft") 43 | 44 | 45 | _tanh_rule = GeluTanhFusion.rule() 46 | _erf_rule = GeluErfFusion.rule() 47 | 48 | gelu_rules = pattern.RewriteRuleSet([_tanh_rule, _erf_rule]) 49 | 50 | fuse_gelu = _fusion_utils.apply_fusion_rules(gelu_rules) 51 | -------------------------------------------------------------------------------- /tests/if_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | import onnxscript.testing 7 | from onnxscript import script 8 | from onnxscript.onnx_opset import opset15 as op 9 | from tests.common import testutils 10 | 11 | 12 | class IfOpTest(testutils.TestBase): 13 | def test_no_else(self): 14 | """Basic test for if-then without else.""" 15 | 16 | # TODO: pass default opset as parameter to @script 17 | @script() 18 | def if1(cond, x, y): 19 | result = op.Identity(y) 20 | if cond: 21 | result = op.Identity(x) 22 | return result 23 | 24 | # if1 should be treated as equivalent to the code if2 below 25 | @script() 26 | def if2(cond, x, y): 27 | result = op.Identity(y) 28 | if cond: 29 | result = op.Identity(x) 30 | else: 31 | result = op.Identity(result) 32 | return result 33 | 34 | # if2 should be treated as equivalent to the code if3 below (SSA renaming) 35 | @script() 36 | def if3(cond, x, y): 37 | result1 = op.Identity(y) 38 | if cond: 39 | result2 = op.Identity(x) 40 | else: 41 | result2 = op.Identity(result1) 42 | return result2 43 | 44 | onnxscript.testing.assert_isomorphic_function(if1, if2) 45 | onnxscript.testing.assert_isomorphic_function(if2, if3) 46 | 47 | 48 | if __name__ == "__main__": 49 | unittest.main() 50 | --------------------------------------------------------------------------------