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 | orttraining/orttraining/test/python/orttraining_test_ortmodule_poc.py | .py | import argparse
import logging
import time
import torch
from torchvision import datasets, transforms
import onnxruntime
from onnxruntime.training.ortmodule import DebugOptions, ORTModule
class NeuralNet(torch.nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
super().__init__()
... | 237 | 8,888 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_autograd.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=missing-docstring
# pylint: disable=C0103
# pylint: disable=W0212
import copy
import os
import onnx
import pytest
import torch
from _test_helpers import (
assert_gradients_match_and_reset_gradient,
... | 1,858 | 66,611 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_cache.py | .py | import os
import tempfile
import unittest.mock
import torch
from onnxruntime.training.ortmodule import DebugOptions, LogLevel, ORTModule
torch.distributed.init_process_group(backend="nccl")
class Net(torch.nn.Module):
def __init__(self):
super().__init__()
self.fc = torch.nn.Linear(10, 1)
... | 47 | 1,412 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_bert_classifier.py | .py | import argparse
import datetime
import logging
import os
import random
import time
import zipfile
import numpy as np
import pandas as pd
import torch
import wget
from sklearn.model_selection import train_test_split
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
from transforme... | 470 | 18,581 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_api.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# orttraining_test_ortmodule_api.py
import copy
import inspect
import itertools
import math
import os
import pickle
import random
import tempfile
import time
import unittest.mock
import warnings
from collections import Ordere... | 7,010 | 267,630 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_dort.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import torch
import torch._dynamo
from torch import nn
from torch.nn import functional as F
from torch.onnx import ExportOptions
from torch.onnx import _OrtBackend as OrtBackend
from torch.onnx import _OrtBac... | 383 | 15,414 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_fairscale_sharded_optimizer.py | .py | import argparse
import os
import time
import numpy as np
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
import torchvision
from fairscale.nn.data_parallel import ShardedDataParallel as ShardedDDP
from fairscale.optim.oss import OSS
from torch.nn.parallel import DistributedDataParallel... | 277 | 10,519 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ort_apis_onnxblock.py | .py | import copy
import io
import os
import random
import tempfile
import numpy as np
import onnx
import pytest
import torch
import onnxruntime
import onnxruntime.training.onnxblock as onnxblock
from onnxruntime.capi import _pybind_state as C
from onnxruntime.training import artifacts
# PyTorch Module definitions
def g... | 1,247 | 46,331 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_deepspeed_zero_stage_1.py | .py | """Test for a simple ORTModule using the high-level DeepSpeed API.
To run on the local GPU(s):
```
$ pip install deepspeed
$ deepspeed orttraining_test_ortmodule_deepspeed_zero_stage_1.py \
--deepspeed_config=orttraining_test_ortmodule_deepspeed_zero_stage_1_config.json
```
"""
import argparse
import time
impor... | 261 | 9,694 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_fused_adam_cpu_fallback.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Unit tests for FusedAdam CPU fallback (issue #17403).
These tests patch torch.cuda.is_available to return False so they run
deterministically on both CPU-only and CUDA machines.
Import strategy:
* Load ``_multi_tensor_a... | 212 | 9,501 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortvalue.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=W0212,C0114,C0116
import copy
import sys
import unittest
import _test_helpers
import numpy as np
import torch
from numpy.testing import assert_almost_equal
from torch._C import _from_... | 397 | 16,517 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_lstm.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import tempfile
import numpy as np
import onnx
import pytest
from onnx import TensorProto, helper
import onnxruntime as ort
def sigmoid(z):
"""Computes the sigmoid of the given numpy array."""
return 1 /... | 938 | 41,743 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_experimental_json_config.py | .py | import os
import torch
from onnxruntime.capi import _pybind_state as C
from onnxruntime.training import ortmodule
from onnxruntime.training.ortmodule.experimental.json_config import load_from_json
class Net(torch.nn.Module):
def __init__(self, input_size=784, hidden_size=500, num_classes=10):
super().__... | 134 | 5,368 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_bert_classifier_autocast.py | .py | import argparse
import datetime
import logging
import os
import random
import time
import zipfile
import numpy as np
import pandas as pd
import torch
import wget
from sklearn.model_selection import train_test_split
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
from transforme... | 482 | 19,274 |
onnxruntime | orttraining/orttraining/test/python/test_train_script.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import importlib.util
import shlex
from pathlib import Path
from unittest.mock import patch
def load_train_module():
train_script = Path(__file__).resolve().parents[4] / "orttraining/tools/scripts/train.py"
spec = i... | 41 | 1,384 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_triton.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import copy
import json
import os
import random
import uuid
import _test_helpers
import onnx
import pytest
import torch
from onnx import TensorProto, helper
from torch._C import _from_dlpack
from torch.utils.dlpack import to... | 907 | 36,554 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_model_transform.py | .py | from onnx import numpy_helper
def add_name(model):
for i, node in enumerate(model.graph.node):
node.name = f"{node.op_type}_{i}"
def find_single_output_node(model, arg):
result = []
for node in model.graph.node:
for input in node.input:
if input == arg:
result... | 113 | 3,857 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_deepspeed_pipeline_parallel.py | .py | import argparse
import deepspeed
import torch
from deepspeed.pipe import PipelineModule
from torch import nn
from onnxruntime.training.ortmodule import ORTModule
# USAGE:
# pip install deepspeed
# deepspeed orttraining_test_ortmodule_deepspeed_pipeline_parallel.py --deepspeed_config=orttraining_test_ortmodule_deepsp... | 121 | 3,879 |
onnxruntime | orttraining/orttraining/test/python/orttraining_ortmodule_tests.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import os
import sys
from _test_commons import run_subprocess
logging.basicConfig(format="%(asctime)s %(name)s [%(levelname)s] - %(message)s", level=logging.DEBUG)
log =... | 220 | 7,217 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_utilities.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from collections import abc
import pytest
import torch
from onnxruntime.training.utils import extract_data_and_schema, unflatten_data_using_schema
from onnxruntime.training.utils.torch_io_helper import _TensorStub
@pytest... | 292 | 11,260 |
onnxruntime | orttraining/orttraining/test/python/_test_helpers.py | .py | import copy
import os
import torch
from numpy.testing import assert_allclose
from onnxruntime.training.ortmodule import ORTModule
from onnxruntime.training.ortmodule._graph_execution_manager_factory import GraphExecutionManagerFactory # noqa: F401
def is_all_or_nothing_fallback_enabled(model, policy=None):
fro... | 337 | 11,412 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ort_pipeline_module.py | .py | import argparse
import deepspeed
import torch
from deepspeed.pipe import LayerSpec
from torch import nn, utils
from onnxruntime.training.ortmodule.experimental.pipe import ORTPipelineModule
# This script demonstrates how to set up a pipeline parallel training session
# using DeepSpeed's ORTPipelineModule for a simpl... | 135 | 4,645 |
onnxruntime | orttraining/orttraining/test/python/_orttraining_ortmodule_models.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# orttraining_test_ortmodule_api.py
import torch
class MyCustomClassInputNet(torch.nn.Module):
def forward(self, x, custom_class_obj):
if custom_class_obj.x == 1:
return x + 1
return x
clas... | 57 | 1,842 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_sampler.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# orttraining_test_sampler.py
import random
import torch
from onnxruntime.training.utils.data import sampler
class MyDataset(torch.utils.data.Dataset):
def __init__(self, samples):
self.samples = samples
... | 161 | 6,195 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_torch_lightning_basic.py | .py | import argparse
from multiprocessing import cpu_count
import pytorch_lightning as pl
import torch
import torch.nn.functional as F
from torch import nn
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.datasets import MNIST
import onnxruntime
from onnxruntime.training.ortmodul... | 102 | 3,519 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_experimental_gradient_graph.py | .py | import os
import unittest
from pathlib import Path
import numpy as np
import onnx
import torch
import onnxruntime
from onnxruntime.training.experimental import export_gradient_graph
class NeuralNet(torch.nn.Module):
r"""
Simple example model.
"""
def __init__(self, input_size: int, embedding_size: ... | 116 | 4,324 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_pytorch_ddp.py | .py | # This test script is a modified version of Pytorch's tutorial.
# For details, see https://pytorch.org/tutorials/intermediate/ddp_tutorial.html.
import argparse
import inspect
import logging
import os
import sys # noqa: F401
import tempfile
import torch
import torch.distributed as dist
import torch.multiprocessing as... | 280 | 9,021 |
onnxruntime | orttraining/orttraining/test/python/_test_commons.py | .py | import os
import subprocess
import sys
def is_windows():
return sys.platform.startswith("win")
def run_subprocess(args, cwd=None, capture=False, dll_path=None, shell=False, env={}, log=None): # noqa: B006
if log:
log.info(f"Running subprocess in '{cwd or os.getcwd()}'\n{args}")
my_env = os.envi... | 30 | 999 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_hooks.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import tempfile
import pytest
import torch
from onnxruntime.training.ortmodule import ORTModule
from onnxruntime.training.utils.hooks import GlobalSubscriberManager, StatisticsSubscriber, inspect_activation
clas... | 203 | 7,307 |
onnxruntime | orttraining/orttraining/test/python/launch_test.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import os # noqa: F401
import sys
from _test_commons import run_subprocess
logging.basicConfig(format="%(asctime)s %(name)s [%(levelname)s] - %(message)s", level=loggin... | 40 | 1,255 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/utils.py | .py | import logging
import os
def makedir(dir_path):
"""Creates a directory if one does not already exist"""
if not os.path.exists(dir_path):
logging.info(f"Creating directory: {dir_path}")
os.makedirs(dir_path, exist_ok=True)
else:
logging.info(f"Directory already exists: {dir_path}. W... | 12 | 370 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/train.py | .py | import logging
import numpy as np
import torch
from torchvision import datasets, transforms
import onnxruntime.training.api as orttraining
def _get_dataloaders(data_dir, batch_size):
"""Preprocesses the data and returns dataloaders."""
transform = transforms.Compose([transforms.ToTensor(), transforms.Norma... | 76 | 2,522 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/model.py | .py | import io
import logging
import os
import onnx
import torch
from onnxruntime.training import artifacts
class MNIST(torch.nn.Module):
"""MNIST PyTorch model"""
def __init__(self, input_size, hidden_size, num_classes):
super().__init__()
self.fc1 = torch.nn.Linear(input_size, hidden_size)
... | 122 | 4,135 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/quantize.py | .py | import logging
import numpy as np
import torch
from torchvision import datasets, transforms
import onnxruntime.quantization as quantization
def preprocess(input_model_dir, output_model_dir):
"""Preprocesses the given onnx model for quantization. Unused for QAT process."""
quantization.shape_inference.quant_... | 63 | 2,232 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/qat.py | .py | import logging
import os
import onnx
import quantize
import utils
from model import create_training_artifacts, get_models
from train import train_model
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(filename)s:%(lineno)s:%(funcName)s::%(message)s",
)
if __name__ == "__main__":
logging.i... | 62 | 2,033 |
onnxruntime | orttraining/orttraining/test/python/perf_log/ort_module_perf_test_tools.py | .py | # https://docs.microsoft.com/en-us/azure/mysql/connect-python
import argparse
import os
from datetime import datetime
import git
import mysql.connector
from mysql.connector import errorcode
def get_repo_commit(repo_path):
repo = git.Repo(repo_path, search_parent_directories=True)
sha = repo.head.object.hexs... | 222 | 7,647 |
onnxruntime | orttraining/orttraining/test/external_custom_ops/setup.py | .py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import subprocess
import sys
from subprocess import CalledProcessError # noqa: F401
import onnx
import pybind11
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
import onnxruntime
class CMak... | 56 | 1,795 |
onnxruntime | orttraining/orttraining/test/external_custom_ops/test.py | .py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os # noqa: F401
import sys # noqa: F401
import numpy as np
# Restore dlopen flags.
import orttraining_external_custom_ops # noqa: F401
# Expose available (onnx::* and protobuf::*) symbols from onnxruntime to resolve references in
# t... | 22 | 696 |
onnxruntime | orttraining/orttraining/test/external_custom_ops/testdata/gen_model.py | .py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import onnx
from onnx import helper
graph = helper.make_graph(
[helper.make_node("Foo", ["input1"], ["output1"], "", "", "com.examples")],
"external_custom_op_example_model",
[helper.make_tensor_value_info("input1", helper.TensorProt... | 20 | 608 |
onnxruntime | cmake/maccatalyst_prepare_objects_for_prelink.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import shutil
import sys
# Note: This script is mainly used for sanity checking/validating the files in the .a library equal to the .o files
# in the source dir to handle the case of source ... | 73 | 2,958 |
onnxruntime | docs/python/conf.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=C0103
"""Configuration file for the Sphinx documentation builder."""
import os
import shutil
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "_common"))
# import recommonmark
# -... | 142 | 4,616 |
onnxruntime | docs/python/_common/onnx_sphinx.py | .py | # pylint: disable=C0103,C0415,R0912,R0913,R0914,R0915
"""
Automates the generation of ONNX operators.
"""
import importlib
import inspect
import keyword
import os
import re
import sys
import textwrap
from difflib import Differ
import numpy as np
import onnx
from onnx.backend.test.case.base import _Exporter
from onnx.... | 900 | 29,135 |
onnxruntime | docs/python/examples/plot_backend.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
.. _l-example-backend-api:
ONNX Runtime Backend for ONNX
=============================
*ONNX Runtime* extends the
`onnx backend API <https://github.com/onnx/onnx/blob/main/docs/ImplementingAnOnnxBackend.md>`_
to run pr... | 60 | 1,605 |
onnxruntime | docs/python/examples/plot_profiling.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
.. _l-example-profiling:
Profile the execution of a simple model
=======================================
*ONNX Runtime* can profile the execution of the model.
This example shows how to interpret the results.
"""
impo... | 70 | 1,900 |
onnxruntime | docs/python/examples/plot_convert_pipeline_vectorizer.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Train, convert and predict with ONNX Runtime
============================================
This example demonstrates an end to end scenario
starting with the training of a scikit-learn pipeline
which takes as inputs not a... | 99 | 3,477 |
onnxruntime | docs/python/examples/plot_common_errors.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
.. _l-example-common-error:
Common errors with onnxruntime
==============================
This example looks into several common situations
in which *onnxruntime* does not return the model
prediction but raises an excep... | 120 | 4,036 |
onnxruntime | docs/python/examples/plot_metadata.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Metadata
========
ONNX format contains metadata related to how the
model was produced. It is useful when the model
is deployed to production to keep track of which
instance was used at a specific time.
Let's see how to d... | 47 | 1,329 |
onnxruntime | docs/python/examples/plot_train_convert_predict.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=C0411,C0412,C0413
"""
.. _l-logreg-example-speed:
Train, convert and predict with ONNX Runtime
============================================
This example demonstrates an end to end scenario
starting with t... | 235 | 6,947 |
onnxruntime | docs/python/examples/plot_pipeline.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Draw a pipeline
===============
There is no other way to look into one model stored
in ONNX format than looking into its node with
*onnx*. This example demonstrates
how to draw a model and to retrieve it in *json*
format... | 68 | 1,646 |
onnxruntime | docs/python/examples/plot_load_and_predict.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
.. _l-example-simple-usage:
Load and predict with ONNX Runtime and a very simple model
==========================================================
This example demonstrates how to load a model and compute
the output for ... | 56 | 1,662 |
onnxruntime | plugin-ep-cuda/_packaging_utils.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Shared utilities for the CUDA plugin EP packaging scripts. Not a public API."""
from __future__ import annotations
import re
from pathlib import Path
# Matches "@var@" template variables.
_TEMPLATE_VARIABLE_PATTERN = re... | 46 | 1,722 |
onnxruntime | plugin-ep-cuda/python/build_wheel.py | .py | #!/usr/bin/env python3
"""Build a wheel for the onnxruntime-ep-cuda12 or onnxruntime-ep-cuda13 package."""
import argparse
import platform
import re
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
SCRIPT_DIR = Path(__file__).parent
MIN_ONNXRUNTIME_VERSION_FILE = SCRIPT_DIR.parent /... | 160 | 5,769 |
onnxruntime | plugin-ep-cuda/python/setup.py | .py | """Minimal setup.py to produce a platform-specific wheel."""
from setuptools import setup
from setuptools.dist import Distribution
from wheel.bdist_wheel import bdist_wheel
class PlatformBdistWheel(bdist_wheel):
"""Override wheel tags to py3-none-{platform}."""
def get_tag(self):
_, _, plat = super(... | 22 | 544 |
onnxruntime | plugin-ep-cuda/python/onnxruntime_ep_cuda/__init__.py | .py | """ONNX Runtime CUDA Plugin Execution Provider Python package."""
from __future__ import annotations
import pathlib
__all__ = [
"get_ep_name",
"get_ep_names",
"get_library_path",
]
_module_dir = pathlib.Path(__file__).parent
def get_library_path() -> str:
"""Return the path to the CUDA plugin EP s... | 39 | 1,008 |
onnxruntime | plugin-ep-cuda/python/test/test_cuda_plugin_ep.py | .py | #!/usr/bin/env python3
"""Smoke test for the onnxruntime-ep-cuda Python package.
Tests:
1. Package import and library path resolution
2. EP registration with ONNX Runtime
3. Device discovery
4. Inference with a simple Mul model (requires CUDA-capable hardware)
The inference test is skipped gracefully if no CUDA devic... | 184 | 6,961 |
onnxruntime | plugin-ep-cuda/csharp/pack_nuget.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Build the Microsoft.ML.OnnxRuntime.EP.Cuda NuGet package.
Stages native binaries from build artifacts into the runtimes/ layout expected
by the .csproj and runs `dotnet pack` to produce the .nupkg / ... | 371 | 13,927 |
onnxruntime | plugin-ep-cuda/csharp/test/CudaEpNuGetTest/generate_mul_model.py | .py | """Generate a simple Mul ONNX model for testing.
Produces mul.onnx in the same directory as this script.
The model computes z = x * y (element-wise) for float32 tensors of shape [2, 3].
"""
import os
from onnx import TensorProto, checker, helper, save
X = helper.make_tensor_value_info("x", TensorProto.FLOAT, [2, 3]... | 26 | 849 |
onnxruntime | objectivec/test/testdata/single_add_gen.py | .py | import onnx
from onnx import TensorProto, helper
graph = helper.make_graph(
[ # nodes
helper.make_node("Add", ["A", "B"], ["C"], "Add"),
],
"SingleAdd", # name
[ # inputs
helper.make_tensor_value_info("A", TensorProto.FLOAT, [1]),
helper.make_tensor_value_info("B", TensorProt... | 20 | 552 |
onnxruntime | plugin-ep-webgpu/_packaging_utils.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Shared utilities for the WebGPU plugin EP packaging scripts. Not a public API."""
from __future__ import annotations
import re
from pathlib import Path
# Matches "@var@" template variables.
_TEMPLATE_VARIABLE_PATTERN = ... | 46 | 1,724 |
onnxruntime | plugin-ep-webgpu/python/build_wheel.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Build a wheel for the onnxruntime-ep-webgpu package.
Combines pre-built plugin EP binaries with the Python package source to produce
a platform-specific wheel.
Usage:
python build_wheel.py --b... | 187 | 6,624 |
onnxruntime | plugin-ep-webgpu/python/setup.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Minimal setup.py to produce a platform-specific wheel.
The package contains pre-built native libraries (not CPython extension modules),
so the wheel tag should be py3-none-{platform} rather than cp3XX-cp3XX-{platform}.
Th... | 30 | 888 |
onnxruntime | plugin-ep-webgpu/python/onnxruntime_ep_webgpu/__init__.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""ONNX Runtime WebGPU Plugin Execution Provider Python Package.
Provides helper functions to locate the plugin EP shared library and
retrieve the EP name for registration with ONNX Runtime.
"""
from __future__ import annot... | 47 | 1,301 |
onnxruntime | plugin-ep-webgpu/python/test/test_webgpu_plugin_ep.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Smoke test for the onnxruntime-ep-webgpu Python package.
Tests:
1. Package import and library path resolution
2. EP registration with ONNX Runtime
3. Device discovery
4. Inference with a simple Mul... | 200 | 7,351 |
onnxruntime | plugin-ep-webgpu/csharp/pack_nuget.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Build the Microsoft.ML.OnnxRuntime.EP.WebGpu NuGet package.
Stages native binaries from build artifacts into the runtimes/ layout expected
by the .csproj and runs `dotnet pack` to produce the .nupk... | 378 | 13,968 |
onnxruntime | plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/generate_mul_model.py | .py | """Generate a simple Mul ONNX model for testing.
Produces mul.onnx in the same directory as this script.
The model computes z = x * y (element-wise) for float32 tensors of shape [2, 3].
"""
import os
from onnx import TensorProto, checker, helper, save
X = helper.make_tensor_value_info("x", TensorProto.FLOAT, [2, 3]... | 26 | 851 |
onnxruntime | csharp/tools/ValidateNativeDelegateAttributes.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import pathlib
def check_all_delegates_have_unmanaged_function_pointer_attribute(file: pathlib.Path):
"""
Check that all 'public delegate' declarations have a matching Unmanage... | 63 | 2,336 |
onnxruntime | csharp/tools/MauiModelTester/create_test_data.py | .py | import argparse
import shutil
import sys
from pathlib import Path
import numpy as np
# set to the directory the ONNX Runtime repo is in
# `git checkout https://github.com/microsoft/onnxruntime.git` if needed.
ORT_ROOT_DIR = Path(__file__).parents[3]
SOLUTION_DIR = Path(__file__).parent
# add path for test data/dir g... | 159 | 5,034 |
onnxruntime | csharp/testdata/test_input_FLOAT16.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import onnx
from onnx import TensorProto, helper
from onnx.helper import make_opsetid
input_info = helper.make_tensor_value_info("input", TensorProto.FLOAT16, [1, 5])
output_info = helper.make_tensor_value_info("output", Ten... | 30 | 1,025 |
onnxruntime | csharp/testdata/test_input_BFLOAT16.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import onnx
from onnx import TensorProto, helper
from onnx.helper import make_opsetid
input_info = helper.make_tensor_value_info("input", TensorProto.BFLOAT16, [1, 5])
output_info = helper.make_tensor_value_info("output", Te... | 23 | 950 |
onnxruntime | cgmanifests/print_submodule_info.py | .py | #!/usr/bin/env python3
# args: <submodule path>
# output: <path> <url> <commit>
import subprocess
import sys
assert len(sys.argv) == 2
path = sys.argv[1]
proc = subprocess.run(
["git", "config", "--get", "remote.origin.url"],
check=True,
cwd=path,
stdout=subprocess.PIPE,
text=True,
)
url = pro... | 28 | 510 |
onnxruntime | cgmanifests/webgpu/validate_webgpu_cgmanifest.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Validate WebGPU Component Governance manifest drift."""
from __future__ import annotations
import json
import re
import sys
from pathlib import Path
from typing import Any
REPO_ROOT = Path(__file... | 166 | 6,244 |
openvino | setup.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os.path
import sys
import errno
import subprocess # nosec
import platform
import re
import shutil
import multiprocessing
import logging as log
from fnmatch import fnmatchcase
from pathlib import Path
from ... | 839 | 34,321 |
openvino | samples/python/model_creation_sample/model_creation_sample.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
from functools import reduce
import numpy as np
import openvino as ov
from openvino import op, opset1, opset8
from data import digits
def create_model(mod... | 210 | 9,116 |
openvino | samples/python/model_creation_sample/data.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy
digits = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,... | 421 | 37,387 |
openvino | samples/python/hello_query_device/hello_query_device.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
import openvino as ov
def param_to_string(parameters) -> str:
"""Convert a list / tuple of parameters returned from OV to a string."""
if isinstanc... | 45 | 1,581 |
openvino | samples/python/benchmark/sync_benchmark/sync_benchmark.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import statistics
import sys
from time import perf_counter
import numpy as np
import openvino as ov
from openvino.utils.types import get_dtype
def fill_tensor_random... | 82 | 3,108 |
openvino | samples/python/benchmark/bert_benchmark/bert_benchmark.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
from pathlib import Path
import sys
import tempfile
from time import perf_counter
import openvino as ov
import datasets
from transformers import AutoTokenizer
from tra... | 79 | 3,028 |
openvino | samples/python/benchmark/throughput_benchmark/throughput_benchmark.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
import statistics
from time import perf_counter
import numpy as np
import openvino as ov
from openvino.utils.types import get_dtype
def fill_tensor_random... | 89 | 3,420 |
openvino | samples/python/hello_classification/hello_classification.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
import cv2
import numpy as np
import openvino as ov
def main():
log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.INFO, stream=sys.std... | 114 | 4,208 |
openvino | samples/python/hello_reshape_ssd/hello_reshape_ssd.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import os
import sys
import cv2
import numpy as np
import openvino as ov
def main():
log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.INFO, stre... | 120 | 4,468 |
openvino | samples/python/classification_sample_async/classification_sample_async.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging as log
import sys
import cv2
import numpy as np
import openvino as ov
def parse_args() -> argparse.Namespace:
"""Parse and return command line arguments... | 132 | 5,211 |
openvino | tools/benchmark_tool/openvino/tools/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
| 5 | 148 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/main.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import platform
from datetime import datetime
from openvino import Dimension, properties
from openvino.tools.benchmark.benchmark import Benchmark
from openvino.tools.benchmark.parameters import parse_args
from open... | 778 | 42,226 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/parameters.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import sys, argparse
from openvino.tools.benchmark.utils.utils import show_available_devices
INPUT_OUTPUT_PRECISION_CHOICES = [
'bool', \
'f16', 'f32', 'f64', \
'i8', 'i16', 'i32', 'i64', \
'u8', 'u16', 'u32', 'u64']
d... | 210 | 17,070 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/benchmark.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import time
from math import ceil
from openvino import Core, get_version, AsyncInferQueue
from .utils.constants import GPU_DEVICE_NAME, XML_EXTENSION, BIN_EXTENSION
from .utils.logging import logger
from .utils.utils import ge... | 211 | 8,797 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/logging.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
import sys
logging.basicConfig(format="[ %(levelname)s ] %(message)s", level=logging.INFO, stream=sys.stdout)
logger = logging.getLogger('BenchmarkApp')
| 9 | 252 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from collections import defaultdict
from datetime import timedelta
import enum
from openvino import Core, Model, PartialShape, Dimension, Layout, Type, serialize, properties, OVAny
from openvino.preprocess import PrePostProcessor
from .... | 835 | 33,649 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/statistics_report.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import abc
import json
import csv
import numpy as np
from enum import Enum
from datetime import timedelta
from typing import Any
from .logging import logger
## statistics reports types
noCntReport = 'no_counters'
averageCntRep... | 297 | 13,001 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import re
import numpy as np
from collections import defaultdict
from pathlib import Path
from importlib.util import find_spec
from openvino import Tensor, PartialShape, Type
from openvino.utils.types import get_dty... | 504 | 23,482 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/constants.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
NPU_DEVICE_NAME = 'NPU'
CPU_DEVICE_NAME = 'CPU'
GPU_DEVICE_NAME = 'GPU'
HETERO_DEVICE_NAME = 'HETERO'
MULTI_DEVICE_NAME = 'MULTI'
AUTO_DEVICE_NAME = 'AUTO'
UNKNOWN_DEVICE_TYPE = 'UNKNOWN'
XML_EXTENSION = '.xml'
BIN_EXTENSION = '.bin'
BL... | 27 | 689 |
openvino | tools/ovc/unit_tests/ovc/main_test_error_log.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
from unittest.mock import patch
from openvino.tools.ovc.error import FrameworkError
def mocked_parse_args(*argv):
# Mock parse_args method which generates warning
import logging as log
log.error("warning", ... | 31 | 928 |
openvino | tools/ovc/unit_tests/ovc/unit_test_with_mocked_telemetry.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import unittest
from unittest.mock import Mock
try:
import openvino_telemetry as tm
from openvino_telemetry.backend import backend_ga4
except ImportError:
import openvino.tools.ovc.telemetry_stub as tm
class UnitTestWithMo... | 21 | 603 |
openvino | tools/ovc/unit_tests/ovc/convert/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
def create_onnx_model():
#
# Create ONNX model
#
import onnx
from onnx import helper
from onnx import TensorProto
shape = [1, 3, 2, 2]
input = helper.make_tensor_value_info('input', Tensor... | 53 | 1,292 |
openvino | tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import tempfile
import unittest
from pathlib import Path
from openvino import get_version as get_rt_version
from openvino import serialize, convert_model
from openvino.tools.mo.utils.ir_reader.restore_graph import restore_grap... | 87 | 3,625 |
openvino | tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import tempfile
from openvino import serialize
from pathlib import Path
from unit_tests.ovc.convert.utils import create_onnx_model, save_to_onnx
from unit_tests.ovc.unit_test_with_mocked_telemetry import UnitTestWithMockedTelem... | 90 | 3,077 |
openvino | tools/ovc/unit_tests/ovc/convert/meta_data_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import tempfile
from openvino import get_version as get_rt_version
from openvino import serialize
from openvino.tools.ovc import convert_model
from pathlib import Path
from unit_tests.ovc.unit_test_with_mocked_telemetry import ... | 88 | 3,091 |
openvino | tools/ovc/unit_tests/ovc/utils/error_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import unittest
from openvino.tools.ovc.error import classify_error_type
class TestingErrorClassifier(unittest.TestCase):
def test_no_module(self):
message = "No module named 'openvino._offline_transformations.offline_tran... | 25 | 977 |
openvino | tools/ovc/unit_tests/ovc/utils/cli_parser_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import shutil
import tempfile
import unittest
import openvino as ov
from openvino import PartialShape
from openvino.tools.ovc.cli_parser import _InputCutInfo
from openvino.tools.ovc.cli_parser import input_to_... | 582 | 26,512 |
openvino | tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import os
import pytest
from openvino import Core
from openvino.tools.ovc.convert import convert_model
class TestMoFreezePlaceholderTFFE():
def basic(self, input_model, argv_input, inputs, dtype, expected, only_c... | 145 | 6,037 |
openvino | tools/ovc/unit_tests/moc_tf_fe/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import numpy as np
from openvino import Core
from openvino.tools.ovc.convert import convert_model
def basic_check(input_model, argv_input, input_data, expected_dtype, expected_value, \
only_conversion=False, input_model... | 37 | 1,277 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.