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/python/tools/transformers/models/sam2/prompt_encoder.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import torch from sam2.modeling.sam2_base import SAM2Bas...
190
8,341
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/nvtx_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import nvtx from cuda import cudart class NvtxHelper: def __init__...
34
1,279
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/cache_helper.py
.py
import packaging.version as pv import torch from transformers import __version__ as transformers_version from transformers.cache_utils import DynamicCache, EncoderDecoderCache def is_cache_dynamic_registered(fast: bool = False) -> bool: """ Tells class :class:`DynamicCache` can be serialized and deseriali...
73
2,334
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/onnx_export_serialization.py
.py
from typing import Any import torch from transformers.cache_utils import DynamicCache, MambaCache ############ # MambaCache ############ # self.conv_states: torch.Tensor = torch.zeros( # config.num_hidden_layers, # self.max_batch_size, # self.intermediate_size, # self.conv_kernel_size, # device=...
125
3,757
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/__init__.py
.py
from dataclasses import fields, is_dataclass from typing import Any import numpy as np import packaging.version as pv import torch from transformers import __version__ as transformers_version from transformers.cache_utils import DynamicCache, EncoderDecoderCache from .onnx_export_errors import ( bypass_export_som...
464
15,780
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/onnx_export_errors.py
.py
import contextlib import pprint from collections.abc import Callable from typing import Any from .onnx_export_serialization import ( flatten_dynamic_cache, flatten_mamba_cache, flatten_with_keys_dynamic_cache, flatten_with_keys_mamba_cache, unflatten_dynamic_cache, unflatten_mamba_cache, ) from...
472
18,236
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/patch_inputs.py
.py
import inspect from typing import Any import torch from transformers.cache_utils import DynamicCache from . import string_type from .cache_helper import make_dynamic_cache def _process_cache(k: str, v): assert k != "position_ids" or isinstance(k, torch.Tensor), ( f"Unexpected type for parameter {k!r} {s...
167
6,629
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/patches/patch_torch.py
.py
import inspect import os from collections.abc import Callable, Sequence from typing import Any import torch from torch._subclasses.fake_tensor import FakeTensorMode def _catch_produce_guards_and_solve_constraints( previous_function: Callable, fake_mode: "FakeTensorMode", gm: "torch.fx.GraphModule", d...
324
14,034
onnxruntime
onnxruntime/python/tools/transformers/models/torch_export_patches/patches/patch_transformers.py
.py
import inspect import sys from dataclasses import dataclass from typing import Any import torch from transformers.cache_utils import Cache, DynamicCache, StaticCache from transformers.generation.utils import GenerationMixin from transformers.modeling_attn_mask_utils import AttentionMaskConverter def _patch_make_caus...
475
20,997
onnxruntime
onnxruntime/python/tools/transformers/models/bert/eval_squad.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # # This script evaluates accuracy of ONNX models for question-answering...
330
12,026
onnxruntime
onnxruntime/python/tools/transformers/models/llama/llama_parity.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- from __f...
344
11,557
onnxruntime
onnxruntime/python/tools/transformers/models/llama/dist_settings.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...
58
1,602
onnxruntime
onnxruntime/python/tools/transformers/models/llama/llama_torch.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 l...
48
1,685
onnxruntime
onnxruntime/python/tools/transformers/models/llama/benchmark.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 a...
701
26,594
onnxruntime
onnxruntime/python/tools/transformers/models/llama/convert_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. # -------------------------------------------------------------------------- from __f...
1,067
42,292
onnxruntime
onnxruntime/python/tools/transformers/models/llama/llama_inputs.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- from __f...
505
20,222
onnxruntime
onnxruntime/python/tools/transformers/models/llama/quant_kv_dataloader.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 a...
109
4,851
onnxruntime
onnxruntime/python/tools/transformers/models/llama/benchmark_all.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 a...
489
15,305
onnxruntime
onnxruntime/python/tools/transformers/models/llama/benchmark_e2e.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # This ...
609
24,869
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_helper.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 j...
1,039
50,551
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/benchmark.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 ...
586
21,862
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_chain.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 ...
335
14,904
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_encoder_decoder_init.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 ...
373
16,461
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_decoder.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 ...
466
21,428
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/convert_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 ...
732
25,880
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_inputs.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 ...
381
15,661
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/benchmark_all.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 ...
527
18,842
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_encoder.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 ...
166
6,208
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/whisper_jump_times.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 ...
480
19,560
onnxruntime
onnxruntime/python/tools/layering/layer_annotate.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import argparse import logging import pathlib import onnx def get_logger(name, level=logging.DEBUG): logging.basicConfig(format="%(asctime)s %(name)s [%(levelname)s] - %(message)s") logger = logging.getLogger(name)...
166
5,571
onnxruntime
onnxruntime/python/tools/profile_explorer/profile_explorer.py
.py
#!/usr/bin/python import argparse import fnmatch import json import subprocess as sp from collections import defaultdict import pandas as pd def _demangle(name, demangler="c++filt"): try: with sp.Popen([demangler, name], stdin=sp.PIPE, stdout=sp.PIPE) as proc: out, _ = proc.communicate() ...
330
11,595
onnxruntime
onnxruntime/python/datasets/__init__.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ Short examples used in the documentation. """ import os def get_example(name): """ Retrieves the absolute file name of an example. """ this = os.path.abspath(os.path.dirname(__file__)) full = os.path...
19
455
onnxruntime
onnxruntime/python/torch_cpp_extensions/setup.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os from setuptools import setup from torch.utils import cpp_exte...
20
668
onnxruntime
onnxruntime/python/torch_cpp_extensions/aten_op_executor/setup.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os from setuptools import setup from torch.utils import cpp_exte...
17
588
onnxruntime
onnxruntime/python/torch_cpp_extensions/aten_op_executor/__init__.py
.py
import threading from functools import wraps from onnxruntime.capi import _pybind_state as _C def run_once_aten_op_executor(f): """ Decorator to run a function only once. :param f: function to be run only once during execution time despite the number of calls :return: The original function with the p...
34
1,174
onnxruntime
onnxruntime/python/torch_cpp_extensions/ort_torch_ext/__init__.py
.py
import threading from functools import wraps import torch # noqa: F401 from onnxruntime.capi import _pybind_state as _C from .aten_op_executor import execute_aten_operator_address, is_tensor_argument_address def run_once_aten_op_executor(f): """ Decorator to run a function only once. :param f: functio...
38
1,213
onnxruntime
onnxruntime/python/backend/backend_rep.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Implements ONNX's backend API. """ from onnx.backend.base import Bac...
77
2,825
onnxruntime
onnxruntime/python/backend/backend.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Implements ONNX's backend API. """ import os import unittest import...
215
10,233
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/RuntimeOptimizationRecordContainerEntry.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class RuntimeOptimizationRecordContainerEntry(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n =...
92
3,741
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/OperatorSetId.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class OperatorSetId(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(fl...
68
2,032
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/StringStringEntry.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class StringStringEntry(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Ge...
68
2,080
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/DimensionValueType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs class DimensionValueType(object): UNKNOWN = 0 VALUE = 1 PARAM = 2
9
166
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/NodesToOptimizeIndices.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() # nodes to consider for a runtime optimization # see corresponding type in onnxruntime/core/graph/runtime_optimization_record.h class NodesToOptimiz...
161
5,984
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/KernelTypeStrResolver.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class KernelTypeStrResolver(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encod...
79
2,789
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/SequenceType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class SequenceType(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(fla...
59
1,771
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/DeprecatedNodeIndexAndKernelDefHash.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() # deprecated: no longer using kernel def hashes class DeprecatedNodeIndexAndKernelDefHash(object): __slots__ = ['_tab'] @classmethod de...
69
2,458
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/DimensionValue.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class DimensionValue(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(f...
81
2,494
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/RuntimeOptimizations.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class RuntimeOptimizations(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode...
80
2,721
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/NodeEdge.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class NodeEdge(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuf...
127
4,057
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/ArgType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs class ArgType(object): INPUT = 0 OUTPUT = 1
8
140
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/FloatProperty.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class FloatProperty(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(fl...
68
2,008
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Attribute.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Attribute(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbu...
338
10,850
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/DeprecatedKernelCreateInfos.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() # deprecated: no longer using kernel def hashes class DeprecatedKernelCreateInfos(object): __slots__ = ['_tab'] @classmethod def GetRoo...
121
4,528
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Model.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Model(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffer...
224
7,440
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/__init__.py
.py
from os.path import dirname, basename, isfile, join, splitext import glob modules = glob.glob(join(dirname(__file__), "*.py")) __all__ = [splitext(basename(f))[0] for f in modules if isfile(f) and not f.endswith('__init__.py')] from . import *
7
245
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/ValueInfo.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class ValueInfo(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbu...
85
2,571
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Graph.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Graph(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffer...
321
10,719
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/PropertyBag.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class PropertyBag(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flat...
153
4,947
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/TypeInfo.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class TypeInfo(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuf...
84
2,516
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Checkpoint.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Checkpoint(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatb...
126
4,217
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/DeprecatedSubGraphSessionState.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() # deprecated: no longer using kernel def hashes class DeprecatedSubGraphSessionState(object): __slots__ = ['_tab'] @classmethod def Get...
73
2,610
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/KernelTypeStrArgsEntry.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class KernelTypeStrArgsEntry(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.enco...
92
3,102
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/TensorTypeAndShape.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class TensorTypeAndShape(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.G...
72
2,255
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Shape.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Shape(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffer...
79
2,274
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/DeprecatedSessionState.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() # deprecated: no longer using kernel def hashes class DeprecatedSessionState(object): __slots__ = ['_tab'] @classmethod def GetRootAs(c...
97
3,582
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/AttributeType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs class AttributeType(object): UNDEFINED = 0 FLOAT = 1 INT = 2 STRING = 3 TENSOR = 4 GRAPH = 5 FLOATS = 6 INTS = 7 STRINGS = 8 TENSORS = 9 GRAPHS = 10 SPARSE_TENSOR = 11 SPARSE_TENSO...
19
328
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/TensorDataType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs class TensorDataType(object): UNDEFINED = 0 FLOAT = 1 UINT8 = 2 INT8 = 3 UINT16 = 4 INT16 = 5 INT32 = 6 INT64 = 7 STRING = 8 BOOL = 9 FLOAT16 = 10 DOUBLE = 11 UINT32 = 12 UINT6...
27
474
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/TypeInfoValue.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs class TypeInfoValue(object): NONE = 0 tensor_type = 1 sequence_type = 2 map_type = 3
10
189
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/EdgeEnd.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class EdgeEnd(object): __slots__ = ['_tab'] @classmethod def SizeOf(cls): return 12 # EdgeEnd def Init(self, buf, pos)...
33
1,105
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/RuntimeOptimizationRecord.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() # a single runtime optimization # see corresponding type in onnxruntime/core/graph/runtime_optimization_record.h class RuntimeOptimizationRecord(obj...
106
3,962
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/OpIdKernelTypeStrArgsEntry.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class OpIdKernelTypeStrArgsEntry(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers....
92
3,296
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/InferenceSession.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class InferenceSession(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get...
89
3,037
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/NodeType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs class NodeType(object): Primitive = 0 Fused = 1
8
144
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Dimension.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Dimension(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbu...
72
2,191
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/StringProperty.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class StringProperty(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(f...
68
2,043
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/ParameterOptimizerState.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class ParameterOptimizerState(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.enc...
92
3,127
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/SparseTensor.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class SparseTensor(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(fla...
115
3,692
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/ArgTypeAndIndex.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class ArgTypeAndIndex(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(...
68
2,026
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/MapType.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class MapType(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuff...
72
2,123
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/OptimizerGroup.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class OptimizerGroup(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(f...
118
4,018
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/IntProperty.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class IntProperty(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flat...
68
1,970
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Node.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Node(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffers...
318
10,401
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/ModuleState.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class ModuleState(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flat...
142
4,853
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Tensor.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Tensor(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffe...
204
6,599
onnxruntime
onnxruntime/core/flatbuffers/schema/compile_schema.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import argparse import pathlib import shutil import subprocess import tempfile SCRIPT_DIR = pathlib.Path(__file__).parent.resolve() def update_schema_names(schema_path: pathlib.Path, updated_schema_p...
150
6,249
onnxruntime
onnxruntime/core/mlas/lib/sve/gen_sve_asm.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """Freeze SVE intrinsics translation units into KleidiAI-style machine code. Compiles an SVE intrinsics reference TU with gcc, extracts the requested extern "C" functions from the object file, and emits...
205
7,665
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/dump_mlprogram_model.py
.py
import sys import coremltools as ct if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} <path to model.mlmodel in ML Package>") print("If generated by onnxruntime this will be <ML Package root>/Data/com.microsoft.onnxruntime/model.mlmodel") print( "The ML Package created by the CoreML EP can saved ...
35
1,205
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/resize_test.py
.py
import coremltools as ct import numpy as np from coremltools.converters.mil import Builder as mb target = ct.target.iOS15 x_shape = (1, 1, 3, 6) use_scale = False # set this to test upsample vs resize @mb.program(input_specs=[mb.TensorSpec(shape=x_shape)], opset_version=target) def prog(x): global use_scale ...
52
1,268
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/div_test.py
.py
import coremltools as ct import numpy as np from coremltools.converters.mil import Builder as mb from coremltools.models import datatypes from coremltools.models.neural_network import NeuralNetworkBuilder from coremltools.models.utils import save_spec input_dim = (1,) output_dim = (1,) def mlprogram(): target = ...
104
2,868
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/convtranspose_test.py
.py
import coremltools as ct import numpy as np from coremltools.converters.mil import Builder as mb target = ct.target.iOS15 x_shape = (1, 3, 4, 4) w_shape = (3, 3, 3, 3) @mb.program(input_specs=[mb.TensorSpec(shape=x_shape)], opset_version=target) def prog(x): weight = mb.const(name="weight", val=np.ones(w_shape,...
43
1,364
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/gridsample_test.py
.py
import coremltools as ct import numpy as np from coremltools.converters.mil import Builder as mb target = ct.target.iOS15 x_shape = (2, 2, 3, 2) grid_shape = (2, 3, 2, 2) @mb.program(input_specs=[mb.TensorSpec(shape=x_shape), mb.TensorSpec(shape=grid_shape)], opset_version=target) def prog(x, grid): sampling = ...
115
2,850
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/concat_test.py
.py
import coremltools as ct import numpy as np from coremltools.converters.mil import Builder as mb target = ct.target.iOS15 a_shape = (1, 1, 3, 3) @mb.program( input_specs=[mb.TensorSpec(shape=a_shape), mb.TensorSpec(shape=a_shape), mb.TensorSpec(shape=a_shape)], opset_version=target, ) def prog(x, y, z): ...
34
767
onnxruntime
onnxruntime/core/providers/coreml/mlprogram_test_scripts/depthtospace_test.py
.py
import coremltools as ct import numpy as np from coremltools.converters.mil import Builder as mb target = ct.target.iOS15 # replicate example from https://github.com/onnx/onnx/blob/main/docs/Operators.md#depthtospace # to prove CoreML mode is DCR x_shape = (1, 8, 2, 3) @mb.program(input_specs=[mb.TensorSpec(shape=x...
52
1,508
onnxruntime
onnxruntime/core/providers/vsinpu/patches/test_scripts/compare_cosine_sim.py
.py
import sys import numpy as np from numpy.linalg import norm def read_values(filename): with open(filename) as file: values = np.array([float(line.strip()) for line in file]) return values def cosine_similarity(vec1, vec2): return np.dot(vec1, vec2) / (norm(vec1) * norm(vec2)) if __name__ == "...
30
650
onnxruntime
onnxruntime/core/providers/vsinpu/patches/test_scripts/compare_topn.py
.py
import sys def read_values(filename): with open(filename) as file: values = [(float(line.strip()), i + 1) for i, line in enumerate(file)] return values def top_n(values, N): return sorted(values, key=lambda x: x[0], reverse=True)[:N] def compare_files(cpu_file, npu_file, N): cpu_values = r...
35
835
onnxruntime
onnxruntime/test/run_benchmark.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from __future__ import annotations import argparse import dataclasses import json import pathlib import subprocess import sys import tempfile def warn(message: str): print(f"WARNING: {message}",...
202
5,708
onnxruntime
onnxruntime/test/platform/apple/generate_ipa_export_options_plist.py
.py
import argparse plist_file_content = """ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>method</key> <string>development</string> <key>teamID</key> <string>{team_id}</string>...
55
1,778
onnxruntime
onnxruntime/test/contrib_ops/multihead_attention_op_test_data_gen.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Running this script in Linux like the following # CUBLAS_WORKSPACE_CO...
565
19,050
onnxruntime
onnxruntime/test/contrib_ops/attention_lstm_data_gen.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import tensorflow as tf batchSize = 2 # noqa: N816 memMaxStep = 3 # noqa: N816 memDepth = 3 # noqa: N816 queryMaxStep = 4 # noqa: N816 queryDepth = 3 # noqa: N816 am_attn_size: int = 2 cell_hidden_size = 3 aw_attn_size...
425
11,825
onnxruntime
onnxruntime/test/autoep/tools/print_onnx_metadata.py
.py
#!/usr/bin/env python3 import argparse import json from pathlib import Path from typing import Any import onnx def model_metadata_to_dict(model: onnx.ModelProto) -> dict[str, Any]: custom_metadata = {entry.key: entry.value for entry in model.metadata_props} graph = model.graph info = { "ir_vers...
56
1,640