repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
onnxruntime
onnxruntime/test/python/transformers/parity_utilities.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- import ar...
240
7,804
onnxruntime
onnxruntime/test/python/transformers/test_shape_infer_helper.py
.py
import unittest import onnx import pytest import torch from parity_utilities import find_transformers_source if find_transformers_source(): from benchmark_helper import ConfigModifier, OptimizerInfo, Precision from huggingface_models import MODELS from onnx_exporter import export_onnx_model_from_pt fr...
79
3,117
onnxruntime
onnxruntime/test/python/transformers/test_qmoe_wfp4afp8_cuda.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # # Tes...
510
18,129
onnxruntime
onnxruntime/test/python/transformers/test_optimizer.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
160
6,357
onnxruntime
onnxruntime/test/python/transformers/test_qmoe_fp4_cuda.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # # Tes...
1,178
48,551
onnxruntime
onnxruntime/test/python/transformers/test_attention_fusion.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
789
32,294
onnxruntime
onnxruntime/test/python/transformers/test_whisper_timestamp_processor.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
83
3,475
onnxruntime
onnxruntime/test/python/transformers/conformer_model_generator.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import...
964
42,653
onnxruntime
onnxruntime/test/python/transformers/test_moe_cpu.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # # Reg...
474
16,370
onnxruntime
onnxruntime/test/python/transformers/qwen3_model_generator.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """Synt...
454
19,112
onnxruntime
onnxruntime/test/python/transformers/test_gqa_cpu_quantized.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """Tests for CPU GroupQueryAttention with quantized KV cache (INT8/INT...
1,035
38,210
onnxruntime
onnxruntime/test/python/transformers/test_float16.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
276
12,200
onnxruntime
onnxruntime/test/python/transformers/test_parity_huggingface_gpt_attention.py
.py
# -------------------------------------------------------------------------- # Copyright 2020 The HuggingFace Inc. team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/l...
540
18,893
onnxruntime
onnxruntime/test/python/transformers/test_optimizer_stable_diffusion.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import o...
404
14,578
onnxruntime
onnxruntime/test/python/transformers/benchmark_mha.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Benchmark performance of MultiHeadAttention with ORT or PyTorch. I...
1,421
51,866
onnxruntime
onnxruntime/test/python/transformers/dit_model_generator.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """Synt...
222
9,584
onnxruntime
onnxruntime/test/python/transformers/test_sparse_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Parity test and benchmark performance of SparseAttention. Requires ...
865
35,907
onnxruntime
onnxruntime/test/python/transformers/test_gqa.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # Copyr...
4,564
184,001
onnxruntime
onnxruntime/test/python/transformers/test_moe_cuda.py
.py
# -------------------------------------------------------------------------- # Copyright 2020 The HuggingFace Inc. team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/l...
1,910
69,624
onnxruntime
onnxruntime/test/python/transformers/test_rotary_mha_fusion.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import os import sys import unittest import numpy as np import onnx from onnx impo...
1,210
45,347
onnxruntime
onnxruntime/test/python/transformers/test_qmoe_cuda.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # # QMo...
3,189
131,644
onnxruntime
onnxruntime/test/python/transformers/test_paged_attention.py
.py
# -------------------------------------------------------------------------- # Copyright 2020 The HuggingFace Inc. team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/l...
3,054
137,238
onnxruntime
onnxruntime/test/python/transformers/test_rotary_embedding_fusion.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import os import sys import unittest import numpy as np import onnx from onnx impo...
447
16,532
onnxruntime
onnxruntime/test/python/transformers/test_convert_tf_models_to_pytorch.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
62
2,309
onnxruntime
onnxruntime/test/python/transformers/test_skip_layer_norm_fusion.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
465
19,248
onnxruntime
onnxruntime/test/python/transformers/test_qmoe_fp8_cuda.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import...
252
9,576
onnxruntime
onnxruntime/test/python/transformers/test_profiler.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
48
1,609
onnxruntime
onnxruntime/test/python/transformers/test_optimizer_huggingface_bert.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
152
6,357
onnxruntime
onnxruntime/test/python/transformers/test_cuda_plugin_ep.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json import os import tempfile import unittest from contextlib import contextmanager import numpy as np import torch import torch.nn.functional as F from cuda_plugin_ep_helper import CUDA_PLUGIN_EP_NAME, ensure_cuda_p...
3,105
132,936
onnxruntime
onnxruntime/test/python/transformers/test_parity_layernorm.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
313
10,489
onnxruntime
onnxruntime/test/python/transformers/gpt2_model_generator.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
1,333
48,614
onnxruntime
onnxruntime/test/python/transformers/profile_qmoe_gemv.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Profiling script for the CUDA QMoE GEMV decode path. Usage: pyth...
129
5,146
onnxruntime
onnxruntime/test/python/transformers/test_onnx_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import unittest import numpy from onnx import ModelProto, TensorProto, ...
39
1,886
onnxruntime
onnxruntime/test/python/transformers/test_conformer.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
156
7,022
onnxruntime
onnxruntime/test/python/transformers/rotary_flash.py
.py
# Copyright (c) 2023, Tri Dao. import torch import triton import triton.language as tl from einops import rearrange, repeat ##### TRITON KERNEL FOR ROTARY ##### # @triton.autotune( # configs=[ # triton.Config({"block_m": 2}), # triton.Config({"block_m": 4}), # triton.Config({"block_m": ...
689
27,375
onnxruntime
onnxruntime/test/python/transformers/test_parity_neox_attention.py
.py
# -------------------------------------------------------------------------- # Copyright 2020 The HuggingFace Inc. team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/l...
485
20,135
onnxruntime
onnxruntime/test/python/transformers/test_clean_graph.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
294
12,898
onnxruntime
onnxruntime/test/python/transformers/parse_nsys.py
.py
#!/usr/bin/env python3 # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Parse nsys SQLite output to extract CUDA ker...
571
20,756
onnxruntime
onnxruntime/test/python/transformers/test_mha_flash_attn.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- import o...
447
14,874
onnxruntime
onnxruntime/test/python/transformers/test_constant_fold.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import os import unittest import onnx from bert_model_generator import float_tenso...
124
5,325
onnxruntime
onnxruntime/test/python/transformers/test_gelu_fusions.py
.py
import math import os import unittest import torch from parameterized import parameterized from parity_utilities import find_transformers_source if find_transformers_source(): from optimizer import optimize_model else: from onnxruntime.transformers.optimizer import optimize_model class HuggingfaceGelu(torch...
106
3,991
onnxruntime
onnxruntime/test/python/transformers/test_embedlayer_fusion.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
112
5,429
onnxruntime
onnxruntime/test/python/transformers/benchmark_gqa.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Benchmark performance of GroupQueryAttention. """ from dataclasses...
331
12,407
onnxruntime
onnxruntime/test/python/transformers/benchmark_gqa_windows.py
.py
import argparse import os import time import torch from gqa_test_helper import GroupQueryAttentionConfig, OrtGroupQueryAttention def save_results(results, filename): import pandas as pd # noqa: PLC0415 df = pd.DataFrame( results, columns=[ "Inference Interval (ms)", ...
237
8,879
onnxruntime
onnxruntime/test/python/transformers/bert_padding.py
.py
# From https://github.com/Dao-AILab/flash-attention/blob/2286d7cea7ca8264165c16b2442b6436c43140de/flash_attn/bert_padding.py import torch import torch.nn.functional as F from einops import rearrange, repeat class IndexFirstAxis(torch.autograd.Function): @staticmethod def forward(ctx, input, indices): ...
132
5,786
onnxruntime
onnxruntime/test/python/transformers/profile_matmul_nbits.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Profiling script for the CUDA MatMulNBits (4-bit / 8-bit weight-onl...
207
7,337
onnxruntime
onnxruntime/test/python/transformers/test_gpt2_to_onnx.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
63
2,357
onnxruntime
onnxruntime/test/python/transformers/cuda_plugin_ep_helper.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import logging import os import sys from importlib.metadata import PackageNotFoundError, distribution from pathlib import Path import torch import onnxruntime as onnxrt CUDA_PLUGIN_EP_NAME = "CUDAExecutionProvider" enable_...
205
6,919
onnxruntime
onnxruntime/test/python/transformers/profile_skip_layer_norm.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Profiling script for SkipLayerNormalization CUDA kernel. Usage: ...
177
6,681
onnxruntime
onnxruntime/test/python/transformers/test_parity_decoder_attention.py
.py
# -------------------------------------------------------------------------- # Copyright 2020 The HuggingFace Inc. team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/l...
590
20,946
onnxruntime
onnxruntime/test/python/transformers/test_gemmfastgelu_fusion.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
153
5,182
onnxruntime
onnxruntime/test/python/transformers/profile_disable_sync.py
.py
#!/usr/bin/env python3 # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Profiling helper to verify that the CUDA EP ...
206
8,394
onnxruntime
onnxruntime/test/python/transformers/test_parity_gelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """ Belo...
243
7,935
onnxruntime
onnxruntime/test/python/transformers/test_phi_vision.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
305
11,806
onnxruntime
onnxruntime/test/python/transformers/benchmark_onnx_attention_vs_gqa.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Benchmark ONNX Attention (opset 23/24, CUDA EP) against contrib Gro...
800
34,683
onnxruntime
onnxruntime/test/python/transformers/bart_model_generator.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """Gene...
280
13,360
onnxruntime
onnxruntime/test/python/transformers/env_var_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os from contextlib import contextmanager @contextmanager def s...
26
802
onnxruntime
onnxruntime/test/python/transformers/test_group_norm.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- import s...
541
16,637
onnxruntime
onnxruntime/test/python/transformers/test_whisper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
919
36,603
onnxruntime
onnxruntime/test/python/transformers/test_qmoe_cpu.py
.py
# -------------------------------------------------------------------------- # Copyright 2020 The HuggingFace Inc. team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/l...
1,899
78,241
onnxruntime
onnxruntime/test/python/transformers/test_parity_linear_attention_causal_conv.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import unittest import numpy as np import torch from onnx import TensorProto, checker, helper import onnxruntime onnxruntime.preload_dlls() def _has_cuda_ep() -> bool: return "CUDAExecutionProvider" in onnxruntime.ge...
571
23,036
onnxruntime
onnxruntime/test/python/transformers/gqa_test_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import math import numpy import torch from onnx import TensorProto, he...
632
24,608
onnxruntime
onnxruntime/test/python/transformers/profile_gqa.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Simple profiling script for GroupQueryAttention with quantized KV c...
250
9,374
onnxruntime
onnxruntime/test/python/transformers/benchmark_gqa_cpu_flash.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ Benchmark CPU GroupQueryAttention: Flash Attention vs Naive (full materialization). Runs the actual GQA operator via InferenceSession, toggling between flash and naive paths using the ORT_GQA_DISAB...
403
14,252
onnxruntime
onnxruntime/test/python/transformers/test_parity_rotary_embedding.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # Notes # 1) The test cases in this file are for the following LLaMA-2 scenarios: ...
490
21,636
onnxruntime
onnxruntime/test/python/transformers/bert_model_generator.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
631
23,635
onnxruntime
onnxruntime/test/python/transformers/model_loader.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
70
2,593
onnxruntime
onnxruntime/test/python/transformers/benchmark_qmoe.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os import sys import time import unittest import numpy import t...
192
8,160
onnxruntime
onnxruntime/test/python/transformers/test_mha.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Test MultiHeadAttention operator for CUDA and CPU. """ import conc...
912
38,713
onnxruntime
onnxruntime/test/python/transformers/conftest.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """Confi...
57
2,203
onnxruntime
onnxruntime/test/python/transformers/test_gpt2_benchmark.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------...
55
1,899
onnxruntime
onnxruntime/test/python/transformers/test_data/gpt2_pytorch1.5_opset11/generate_tiny_gpt2_model.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # This tool generates a tiny GPT2 model for testing fusion script. # You...
529
21,550
onnxruntime
onnxruntime/test/python/transformers/test_data/bert_squad_tensorflow2.1_keras2onnx_opset11/generate_tiny_keras2onnx_bert_models.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Convert a Bert large model exported by Keras2Onnx to a tiny model fo...
447
18,102
onnxruntime
onnxruntime/test/python/transformers/sharded_moe/test_sharded_moe.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import unittest import numpy as np from onnx import TensorProto, helpe...
424
11,810
onnxruntime
onnxruntime/test/python/transformers/test_onnx_attention/test_tensorscatter_attention.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """ Te...
2,191
102,859
onnxruntime
onnxruntime/test/python/transformers/test_onnx_attention/test_gqa.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # Copyr...
3,105
112,243
onnxruntime
onnxruntime/test/python/transformers/test_onnx_attention/common.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # Copyr...
921
37,522
onnxruntime
onnxruntime/test/python/transformers/test_onnx_attention/test_mha.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """ Te...
3,089
107,263
onnxruntime
onnxruntime/test/common/test_cpuinfo_sysfs_fallback.py
.py
#!/usr/bin/env python3 """ Simulation test for the cpuinfo sysfs fallback fix. This test verifies two fixes for https://github.com/microsoft/onnxruntime/issues/10038: 1. Safe logging in env.cc - PosixEnv constructor no longer crashes when the logging system is not yet initialized and cpuinfo_initialize() fails. 2...
564
21,514
onnxruntime
onnxruntime/test/onnx/gen_test_models.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import argparse import os import warnings from datetime import date import numpy as np import onnx from onnx import AttributeProto, GraphProto, TensorProto, helper, numpy_helper, utils # noqa: F401 #...
206
7,936
onnxruntime
onnxruntime/test/testdata/dmmha_inside_mha_graph.py
.py
from onnx import TensorProto, helper, save_model # Whisper decoder self attention with past_kv, present_kv, buffer sharing enabled, mask, and bias # Used in decoder-with-past's self-attention layers def dmmha_inside_mha_self_attn(): num_heads, head_size = 2, 32 hidden_size = num_heads * head_size # Input...
236
9,820
onnxruntime
onnxruntime/test/testdata/test_shape_data_propagation_shape_mul_constantofshape.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # Negative regression fixture for the single-element guard in the elementwise # data-propagation consumers (Add/Sub/Mul/Div). # # Shape(X[3, 4]) produces a rank-1, MULTI-element value [3, 4]. The elementwise # custom data pro...
51
2,263
onnxruntime
onnxruntime/test/testdata/custom_mul.py
.py
import onnx def create_custom_mul_model(): # === Inputs === x = onnx.helper.make_tensor_value_info("X", onnx.TensorProto.FLOAT, [3, 2]) w = onnx.helper.make_tensor_value_info("W", onnx.TensorProto.FLOAT, [3, 2]) # === Output === y = onnx.helper.make_tensor_value_info("Y", onnx.TensorProto.FLOAT, ...
46
1,274
onnxruntime
onnxruntime/test/testdata/sparse_to_dense_matmul.py
.py
import argparse import sys import traceback import onnx from onnx import ( TensorProto, ValueInfoProto, helper, ) from onnx.helper import make_opsetid def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument("--output_file", required=True, type=str, help="Model file name to s...
106
3,415
onnxruntime
onnxruntime/test/testdata/make_conv_int4_weights_model.py
.py
import numpy as np import onnx from onnxruntime.quantization import CalibrationDataReader, QuantType, quantize from onnxruntime.quantization.execution_providers.qnn import get_qnn_qdq_config INPUT0_SHAPE = (1, 3, 8, 8) INPUT0_NAME = "input_0" def create_f32_model(): input_0 = onnx.helper.make_tensor_value_info(...
99
4,182
onnxruntime
onnxruntime/test/testdata/transpose_optimizer_shared_initializers.py
.py
import numpy as np import onnx from onnx import TensorProto, helper # Create a model with shared initializers that can be updated in-place by the transpose optimizer, # including ones behind a DQ node. The transpose optimizer updates the first usage and inserts # Transpose/Unsqueeze ops on the others (see UnsqueezeIn...
117
5,961
onnxruntime
onnxruntime/test/testdata/clip_div_shared_initializer.py
.py
from onnx import TensorProto, checker, helper, save graph_proto = helper.make_graph( [ helper.make_node( "Clip", inputs=["input_0", "initializer_0", "initializer_1"], outputs=["clip_output"], name="clip", ), helper.make_node( "Div"...
34
936
onnxruntime
onnxruntime/test/testdata/ort_github_issue_10305.py
.py
import onnx from onnx import TensorProto, helper # Loop is so the Tranpose output is used in a subgraph loop_body = helper.make_graph( [ helper.make_node("Add", ["transpose:0", "loop_state_in"], ["loop_state_out"], "Add1"), ], "Loop_body", [ helper.make_tensor_value_info("iteration_num"...
73
2,374
onnxruntime
onnxruntime/test/testdata/test_dangling_input_segment_ids.py
.py
""" Run this script to recreate the original onnx model. Example usage: python test_dangling_input_segment_ids.py test_dangling_input_segment_ids.onnx """ import sys import numpy as np import onnx def order_repeated_field(repeated_proto, key_name, order): order = list(order) repeated_proto.sort(key=lambda x...
137
7,173
onnxruntime
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v2.py
.py
import onnx from onnx import TensorProto, helper # === Graph input/output === input_tensor = helper.make_tensor_value_info("input", TensorProto.FLOAT, ["batch", 3, "width", "height"]) output_tensor = helper.make_tensor_value_info("output", TensorProto.FLOAT, ["batch", 3, "width*height"]) # === Initializers === B = he...
60
2,644
onnxruntime
onnxruntime/test/testdata/shape_then_slice_and_gather.py
.py
from pathlib import Path import onnx from onnx import helper from onnx.onnx_pb import TensorProto nodes = [ helper.make_node("Shape", ["X"], ["X_shape"]), helper.make_node("Gather", ["X_shape", "gather_indices"], ["gather_out"], axis=0), helper.make_node("Slice", ["X_shape", "slice_starts", "slice_ends", ...
34
1,264
onnxruntime
onnxruntime/test/testdata/ort_github_issue_26272.py
.py
import onnx from onnx import TensorProto, helper # Create a simple ONNX model with DDS output input = helper.make_tensor_value_info("data", TensorProto.FLOAT, ["d1", "d2"]) output = helper.make_tensor_value_info("output", TensorProto.FLOAT, ["nzr"]) nonzeros_node = helper.make_node("NonZero", ["data"], ["nonzeros"], ...
27
946
onnxruntime
onnxruntime/test/testdata/dmmha_inside_mha_data.py
.py
import numpy as np import onnxruntime as ort from onnxruntime import OrtValue np.random.seed(0) # Whisper decoder self attention with past_kv, present_kv, buffer sharing enabled, mask, and bias # Used in decoder-with-past's self-attention layers # For CUDA, K caches are transposed and reshaped from 4D to 5D for Dec...
196
8,921
onnxruntime
onnxruntime/test/testdata/model_with_metadata.py
.py
import onnx from onnx import TensorProto, helper # Create a model with metadata to test ORT conversion def GenerateModel(model_name): # noqa: N802 nodes = [ helper.make_node("Sigmoid", ["X"], ["Y"], "sigmoid"), ] graph = helper.make_graph( nodes, "NNAPI_Internal_uint8_Test", ...
38
977
onnxruntime
onnxruntime/test/testdata/dynamic_quantize_matmul_test.py
.py
import onnx from onnx import TensorProto, helper def GenerateModel(model_name, sign, b_zp=True, bias=False): # noqa: N802 nodes = [ # DynamicQuantizeMatMul subgraph helper.make_node( "DynamicQuantizeLinear", ["A"], ["a_quantized", "a_scale", "a_zp"], "Dyna...
69
2,317
onnxruntime
onnxruntime/test/testdata/ort_github_issue_17000.py
.py
import numpy as np import onnx from onnx import TensorProto, helper, numpy_helper def order_repeated_field(repeated_proto, key_name, order): order = list(order) repeated_proto.sort(key=lambda x: order.index(getattr(x, key_name))) def make_node(op_type, inputs, outputs, name=None, doc_string=None, domain=Non...
78
3,053
onnxruntime
onnxruntime/test/testdata/trt_plugin_custom_op_test.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import onnx from onnx import TensorProto, helper def generate_model(model_name): nodes = [ helper.make_node( "DisentangledAttention_TRT", ["input1", "input2", "inpu...
41
1,141
onnxruntime
onnxruntime/test/testdata/test_evil_weights.py
.py
import onnx def create_exp_model(): inputs = [] nodes = [] tensors = [] outputs = [] input_ = onnx.helper.make_tensor_value_info("input", onnx.TensorProto.INT64, [None, None]) inputs.append(input_) evil_tensor = onnx.helper.make_tensor( name="evil_weights", data_type=onnx...
50
1,507
onnxruntime
onnxruntime/test/testdata/nnapi_sigmoid_input_rank_test.py
.py
import onnx from onnx import TensorProto, helper # Since NNAPI ANEURALNETWORKS_LOGISTIC only supports input tensor rank up to 4, we added limits in # Sigmoid op support checker in NNAPI EP, so we don't fail hard. Added test case here. def GenerateModel(model_name): # noqa: N802 node = [ helper.make_node...
26
796
onnxruntime
onnxruntime/test/testdata/loop_sub_one.py
.py
from onnx import TensorProto, checker, helper, save, shape_inference """ x = A for (int i = 0; i < MAX_ITERS; i++) { y = x - 1.0 user_val = x - 1.0 x = y } C = x D = user_val (will be the concatenated result of all iterations) """ loop_body = helper.make_graph( nodes=[ helper.make_node( ...
70
2,025