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/qnn/add_trans_cast.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import json
from argparse import ArgumentParser
import onnx
from onnx i... | 293 | 13,456 |
onnxruntime | onnxruntime/python/tools/quantization/qdq_loss_debug.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft, Intel Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"... | 390 | 15,440 |
onnxruntime | onnxruntime/python/tools/quantization/static_quantize_runner.py | .py | import argparse
import json
import os
import numpy as np
import onnx
import onnxruntime
from onnxruntime.quantization import QuantFormat, QuantType, StaticQuantConfig, quantize
from onnxruntime.quantization.calibrate import CalibrationDataReader, CalibrationMethod
class OnnxModelCalibrationDataReader(CalibrationDat... | 257 | 11,085 |
onnxruntime | onnxruntime/python/tools/quantization/preprocess.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft, Intel Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
i... | 142 | 4,904 |
onnxruntime | onnxruntime/python/tools/quantization/cuda_quantizer.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"""CUDA w... | 644 | 26,855 |
onnxruntime | onnxruntime/python/tools/quantization/quant_utils.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 __fut... | 1,286 | 51,725 |
onnxruntime | onnxruntime/python/tools/quantization/calibrate.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft, Intel Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------... | 1,354 | 56,791 |
onnxruntime | onnxruntime/python/tools/quantization/__init__.py | .py | from .calibrate import ( # noqa: F401
CalibraterBase,
CalibrationDataReader,
CalibrationMethod,
MinMaxCalibrater,
TensorData,
TensorsData,
create_calibrator,
load_tensors_data,
save_tensors_data,
)
from .cuda_quantizer import CudaQuantizer # noqa: F401
from .qdq_quantizer import QD... | 25 | 763 |
onnxruntime | onnxruntime/python/tools/quantization/shape_inference.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft, Intel Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
... | 211 | 10,049 |
onnxruntime | onnxruntime/python/tools/quantization/registry.py | .py | from .operators.activation import QDQRemovableActivation, QLinearActivation
from .operators.argmax import QArgMax
from .operators.attention import AttentionQuant
from .operators.base_operator import QuantOperatorBase
from .operators.binary_op import QLinearBinaryOp
from .operators.concat import QLinearConcat
from .oper... | 113 | 3,807 |
onnxruntime | onnxruntime/python/tools/quantization/onnx_quantizer.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 log... | 1,175 | 49,827 |
onnxruntime | onnxruntime/python/tools/quantization/quantize.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 __fut... | 1,077 | 60,301 |
onnxruntime | onnxruntime/python/tools/quantization/qdq_quantizer.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 __fut... | 1,542 | 72,744 |
onnxruntime | onnxruntime/python/tools/quantization/matmul_bnb4_quantizer.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ar... | 240 | 9,024 |
onnxruntime | onnxruntime/python/tools/quantization/onnx_model.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from pathlib import Path
import onnx
import onnx.helper as onnx_helper... | 601 | 23,928 |
onnxruntime | onnxruntime/python/tools/quantization/tensor_quant_overrides.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 __fut... | 521 | 20,784 |
onnxruntime | onnxruntime/python/tools/quantization/base_quantizer.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 log... | 531 | 25,765 |
onnxruntime | onnxruntime/python/tools/quantization/matmul_nbits_quantizer.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 __fu... | 1,875 | 79,165 |
onnxruntime | onnxruntime/python/tools/quantization/execution_providers/qnn/fusion_spacetodepth.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"""Define ... | 163 | 6,123 |
onnxruntime | onnxruntime/python/tools/quantization/execution_providers/qnn/preprocess.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 __fut... | 354 | 16,383 |
onnxruntime | onnxruntime/python/tools/quantization/execution_providers/qnn/mixed_precision_overrides_utils.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 __fut... | 414 | 18,582 |
onnxruntime | onnxruntime/python/tools/quantization/execution_providers/qnn/quant_config.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 __fut... | 390 | 18,597 |
onnxruntime | onnxruntime/python/tools/quantization/execution_providers/qnn/fusion_lpnorm.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 __fut... | 133 | 5,195 |
onnxruntime | onnxruntime/python/tools/quantization/neural_compressor/util.py | .py | #
# The implementation of this file is based on:
# https://github.com/intel/neural-compressor/tree/master/neural_compressor
#
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a ... | 81 | 2,682 |
onnxruntime | onnxruntime/python/tools/quantization/neural_compressor/onnx_model.py | .py | #
# The implementation of this file is based on:
# https://github.com/intel/neural-compressor/tree/master/neural_compressor
#
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a ... | 1,237 | 49,600 |
onnxruntime | onnxruntime/python/tools/quantization/neural_compressor/weight_only.py | .py | #
# The implementation of this file is based on:
# https://github.com/intel/neural-compressor/tree/master/neural_compressor
#
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a ... | 933 | 36,295 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/replace_upsample_with_resize.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 __fut... | 97 | 3,331 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/fusion_layernorm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 147 | 6,000 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/fusion_gelu.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 273 | 10,375 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/fusion.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 312 | 11,777 |
onnxruntime | onnxruntime/python/tools/quantization/operators/split.py | .py | import onnx
from ..quant_utils import QuantizedValue, QuantizedValueType, attribute_to_kwarg
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase
class QSplit(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(onnx_quantizer, onnx_no... | 64 | 2,195 |
onnxruntime | onnxruntime/python/tools/quantization/operators/norm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from .qdq_base_operator import QDQOperatorBase
class QDQNormalization(... | 41 | 1,609 |
onnxruntime | onnxruntime/python/tools/quantization/operators/binary_op.py | .py | import onnx
from onnx import onnx_pb as onnx_proto # noqa: F401
from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType, attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
class QLinearBinaryOp(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_nod... | 73 | 2,472 |
onnxruntime | onnxruntime/python/tools/quantization/operators/resize.py | .py | from .direct_q8 import Direct8BitOp, QDQDirect8BitOp
class QResize(Direct8BitOp):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(onnx_quantizer, onnx_node)
def quantize(self):
node = self.node
assert node.op_type == "Resize"
# if version is less than 11, go t... | 35 | 928 |
onnxruntime | onnxruntime/python/tools/quantization/operators/qdq_base_operator.py | .py | import itertools
from ..quant_utils import QuantizedValue, QuantizedValueType, attribute_to_kwarg, quantize_nparray # noqa: F401
from .base_operator import QuantOperatorBase # noqa: F401
class QDQOperatorBase:
def __init__(self, onnx_quantizer, onnx_node):
self.quantizer = onnx_quantizer
self.n... | 23 | 801 |
onnxruntime | onnxruntime/python/tools/quantization/operators/argmax.py | .py | from .base_operator import QuantOperatorBase
# Use the quantized tensor as input without DQ.
class QArgMax(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(onnx_quantizer, onnx_node)
def quantize(self):
node = self.node
quantized_input_value = self.... | 19 | 571 |
onnxruntime | onnxruntime/python/tools/quantization/operators/softmax.py | .py | import onnx
import onnx.helper
from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType, attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
class QLinearSoftmax(QuantOperatorBase):
def quantize(self):
node = self.node
# set limitations for sof... | 75 | 2,640 |
onnxruntime | onnxruntime/python/tools/quantization/operators/attention.py | .py | import onnx
from onnx import onnx_pb as onnx_proto # noqa: F401
from ..quant_utils import attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
"""
Quantize Attention
"""
class AttentionQuant(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(on... | 74 | 2,564 |
onnxruntime | onnxruntime/python/tools/quantization/operators/gavgpool.py | .py | import onnx
from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType, attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
class QGlobalAveragePool(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(onnx_quantizer, onnx_... | 63 | 2,383 |
onnxruntime | onnxruntime/python/tools/quantization/operators/pooling.py | .py | import onnx
from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType, attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
class QLinearPool(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(onnx_quantizer, onnx_node)
... | 68 | 2,218 |
onnxruntime | onnxruntime/python/tools/quantization/operators/gemm.py | .py | import logging
import numpy as np # noqa: F401
import onnx
from ..quant_utils import (
TENSOR_NAME_QUANT_SUFFIX,
QuantizedValue,
QuantizedValueType,
attribute_to_kwarg,
find_by_name, # noqa: F401
get_mul_node, # noqa: F401
ms_domain,
)
from .base_operator import QuantOperatorBase # noq... | 173 | 6,054 |
onnxruntime | onnxruntime/python/tools/quantization/operators/embed_layernorm.py | .py | import logging
import onnx
from onnx import onnx_pb as onnx_proto # noqa: F401
from ..quant_utils import attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
"""
Quantizes the EmbedLayerNorm fused ONNXRuntime Op.
This Quant operator keeps the input and segment IDs at int32 but will quantize a... | 122 | 3,937 |
onnxruntime | onnxruntime/python/tools/quantization/operators/activation.py | .py | import onnx
from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType, attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase
class QLinearActivation(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
... | 120 | 4,426 |
onnxruntime | onnxruntime/python/tools/quantization/operators/base_operator.py | .py | class QuantOperatorBase:
def __init__(self, onnx_quantizer, onnx_node):
self.quantizer = onnx_quantizer
self.node = onnx_node
def should_quantize(self):
if not self.quantizer.should_quantize_node(self.node):
return False
return self.quantizer.is_float_tensor(self.no... | 27 | 1,092 |
onnxruntime | onnxruntime/python/tools/quantization/operators/where.py | .py | import onnx
from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType, attribute_to_kwarg, ms_domain
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase
class QLinearWhere(QuantOperatorBase):
def should_quantize(self):
return True
... | 88 | 3,040 |
onnxruntime | onnxruntime/python/tools/quantization/operators/conv.py | .py | import numpy as np
import onnx
from onnx import onnx_pb as onnx_proto
from ..quant_utils import (
TENSOR_NAME_QUANT_SUFFIX,
QuantizedValue,
QuantizedValueType,
attribute_to_kwarg,
find_by_name,
get_mul_node,
)
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperat... | 261 | 9,943 |
onnxruntime | onnxruntime/python/tools/quantization/operators/gather.py | .py | from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase
"""
Quantize Gather
"""
class GatherQuant(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super().__ini... | 65 | 2,166 |
onnxruntime | onnxruntime/python/tools/quantization/operators/matmul.py | .py | import itertools
import logging
import onnx
from ..quant_utils import (
FLOAT8_TYPES,
TENSOR_NAME_QUANT_SUFFIX,
QuantizedValue,
QuantizedValueType,
find_by_name,
get_mul_node,
)
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase
class QOpMatMul(QuantO... | 228 | 7,995 |
onnxruntime | onnxruntime/python/tools/quantization/operators/pad.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from __future__ import annotations
from typing import Any
import nump... | 173 | 7,779 |
onnxruntime | onnxruntime/python/tools/quantization/operators/concat.py | .py | import onnx
from ..quant_utils import ( # noqa: F401
TENSOR_NAME_QUANT_SUFFIX,
QuantizedValue,
QuantizedValueType,
attribute_to_kwarg,
ms_domain,
)
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase # noqa: F401
class QLinearConcat(QuantOperatorBase):
... | 63 | 2,081 |
onnxruntime | onnxruntime/python/tools/quantization/operators/direct_q8.py | .py | from ..quant_utils import TENSOR_NAME_QUANT_SUFFIX, QuantizedValue, QuantizedValueType
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase
# For operators that support 8bits operations directly, and output could
# reuse input[0]'s type, zeropoint, scale; For example,Transpose, ... | 79 | 3,311 |
onnxruntime | onnxruntime/python/tools/quantization/operators/lstm.py | .py | import numpy
import onnx
from onnx import onnx_pb as onnx_proto
from ..quant_utils import QuantType, attribute_to_kwarg, ms_domain # noqa: F401
from .base_operator import QuantOperatorBase
"""
Quantize LSTM
"""
class LSTMQuant(QuantOperatorBase):
def __init__(self, onnx_quantizer, onnx_node):
super... | 122 | 5,117 |
onnxruntime | onnxruntime/python/tools/quantization/operators/maxpool.py | .py | from ..quant_utils import FLOAT8_TYPES
from .base_operator import QuantOperatorBase
from .direct_q8 import Direct8BitOp, QDQDirect8BitOp
class QMaxPool(Direct8BitOp):
def __init__(self, onnx_quantizer, onnx_node):
super().__init__(onnx_quantizer, onnx_node)
def quantize(self):
node = self.nod... | 45 | 1,349 |
onnxruntime | onnxruntime/python/tools/quantization/CalTableFlatBuffers/KeyValue.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: CalTableFlatBuffers
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class KeyValue:
__slots__ = ["_tab"]
@classmethod
def GetRootAs(cls, buf, offset=0): # noqa: N802
n = flatbu... | 79 | 2,172 |
onnxruntime | onnxruntime/python/tools/quantization/CalTableFlatBuffers/TrtTable.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: CalTableFlatBuffers
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class TrtTable:
__slots__ = ["_tab"]
@classmethod
def GetRootAs(cls, buf, offset=0): # noqa: N802
n = flatbu... | 91 | 2,592 |
onnxruntime | onnxruntime/python/tools/custom_op_wrapper/create_custom_op_wrapper.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Creates an ONNX model with a single custom operator node that wraps a... | 277 | 7,981 |
onnxruntime | onnxruntime/python/tools/microbench/skip_layer_norm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 75 | 2,368 |
onnxruntime | onnxruntime/python/tools/microbench/softmax.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 59 | 1,756 |
onnxruntime | onnxruntime/python/tools/microbench/benchmark.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import time
from abc import ABC, abstractmethod
from argp... | 166 | 4,900 |
onnxruntime | onnxruntime/python/tools/microbench/attention.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 70 | 2,236 |
onnxruntime | onnxruntime/python/tools/microbench/cast.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 109 | 3,511 |
onnxruntime | onnxruntime/python/tools/microbench/fast_gelu.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 72 | 2,045 |
onnxruntime | onnxruntime/python/tools/microbench/layernorm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 63 | 1,968 |
onnxruntime | onnxruntime/python/tools/microbench/nhwcConv.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 63 | 2,065 |
onnxruntime | onnxruntime/python/tools/microbench/conv.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 63 | 2,049 |
onnxruntime | onnxruntime/python/tools/microbench/topk.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 62 | 1,956 |
onnxruntime | onnxruntime/python/tools/microbench/matmul.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 106 | 3,145 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_vae.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_attention_vae import FusionA... | 43 | 1,471 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_gpt_attention_megatron.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from fusion_gpt_attent... | 356 | 13,284 |
onnxruntime | onnxruntime/python/tools/transformers/float16.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# This file is modified from https://github.com/microsoft/onnxconverter... | 510 | 24,681 |
onnxruntime | onnxruntime/python/tools/transformers/shape_optimizer.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# This tool is not used directly in bert optimization. It could assist ... | 401 | 15,068 |
onnxruntime | onnxruntime/python/tools/transformers/convert_to_packing_mode.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
import logging
import os
from constants import (
A... | 386 | 16,419 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_gpt_attention_no_past.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_base import Fusion
from onnx ... | 258 | 10,573 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_gemmfastgelu.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... | 122 | 4,087 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_bart.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
from fusion_attention import AttentionMask
from fusion_b... | 142 | 5,406 |
onnxruntime | onnxruntime/python/tools/transformers/machine_info.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# It is used to dump machine information for Notebooks
import argparse... | 231 | 7,351 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_bert_keras.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import onnx
from onnx import numpy_helper
from onnx_mod... | 475 | 18,536 |
onnxruntime | onnxruntime/python/tools/transformers/bert_test_data.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# It is a tool to generate test data for a bert model.
# The test data ... | 642 | 22,805 |
onnxruntime | onnxruntime/python/tools/transformers/compare_bert_results.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# It is a tool to compare the inference results of the original model a... | 257 | 8,192 |
onnxruntime | onnxruntime/python/tools/transformers/io_binding_helper.py | .py | import copy
import logging
from collections import OrderedDict
from collections.abc import Mapping
from typing import Any
import numpy
import torch
from onnx import TensorProto
from onnxruntime import InferenceSession, RunOptions
# Type alias
ShapeDict = Mapping[str, tuple | list[int]]
logger = logging.getLogger(__... | 539 | 21,307 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_shape.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... | 110 | 3,654 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_biassplitgelu.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_base import Fusion
from onnx ... | 111 | 4,381 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_nhwc_conv.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... | 100 | 3,849 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_fastgelu.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_base import Fusion
from onnx ... | 493 | 17,689 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_simplified_layernorm.py | .py | import logging
from fusion_base import Fusion
from fusion_skiplayernorm import FusionSkipLayerNormalization
from onnx import helper
from onnx_model import OnnxModel
logger = logging.getLogger(__name__)
class FusionSimplifiedLayerNormalization(Fusion):
def __init__(self, model: OnnxModel):
super().__init... | 166 | 7,666 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_qordered_matmul.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... | 217 | 8,325 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_phi.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from dynamo_onnx_help... | 930 | 35,410 |
onnxruntime | onnxruntime/python/tools/transformers/shape_infer_helper.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import os
import sys
# In ORT Package the symbolic_shap... | 140 | 5,279 |
onnxruntime | onnxruntime/python/tools/transformers/convert_tf_models_to_pytorch.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import glob
import os
import tarfile
import zipfile
TFMODELS = {
"... | 252 | 8,993 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_tnlr.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
from fusion_attention import AttentionMask, FusionAttent... | 227 | 8,179 |
onnxruntime | onnxruntime/python/tools/transformers/benchmark.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright 2018 The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain... | 946 | 32,580 |
onnxruntime | onnxruntime/python/tools/transformers/convert_generation.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# -------------------------------------------------------------------------
"""
This converts GPT2 or T5 model to onnx with beam search operator.
Exa... | 3,607 | 141,487 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_base.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from collections import defaultdict
from collections.abc import Sequence... | 142 | 5,825 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_layernorm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_base import Fusion
from onnx ... | 490 | 20,356 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_embedlayer.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... | 811 | 35,864 |
onnxruntime | onnxruntime/python/tools/transformers/profiler.py | .py | import argparse
import os
import numpy
import psutil
from onnx import TensorProto
"""
This profiler tool could run a transformer model and print out the kernel time spent on each Node of the model.
Example of profiling of longformer model:
python profiler.py --model longformer-base-4096_fp32.onnx --batch_size 1 -... | 435 | 13,302 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_quickgelu.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
from fusion_base import Fusion
from onnx import helper
... | 75 | 2,795 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_gelu_approximation.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from fusion_base import Fusion
from onnx import helper
from onnx_model ... | 26 | 1,004 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_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 onnx ... | 259 | 10,193 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_qordered_layernorm.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... | 123 | 4,810 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.