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/fusion_bart_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import numpy as np from fusion_attention import Attentio...
507
23,420
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_gpt2.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import onnx from fusion_gpt_attention import FusionGptAt...
102
3,812
onnxruntime
onnxruntime/python/tools/transformers/fusion_group_norm.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
181
7,465
onnxruntime
onnxruntime/python/tools/transformers/fusion_conformer_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from fusion_attention import AttentionMask, FusionAttent...
298
11,705
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_t5.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import numpy as np from fusion_attention import Attentio...
986
37,071
onnxruntime
onnxruntime/python/tools/transformers/huggingface_models.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # Maps ...
75
3,931
onnxruntime
onnxruntime/python/tools/transformers/constants.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- class Operators: ATTENTION = "Attention" LAYERNORM = "LayerNor...
48
1,080
onnxruntime
onnxruntime/python/tools/transformers/fusion_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
1,199
50,927
onnxruntime
onnxruntime/python/tools/transformers/fusion_mha_mmdit.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
668
25,149
onnxruntime
onnxruntime/python/tools/transformers/fusion_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy from numpy import array_equa...
322
13,003
onnxruntime
onnxruntime/python/tools/transformers/fusion_rotary_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import numpy as np from fusion_attention import FusionAt...
1,789
77,850
onnxruntime
onnxruntime/python/tools/transformers/fusion_attention_sam2.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
534
20,774
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_conformer.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from fusion_attention import AttentionMask from fusion_c...
33
1,380
onnxruntime
onnxruntime/python/tools/transformers/bert_perf_test.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # This tool measures the inference performance of onnxruntime on BERT-l...
630
20,163
onnxruntime
onnxruntime/python/tools/transformers/fusion_qordered_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_attention...
421
16,717
onnxruntime
onnxruntime/python/tools/transformers/fusion_options.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from argparse import ArgumentParser from enum import Enum class Attent...
341
12,386
onnxruntime
onnxruntime/python/tools/transformers/fusion_biasgelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
67
2,234
onnxruntime
onnxruntime/python/tools/transformers/past_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 ...
150
6,806
onnxruntime
onnxruntime/python/tools/transformers/onnx_model.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from __future__ import annotations import itertools import logging impo...
1,645
68,593
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_mmdit.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from fusion_layernorm import FusionLayerNormalization f...
120
4,459
onnxruntime
onnxruntime/python/tools/transformers/benchmark_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 ...
643
22,355
onnxruntime
onnxruntime/python/tools/transformers/fusion_attention_vae.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
301
12,079
onnxruntime
onnxruntime/python/tools/transformers/onnx_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from fusion_utils import NumpyHelper from onnx import ModelProto, Tensor...
56
2,120
onnxruntime
onnxruntime/python/tools/transformers/fusion_skiplayernorm.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
259
10,817
onnxruntime
onnxruntime/python/tools/transformers/metrics.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 ...
164
5,060
onnxruntime
onnxruntime/python/tools/transformers/fusion_qordered_gelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
119
4,292
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_bert.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from convert_to_packi...
513
21,425
onnxruntime
onnxruntime/python/tools/transformers/fusion_skip_group_norm.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusio...
255
10,601
onnxruntime
onnxruntime/python/tools/transformers/onnx_exporter.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 ...
720
24,621
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_sam2.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from fusion_attention_sam2 import FusionMultiHeadAttent...
138
4,844
onnxruntime
onnxruntime/python/tools/transformers/torch_onnx_export_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import warnings import torch from torch._C._onnx import OperatorExport...
83
3,001
onnxruntime
onnxruntime/python/tools/transformers/fusion_mha_dit.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
534
24,130
onnxruntime
onnxruntime/python/tools/transformers/large_model_exporter.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Export LLM to onnx """ import argparse import inspect import math ...
397
14,927
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_bert_tf.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import numpy as np import onnx from onnx import TensorP...
589
24,915
onnxruntime
onnxruntime/python/tools/transformers/fusion_bias_add.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from numpy...
58
1,984
onnxruntime
onnxruntime/python/tools/transformers/dynamo_onnx_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from collections.abc import Sequence from logging import getLogger from t...
206
7,597
onnxruntime
onnxruntime/python/tools/transformers/fusion_attention_clip.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_attention import AttentionMas...
341
13,756
onnxruntime
onnxruntime/python/tools/transformers/affinity_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Get/Set cpu affinity. Currently only support part of Unix system impo...
41
1,402
onnxruntime
onnxruntime/python/tools/transformers/profile_result_processor.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """This profiler result processor print out the kernel time spent on eac...
359
12,582
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_clip.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_attention_clip import Fusion...
43
1,352
onnxruntime
onnxruntime/python/tools/transformers/fusion_reshape.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impo...
174
6,230
onnxruntime
onnxruntime/python/tools/transformers/fusion_transpose.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
168
6,837
onnxruntime
onnxruntime/python/tools/transformers/fusion_gpt_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
547
21,962
onnxruntime
onnxruntime/python/tools/transformers/fusion_attention_unet.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
1,308
55,648
onnxruntime
onnxruntime/python/tools/transformers/import_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import importlib.metadata import importlib.util def is_installed(packa...
21
631
onnxruntime
onnxruntime/python/tools/transformers/fusion_constant_fold.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
145
5,870
onnxruntime
onnxruntime/python/tools/transformers/optimizer.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Convert Bert ONNX model converted from TensorFlow or exported from Py...
622
25,163
onnxruntime
onnxruntime/python/tools/transformers/quantize_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 ...
81
2,931
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_unet.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from fusion_attention_unet import FusionAttentionUnet f...
259
9,255
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/gpt2_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. # -------------------------------------------------------------------------- # This ...
514
17,735
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/parity_check_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. # -------------------------------------------------------------------------- # This s...
147
5,694
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/__init__.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os.path import sys sys.path.append(os.path.dirname(__file__)) t...
13
483
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/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. # -------------------------------------------------------------------------- """ This...
567
20,271
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/benchmark_gpt2.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 s...
414
15,517
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/gpt2_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. # -------------------------------------------------------------------------- # This s...
1,032
40,300
onnxruntime
onnxruntime/python/tools/transformers/models/gpt2/gpt2_tester.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 s...
502
19,570
onnxruntime
onnxruntime/python/tools/transformers/models/bart/export.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 ...
99
4,187
onnxruntime
onnxruntime/python/tools/transformers/models/bart/utils/chain_enc_dec_with_beamsearch.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 ...
150
5,741
onnxruntime
onnxruntime/python/tools/transformers/models/bart/utils/export_summarization_enc_dec_past.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 ...
271
10,288
onnxruntime
onnxruntime/python/tools/transformers/models/bart/utils/onnx_inference.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 ...
96
3,497
onnxruntime
onnxruntime/python/tools/transformers/models/bart/utils/export_summarization_edinit.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 ...
210
7,887
onnxruntime
onnxruntime/python/tools/transformers/models/bart/utils/export_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...
172
6,292
onnxruntime
onnxruntime/python/tools/transformers/models/phi2/inference_example.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import time import numpy as np import torch from transformers import Au...
415
17,291
onnxruntime
onnxruntime/python/tools/transformers/models/phi2/__init__.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os import sys sys.path.append(os.path.dirname(__file__)) transf...
13
478
onnxruntime
onnxruntime/python/tools/transformers/models/phi2/convert_to_onnx.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from __future__ import annotations import argparse import logging import...
591
20,408
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from TensorRT demo diffusion, which has the following license...
104
3,312
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/diffusion_models.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from stable_diffusion_tensorrt_txt2img.py in diffusers and Te...
1,319
50,398
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img_xl.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from TensorRT demo diffusion, which has the following license...
270
9,948
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import argparse import csv import logging import os import statistics i...
1,512
49,574
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/trt_utilities.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import tensorrt as trt TRT_LOGGER = trt.Logger(trt.Logger.ERROR) def ...
13
420
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/optimize_pipeline.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # # This script converts stable diffusion onnx models from float to half...
591
21,648
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/demo_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from TensorRT demo diffusion, which has the following license...
779
28,598
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/diffusion_schedulers.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from utilities.py of TensorRT demo diffusion, which has the f...
1,180
48,289
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_tensorrt.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from TensorRT demo diffusion, which has the following license...
396
15,621
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import hashlib import os from enum import Enum import torch from diffus...
296
11,670
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_ort_cuda.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import gc import logging import os import onnx import torch from diffu...
388
15,854
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_ort_trt.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import gc import logging import os import torch from cuda import cudar...
289
11,163
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/pipeline_stable_diffusion.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from TensorRT demo diffusion, which has the following license...
832
33,198
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_torch.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from diffusion_models import PipelineInfo from engine_bu...
109
4,198
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/ort_optimizer.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ ONNX Model Optimizer for Stable Diffusion """ import gc import log...
137
5,717
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark_controlnet.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import gc import importlib.util import time from statistics import mean...
427
12,929
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/test/check_image.py
.py
import argparse import os import cv2 import open_clip import torch from PIL import Image from sentence_transformers import util def arg_parser(): parser = argparse.ArgumentParser(description="Options for Compare 2 image") parser.add_argument("--image1", type=str, help="Path to image 1") parser.add_argume...
79
2,600
onnxruntime
onnxruntime/python/tools/transformers/models/t5/t5_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # ------------------------------------------------------------------------- import logging import os from pathlib import Path import torch from floa...
316
12,626
onnxruntime
onnxruntime/python/tools/transformers/models/t5/t5_encoder.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # ------------------------------------------------------------------------- import logging import random import torch from transformers import MT5Co...
71
2,249
onnxruntime
onnxruntime/python/tools/transformers/models/t5/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 ...
319
10,192
onnxruntime
onnxruntime/python/tools/transformers/models/t5/t5_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 ...
438
16,751
onnxruntime
onnxruntime/python/tools/transformers/models/t5/t5_encoder_decoder_init.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # ------------------------------------------------------------------------- import logging import os import tempfile from pathlib import Path import...
362
15,060
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/benchmark_longformer.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...
822
29,409
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/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. # -------------------------------------------------------------------------- # This ...
414
14,794
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/generate_test_data.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Generate test data for a longformer model, so that we can use onnxrun...
348
9,617
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/longformer_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. # -------------------------------------------------------------------------- # This s...
77
3,047
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/torch_extensions/setup.py
.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CppExtension setup( name="longformer_attention", ext_modules=[ CppExtension( name="longformer_attention", sources=["longformer_attention.cpp"], include_dirs=[], extra_compi...
16
399
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/image_encoder.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import warnings import torch from sam2.modeling.sam2_bas...
237
9,552
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/benchmark_sam2.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Benchmark performance of SAM2 encoder with ORT or PyTorch. See benc...
639
21,830
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/sam2_image_onnx_predictor.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import numpy as np import torch from PIL.Image import I...
280
12,423
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/sam2_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import os import sys from collections.abc import Mapping ...
148
5,520
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/convert_to_onnx.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import argparse import os import pathlib import sys import torch from i...
271
10,399
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/sam2_demo.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import os import matplotlib.image as mpimg import matplotlib.pyplot as ...
322
10,501
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/image_decoder.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import warnings import torch import torch.nn.functional ...
273
10,821
onnxruntime
onnxruntime/python/tools/transformers/models/sam2/mask_decoder.py
.py
# ------------------------------------------------------------------------- # Copyright (R) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import warnings import torch from image_encoder import S...
209
8,858