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 |
|---|---|---|---|---|---|
onnx | onnx/backend/test/case/node/constant.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Constant(Base):
@staticmethod
def export() -> None:
va... | 30 | 801 |
onnx | onnx/backend/test/case/node/layernormalization.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
# Layer normalization's reference implementation
def _layer_normalization(X,... | 179 | 6,317 |
onnx | onnx/backend/test/case/node/atanh.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Atanh(Base):
@staticmethod
def export() -> None:
node ... | 29 | 798 |
onnx | onnx/backend/test/case/node/scatterelements.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Sequence
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.cas... | 267 | 8,574 |
onnx | onnx/backend/test/case/node/or_.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Or(Base):
@staticmethod
def export() -> None:
node = o... | 77 | 2,482 |
onnx | onnx/backend/test/case/node/bitshift.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class BitShift(Base):
@staticmethod
def export_right_unit8() -> None... | 101 | 3,581 |
onnx | onnx/backend/test/case/node/scatternd.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def scatter_nd_impl(
data: np.ndarray, indices: np.ndarray, updates: np.... | 272 | 10,458 |
onnx | onnx/backend/test/case/node/scatter.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
import onnx
from onnx import helper
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
# The below Scatter's numpy ... | 110 | 3,398 |
onnx | onnx/backend/test/case/node/tanh.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Tanh(Base):
@staticmethod
def export() -> None:
node =... | 29 | 768 |
onnx | onnx/backend/test/case/node/causal_conv_with_state.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.reference.ops.op_causal_conv_with_state import (
CausalConvWithS... | 336 | 11,846 |
onnx | onnx/backend/test/case/node/onehot.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def one_hot(indices, depth, axis=-1, dtype=np.float32):
"""Compute one h... | 160 | 5,063 |
onnx | onnx/backend/test/case/node/sequenceinsert.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def sequence_insert_reference_implementation(
se... | 76 | 2,589 |
onnx | onnx/backend/test/case/node/cos.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Cos(Base):
@staticmethod
def export() -> None:
node = ... | 29 | 713 |
onnx | onnx/backend/test/case/node/instancenorm.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class InstanceNormalization(Base):
@staticmethod
def export() -> Non... | 59 | 2,010 |
onnx | onnx/backend/test/case/node/acosh.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Acosh(Base):
@staticmethod
def export() -> None:
node ... | 29 | 797 |
onnx | onnx/backend/test/case/node/not_.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Not(Base):
@staticmethod
def export() -> None:
node = ... | 33 | 883 |
onnx | onnx/backend/test/case/node/hardswish.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def hardswish(x: np.ndarray) -> np.ndarray:
alfa = float(1 / 6)
beta... | 31 | 734 |
onnx | onnx/backend/test/case/node/negativeloglikelihoodloss.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def compute_negative_log_likelihood_loss(
input, target, weight=None, re... | 586 | 19,618 |
onnx | onnx/backend/test/case/node/col2im.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Col2Im(Base):
"""Col2Im operator with N-dimension support
The... | 350 | 11,069 |
onnx | onnx/backend/test/case/node/leakyrelu.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class LeakyRelu(Base):
@staticmethod
def export() -> None:
n... | 40 | 1,276 |
onnx | onnx/backend/test/case/node/lpnormalization.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class LpNormalization(Base):
@staticmethod
def export_l2normalizatio... | 81 | 3,152 |
onnx | onnx/backend/test/case/node/gathernd.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def gather_nd_impl(
data: np.ndarray, indices: np.ndarray, batch_dims: i... | 122 | 4,041 |
onnx | onnx/backend/test/case/node/reversesequence.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class ReverseSequence(Base):
@staticmethod
def export_reversesequenc... | 87 | 2,240 |
onnx | onnx/backend/test/case/node/max.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.backend.test.case.utils import all_numeric_dtypes
class Max(Base):... | 67 | 2,044 |
onnx | onnx/backend/test/case/node/lstm.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class LSTMHelper:
def __init__(self, **params: A... | 416 | 12,445 |
onnx | onnx/backend/test/case/node/equal.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Equal(Base):
@staticmethod
def export() -> None:
node ... | 93 | 3,307 |
onnx | onnx/backend/test/case/node/reducel1.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class ReduceL1(Base):
@staticmethod
def export_do_not_keepdims() -> ... | 190 | 5,604 |
onnx | onnx/backend/test/case/node/sub.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Sub(Base):
@staticmethod
def export() -> None:
node = ... | 74 | 2,604 |
onnx | onnx/backend/test/case/node/castlike.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import itertools
import numpy as np
import onnx
from onnx import TensorProto
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.helper import make_te... | 325 | 11,394 |
onnx | onnx/backend/test/case/node/dynamicquantizelinear.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class DynamicQuantizeLinear(Base):
@staticmethod
def export() -> Non... | 71 | 2,477 |
onnx | onnx/backend/test/case/node/shape.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
# Reference implementation of shape op
def shape_reference_impl(
x: np.n... | 65 | 1,688 |
onnx | onnx/backend/test/case/node/squeeze.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Squeeze(Base):
@staticmethod
def export_squeeze() -> None:
... | 38 | 1,087 |
onnx | onnx/backend/test/case/node/xor.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Xor(Base):
@staticmethod
def export() -> None:
node = ... | 77 | 2,504 |
onnx | onnx/backend/test/case/node/floor.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Floor(Base):
@staticmethod
def export() -> None:
node ... | 29 | 762 |
onnx | onnx/backend/test/case/node/exp.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Exp(Base):
@staticmethod
def export() -> None:
node = ... | 29 | 761 |
onnx | onnx/backend/test/case/node/mean.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Mean(Base):
@staticmethod
def export() -> None:
data_0... | 48 | 1,367 |
onnx | onnx/backend/test/case/node/mod.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Mod(Base):
@staticmethod
def export_mod_mixed_sign_float64() -... | 178 | 6,251 |
onnx | onnx/backend/test/case/node/min.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.backend.test.case.utils import all_numeric_dtypes
class Min(Base):... | 67 | 2,044 |
onnx | onnx/backend/test/case/node/reduce_log_sum_exp.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class ReduceLogSumExp(Base):
@staticmethod
def export_do_not_keepdim... | 194 | 5,778 |
onnx | onnx/backend/test/case/node/mish.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Mish(Base):
@staticmethod
def export() -> None:
node =... | 24 | 655 |
onnx | onnx/backend/test/case/node/tan.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Tan(Base):
@staticmethod
def export() -> None:
node = ... | 29 | 713 |
onnx | onnx/backend/test/case/node/erf.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import math
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Erf(Base):
@staticmethod
def export() -> None:
... | 27 | 620 |
onnx | onnx/backend/test/case/node/linear_attention.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.reference.ops.op_linear_attention import (
LinearAttention as _R... | 542 | 18,779 |
onnx | onnx/backend/test/case/node/spacetodepth.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class SpaceToDepth(Base):
@staticmethod
def export() -> None:
... | 67 | 1,939 |
onnx | onnx/backend/test/case/node/eyelike.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class EyeLike(Base):
@staticmethod
def export_without_dtype() -> Non... | 61 | 1,749 |
onnx | onnx/backend/test/case/node/maxpool.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.reference.ops.op_pool_common import (
get_output_shape_auto_pad,... | 726 | 22,111 |
onnx | onnx/backend/test/case/node/bitcast.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class BitCast(Base):
@staticmethod
def export_bitcast_float32_to_int... | 148 | 5,158 |
onnx | onnx/backend/test/case/node/ai_onnx_ml/array_feature_extractor.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class ArrayFeatureExtractor(Base):
@staticmethod
def export() -> None... | 32 | 826 |
onnx | onnx/backend/test/case/node/ai_onnx_ml/tree_ensemble.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.helper import make_tensor
class TreeEnsemble(Base):
@staticmeth... | 124 | 3,907 |
onnx | onnx/backend/test/case/node/ai_onnx_ml/binarizer.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.reference.ops.aionnxml.op_binarizer import compute_binarizer
class ... | 29 | 781 |
onnx | onnx/backend/test/case/node/ai_onnx_ml/label_encoder.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.helper import make_tensor
class LabelEncoder(Base):
@staticmeth... | 102 | 3,045 |
onnx | onnx/backend/test/case/model/shrink.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
class ShrinkTest(Base):
@staticmethod
def export() -> None:
... | 43 | 1,200 |
onnx | onnx/backend/test/case/model/sequence.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import typing
import numpy as np
import onnx
from onnx import TensorProto
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
def SequenceEmptyImpl() -> list... | 457 | 16,039 |
onnx | onnx/backend/test/case/model/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
from typing import TYPE_CHECKING
from onnx.backend.test.case.test_case import TestCase
from onnx.backend.test.case.utils import import_recursive
if TYPE_CHECKING:
from collections.abc im... | 82 | 2,191 |
onnx | onnx/backend/test/case/model/stringnormalizer.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
if TYPE_CHECKING:
from collections.abc ... | 206 | 6,219 |
onnx | onnx/backend/test/case/model/sign.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
class SingleSign(Base):
@staticmethod
def export() -> None:
... | 37 | 1,151 |
onnx | onnx/backend/test/case/model/expand.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
if TYPE_CHECKING:
from collections.abc ... | 92 | 3,300 |
onnx | onnx/backend/test/case/model/single_relu.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
class SingleRelu(Base):
@staticmethod
def export() -> None:
... | 37 | 1,086 |
onnx | onnx/backend/test/case/model/gradient.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
from onnx.defs import AI_ONNX_PREVIEW_TRAINING_DOMAIN, ONNX_DOMAIN
class Gra... | 111 | 4,010 |
onnx | onnx/backend/test/runner/item.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import dataclasses
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Callable
from onnx import ModelProto, NodeProto
# A container that hosts the test functi... | 22 | 484 |
onnx | onnx/backend/test/runner/__init__.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import functools
import glob
import os
import re
import shutil
import sys
import tempfile
import time
import unittest
from collections import defaultdict
from re import Pattern
from typing import TYPE_... | 549 | 22,128 |
onnx | onnx/backend/test/report/coverage.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import csv
import datetime
import os
from collections import OrderedDict, defaultdict
from typing import IO, Any
from tabulate import tabulate
import onnx
from onnx import GraphProto, defs, helper
_al... | 267 | 10,942 |
onnx | onnx/backend/test/report/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Any
import pytest
from onnx.backend.test.report.coverage import Coverage
if TYPE_CHECKING:
from collections.abc import Sequence
import _pytest
_coverage = C... | 51 | 1,321 |
onnx | onnx/backend/test/loader/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import json
import os
import onnx.backend.test.case.node
from onnx.backend.test.case.test_case import TestCase
from onnx.backend.test.case.utils import import_recursive
DATA_DIR = os.path.join(
os.... | 79 | 2,436 |
onnx | onnx/backend/sample/ops/abs.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
def abs(input: np.ndarray) -> np.ndarray: # noqa: A001
return np.abs(input) # type: ignore[no-any-return]
| 9 | 207 |
onnx | onnx/backend/sample/ops/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import importlib
import inspect
import pkgutil
import sys
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types import ModuleType
def collect_sample_implementations() -> dict[str, str]:
... | 31 | 862 |
onnx | onnx/fuzz/fuzz_model_loader.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
import onnx
def TestOneInput(data):
try:
model = onnx.load_model_from_string(data)
_ = len(model.graph.node)
... | 32 | 635 |
onnx | onnx/fuzz/fuzz_compose.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
"""Atheris fuzz harness for onnx.compose.
Two input paths are exercised per iteration, selected by a fuzzer-controlled
toggle byte read from the *tail* of the input:
* Raw -> a 4-byte big-endian length prefix splits the remaining bytes... | 148 | 5,033 |
onnx | onnx/fuzz/fuzz_parser.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
from onnx import parser
def TestOneInput(data):
try:
text = data.decode("utf-8", "surrogatepass")
parser.parse_mode... | 29 | 538 |
onnx | onnx/fuzz/fuzz_checker.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
from onnx import checker
def TestOneInput(data):
try:
checker.check_model(data, full_check=True)
except Exception:
... | 28 | 504 |
onnx | onnx/fuzz/make_seed_corpus.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import struct
import sys
import zipfile
from typing import TYPE_CHECKING
from onnx import TensorProto, helper
if TYPE_CHECKING:
from collections.abc import Mapping
def _make_model(
op_type: st... | 551 | 18,626 |
onnx | onnx/fuzz/fuzz_shape_inference.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
"""Atheris fuzz harness for onnx.shape_inference.
Two input paths are exercised per iteration, selected by a fuzzer-controlled
toggle byte read from the *tail* of the input (so the head remains a valid
candidate for the raw-bytes path):
*... | 190 | 6,508 |
onnx | onnx/fuzz/fuzz_version_converter.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
import onnx
from onnx import version_converter
def _default_opset_version(model):
for opset in model.opset_import:
if o... | 58 | 1,301 |
onnx | onnx/defs/gen_shape_inference_information.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx import defs
def main() -> None:
# domain -> support level -> name -> [schema]
with_inference = []
without_inference = []
for schema in defs.get_all_schemas():
domain,... | 32 | 875 |
onnx | onnx/defs/__init__.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
__all__ = [
"C",
"ONNX_DOMAIN",
"ONNX_ML_DOMAIN",
"AI_ONNX_PREVIEW_DOMAIN",
"AI_ONNX_PREVIEW_TRAINING_DOMAIN",
"has",
"register_schema",
"deregister_schema",
"get_sch... | 159 | 4,569 |
onnx | onnx/defs/gen_doc.py | .py | #!/usr/bin/env python
# Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
from collections import defaultdict
from typing import TYPE_CHECKING, Any, NamedTuple
import numpy as np
from onnx import defs, helper
from onnx.backend.sample.ops impo... | 441 | 17,078 |
onnxruntime | setup.py | .py | # ------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# ------------------------------------------------------------------------
# pylint: disable=C0103
import datetime
import json
import logging
import p... | 922 | 38,301 |
onnxruntime | go/testdata/gen_models.py | .py | """Generate minimal ONNX test models for Go bindings testing."""
import os
from onnx import TensorProto, checker, helper, save_model
OUT_DIR = os.path.dirname(os.path.abspath(__file__))
def make_add_f32():
"""Add op: A[2,3] + B[2,3] = C[2,3], all float32."""
input_a = helper.make_tensor_value_info("A", Ten... | 75 | 2,730 |
onnxruntime | samples/cxx/generate_model.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Generate a simple ONNX model that computes C = A + B.
Inputs:
A : float tensor of shape [1, 3]
B : float tensor of shape [1, 3]
Output:
C : float tensor of shape [1, 3]
Usage:
pip install onnx
python generate_... | 43 | 1,120 |
onnxruntime | onnxruntime/__init__.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
ONNX Runtime is a performance-focused scoring engine for Open Neural ... | 501 | 21,447 |
onnxruntime | onnxruntime/contrib_ops/cuda/llm/generate_kernels.py | .py | # Copyright (c) 2020-2023, 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 a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | 401 | 14,069 |
onnxruntime | onnxruntime/contrib_ops/cuda/llm/generate_moe_kernels.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# Generate MoE GEMM kernels for SM80+:
# python generate_moe_kernels.py -a "80;90" -o ./moe_gemm/launchers
import argparse
import glob
import os
from itertools import product
# CUDA type names fo... | 378 | 12,052 |
onnxruntime | onnxruntime/contrib_ops/cuda/llm/moe_gemm/launchers/generate_moe_gemm_tma_ws_sm120_fp4.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Generate SM120 FP4-based MoE GEMM kernel instantiations.
SM120 (Blackwell SM120) supports native FP4 grouped GEMM via CUTLASS TMA
warp-specialized kernels. This script generates one .cu file per
(o... | 139 | 4,795 |
onnxruntime | onnxruntime/contrib_ops/cuda/llm/moe_gemm/launchers/generate_moe_gemm_tma_ws_sm90_fp4.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
CLUSTER_K = 1
OLD_GENERATED_PREFIX = "moe_gemm_tma_ws_sm90_mixed_fp4"
NEW_GENERATED_PREFIX = "moe_gemm_tma... | 141 | 5,302 |
onnxruntime | onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v2/sparse_attention_v2_triton.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import triton
import triton.language as tl
@triton.jit
def block_spars... | 216 | 8,494 |
onnxruntime | onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v2/compile_sparse_attention_v2.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Use triton AoT compiler to convert sparse_attention_v2_triton.py to C ... | 150 | 7,646 |
onnxruntime | onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v1/sparse_attention_triton.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import triton
import triton.language as tl
# This kernel is for prompt... | 167 | 6,670 |
onnxruntime | onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v1/compile_sparse_attention.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Use triton AoT compiler to convert sparse_attention_triton.py to C sou... | 136 | 7,211 |
onnxruntime | onnxruntime/contrib_ops/cuda/bert/flash_attention/update_kernels.py | .py | import os
base_dir = os.path.dirname(os.path.realpath(__file__))
dims = [32, 64, 96, 128, 192, 256]
types = ["fp16", "bf16"]
copyright_header = """/******************************************************************************
* Copyright (c) 2024, Tri Dao.
**********************************************************... | 78 | 2,825 |
onnxruntime | onnxruntime/python/onnxruntime_validation.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Check OS requirements for ONNX Runtime Python Bindings.
"""
import l... | 155 | 6,795 |
onnxruntime | onnxruntime/python/onnxruntime_collect_build_info.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import ctypes
import sys
import warnings
def find_cudart_versions(build... | 48 | 2,062 |
onnxruntime | onnxruntime/python/onnxruntime_inference_collection.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from __future__ import annotations
import collections
import collections... | 1,628 | 68,906 |
onnxruntime | onnxruntime/python/convert_npz_to_onnx_adapter.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This script helps converting .npz files to .onnx_adapter files
import argparse
import os
import sys
import numpy as np
import onnxruntime as ort
def get_args() -> argparse:
parser = argparse.ArgumentParser()
pa... | 49 | 1,533 |
onnxruntime | onnxruntime/python/tools/onnx_randomizer.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# An offline standalone script to declassify an ONNX model by randomizi... | 86 | 3,276 |
onnxruntime | onnxruntime/python/tools/offline_tuning.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import copy
import json
import sys
from collections import OrderedDict
from pprint import pprint
from typing import Any
import onnx
TuningResults = dict[str, Any]
_TUNING_RESULTS_KEY = "tuning_results"
de... | 170 | 6,199 |
onnxruntime | onnxruntime/python/tools/onnxruntime_test.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from __future__ import annotations
import argparse
import os
import sys
... | 165 | 5,606 |
onnxruntime | onnxruntime/python/tools/symbolic_shape_infer.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# -*- coding: UTF-8 -*-
import argparse
import logging
import numpy as np
import onnx
try:
import sympy
except ImportError:
raise ImportError("sympy is required for symbolic shape inference. Install with: pip instal... | 3,145 | 145,403 |
onnxruntime | onnxruntime/python/tools/pytorch_export_contrib_ops.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Support for registering ONNX Runtime's built-in contrib ops with
PyTorch-ONNX exporter (torch.onnx.export).
"""
import contextlib
import typing
try:
# TODO(justinchuby): Create a function to alert users when torch i... | 138 | 5,214 |
onnxruntime | onnxruntime/python/tools/qnn/gen_qnn_ctx_onnx_model.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... | 365 | 16,198 |
onnxruntime | onnxruntime/python/tools/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.
# --------------------------------------------------------------------------
"""Provide... | 166 | 7,275 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.