repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
pytorch
pytorch-main/test/jit/test_module_containers.py
# Owner(s): ["oncall: jit"] import os import sys from typing import Any, List, Tuple from collections import OrderedDict import torch import torch.nn as nn from torch.testing._internal.jit_utils import JitTestCase # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path....
25,072
35.024425
127
py
pytorch
pytorch-main/test/jit/test_tensor_creation_ops.py
# Owner(s): ["oncall: jit"] import os import sys import torch # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase if __name__ == '__main__': raise R...
2,993
38.394737
81
py
pytorch
pytorch-main/test/jit/test_dataclasses.py
# Owner(s): ["oncall: jit"] # flake8: noqa from dataclasses import dataclass, field, InitVar from hypothesis import given, settings, strategies as st from torch.testing._internal.jit_utils import JitTestCase from typing import List, Optional import sys import torch import unittest from enum import Enum # Example jitt...
4,484
26.181818
122
py
pytorch
pytorch-main/test/jit/test_ignore_context_manager.py
# Owner(s): ["oncall: jit"] import os import sys import unittest import torch # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase from torch.jit.frontend...
3,324
35.141304
105
py
pytorch
pytorch-main/test/jit/test_data_parallel.py
# Owner(s): ["oncall: jit"] import os import sys import unittest import torch import torch.nn as nn import torch.nn.parallel as dp # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal...
5,731
35.74359
81
py
pytorch
pytorch-main/test/jit/test_remove_mutation.py
# Owner(s): ["oncall: jit"] import os import sys import torch from torch.testing import FileCheck from typing import List # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_util...
10,439
32.461538
92
py
pytorch
pytorch-main/test/jit/test_typing.py
# Owner(s): ["oncall: jit"] import os import sys import torch from torch.testing._internal.jit_utils import JitTestCase, make_global from torch.testing._internal.common_utils import IS_WINDOWS from collections import namedtuple from typing import List, Tuple, Dict, NamedTuple # Make the helper files in test/ importa...
21,036
31.666149
123
py
pytorch
pytorch-main/test/jit/test_device_analysis.py
# Owner(s): ["oncall: jit"] from itertools import product import unittest import torch from torch.testing._internal.common_utils import TEST_CUDA from torch.testing._internal.jit_utils import JitTestCase from torch.jit._passes._property_propagation import apply_input_props_using_example try: from torchvision imp...
11,567
33.224852
92
py
pytorch
pytorch-main/test/jit/test_sparse.py
# Owner(s): ["oncall: jit"] import io import torch import unittest from torch.testing._internal.common_utils import IS_WINDOWS, TEST_MKL from torch.testing._internal.jit_utils import JitTestCase class TestSparse(JitTestCase): def test_freeze_sparse_coo(self): class SparseTensorModule(torch.nn.Module): ...
3,696
29.303279
78
py
pytorch
pytorch-main/test/jit/test_recursive_script.py
# Owner(s): ["oncall: jit"] import os import sys import types import typing import typing_extensions from typing import List, Dict, Optional, Tuple import torch import torch.nn as nn from torch import Tensor from torch.testing import FileCheck from collections import OrderedDict # Make the helper files in test/ impo...
21,776
28.349057
128
py
pytorch
pytorch-main/test/jit/test_ignorable_args.py
# Owner(s): ["oncall: jit"] import os import sys import torch from torch._C import parse_ir from torch.testing import FileCheck # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit...
2,371
42.127273
98
py
pytorch
pytorch-main/test/jit/test_union.py
# Owner(s): ["oncall: jit"] import io import os import sys import torch from torch.testing import FileCheck from enum import Enum from textwrap import dedent from typing import Dict, List, Optional, Tuple, Union # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.re...
35,963
34.607921
99
py
pytorch
pytorch-main/test/jit/test_module_apis.py
# Owner(s): ["oncall: jit"] import torch import os import sys from torch.testing._internal.jit_utils import JitTestCase from typing import Dict, Any, List # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) if _...
5,202
39.333333
82
py
pytorch
pytorch-main/test/jit/test_hooks_modules.py
# Owner(s): ["oncall: jit"] import torch from typing import List, Tuple class SubmoduleNoForwardInputs(torch.nn.Module): def __init__(self, name): super().__init__() self.name = name def forward(self): assert self.name == "inner_mod_name" class ModuleNoForwardInputs(torch.nn.Module...
18,131
33.211321
88
py
pytorch
pytorch-main/test/jit/test_hash.py
# Owner(s): ["oncall: jit"] import os import sys import torch from typing import Tuple, List # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase if __n...
3,797
32.610619
114
py
pytorch
pytorch-main/test/jit/test_exception.py
# Owner(s): ["oncall: jit"] from torch.testing._internal.common_utils import TestCase import torch from torch import nn r""" Test TorchScript exception handling. """ class TestException(TestCase): def test_pyop_exception_message(self): class Foo(torch.jit.ScriptModule): def __init__(self): ...
5,567
30.636364
117
py
pytorch
pytorch-main/test/jit/test_script_profile.py
# Owner(s): ["oncall: jit"] import os import sys import torch from torch import nn # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase if __name__ == '_...
3,111
26.785714
81
py
pytorch
pytorch-main/test/jit/test_unsupported_ops.py
# Owner(s): ["oncall: jit"] import os import sys import torch import unittest # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase if __name__ == '__main...
3,097
37.246914
90
py
pytorch
pytorch-main/test/jit/test_enum.py
# Owner(s): ["oncall: jit"] import os import sys import torch from torch.testing import FileCheck from enum import Enum from typing import Any, List # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch...
10,170
26.865753
114
py
pytorch
pytorch-main/test/jit/test_await.py
# Owner(s): ["oncall: jit"] import io import torch from torch.testing._internal.jit_utils import JitTestCase from torch.testing._internal.jit_utils import make_global from typing import List, Optional, Tuple from torch import Tensor from torch._awaits import _Await as Await class TestAwait(JitTestCase): def test...
12,016
30.05168
96
py
pytorch
pytorch-main/test/jit/test_peephole.py
# Owner(s): ["oncall: jit"] import torch from torch.testing._internal.jit_utils import JitTestCase, RUN_CUDA, _inline_everything from torch import nn from torch.testing import FileCheck from typing import Callable, List import unittest if __name__ == '__main__': raise RuntimeError("This test file is not meant to...
29,562
32.518141
92
py
pytorch
pytorch-main/test/jit/test_aten_pow.py
# Owner(s): ["oncall: jit"] import torch from torch.testing._internal.common_utils import TestCase class TestAtenPow(TestCase): def test_aten_pow_zero_negative_exponent(self): ''' 1. Testing a = int, b = int ''' @torch.jit.script def fn_int_int(a: int, b: int): ...
4,381
46.11828
79
py
pytorch
pytorch-main/test/jit/test_attr.py
# Owner(s): ["oncall: jit"] from torch.testing import FileCheck from torch.testing._internal.jit_utils import JitTestCase import torch if __name__ == '__main__': raise RuntimeError("This test file is not meant to be run directly, use:\n\n" "\tpython test/test_jit.py TESTNAME\n\n" ...
1,398
34.871795
102
py
pytorch
pytorch-main/test/jit/test_dce.py
# Owner(s): ["oncall: jit"] import torch from torch.testing import FileCheck from torch.testing._internal.jit_utils import JitTestCase, make_global class TestDCE(JitTestCase): def test_setattr_no_aliasdb(self): class Net(torch.nn.Module): def __init__(self): super().__init__()...
1,239
25.382979
70
py
pytorch
pytorch-main/test/jit/test_ivalue.py
# Owner(s): ["oncall: jit"] import os import sys import torch # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase if __name__ == "__main__": raise R...
713
24.5
79
py
pytorch
pytorch-main/test/jit/test_cuda.py
# Owner(s): ["oncall: jit"] import os import sys import gc import unittest import torch from typing import NamedTuple from torch.testing import FileCheck from torch.testing._internal.jit_utils import JitTestCase from torch.testing._internal.common_utils import skipIfRocm, skipCUDANonDefaultStreamIf, NoTest # Make th...
27,089
42.553055
109
py
pytorch
pytorch-main/test/jit/test_with.py
# Owner(s): ["oncall: jit"] import os import sys from typing import Any, List import torch from torch.testing._internal.common_utils import skipIfTorchDynamo from torch.testing._internal.jit_utils import JitTestCase, make_global # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path...
19,657
30.006309
119
py
pytorch
pytorch-main/test/jit/test_list_dict.py
# Owner(s): ["oncall: jit"] import os import sys import inspect import unittest from typing import Any, Dict, List, NamedTuple, Optional, Tuple from textwrap import dedent from collections import OrderedDict from torch import Tensor import torch import torch.nn as nn import types from torch.testing import FileCheck ...
91,253
32.475422
118
py
pytorch
pytorch-main/test/jit/test_freezing.py
# Owner(s): ["oncall: jit"] import io import unittest from itertools import product from typing import Any import torch import torch.nn as nn import torch.nn.functional as F from torch.jit._recursive import wrap_cpp_module from torch.testing import FileCheck from torch.testing._internal.common_quantization import ski...
114,438
36.059262
128
py
pytorch
pytorch-main/test/jit/test_scriptmod_ann.py
# Owner(s): ["oncall: jit"] import os import sys import warnings import torch from typing import List, Dict, Optional # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils im...
9,351
34.831418
87
py
pytorch
pytorch-main/test/jit/test_backend_nnapi.py
# Owner(s): ["oncall: jit"] import os import sys import unittest import torch import torch._C from pathlib import Path from test_nnapi import TestNNAPI # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) if __n...
4,864
42.4375
132
py
pytorch
pytorch-main/test/jit/test_autodiff.py
# Owner(s): ["oncall: jit"] import torch from torch.testing._internal.common_utils import skipIfTorchDynamo from torch.testing._internal.jit_utils import JitTestCase from typing import List @skipIfTorchDynamo() class TestAutodiffJit(JitTestCase): def test_undefined_tensor_lists(self): def fn(tensor_list...
5,115
33.567568
87
py
pytorch
pytorch-main/test/jit/test_tensor_methods.py
# Owner(s): ["oncall: jit"] import os import sys import torch # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal.jit_utils import JitTestCase from torch.testing import FileCheck if...
1,239
30
80
py
pytorch
pytorch-main/test/jit/test_alias_analysis.py
# Owner(s): ["oncall: jit"] from torch.testing._internal.jit_utils import JitTestCase from torch._C import parse_ir import torch if __name__ == '__main__': raise RuntimeError("This test file is not meant to be run directly, use:\n\n" "\tpython test/test_jit.py TESTNAME\n\n" ...
3,490
36.138298
103
py
pytorch
pytorch-main/test/jit/test_graph_rewrite_passes.py
# Owner(s): ["oncall: jit"] from torch.testing._internal.jit_utils import JitTestCase import torch import torch._C from torch.testing import FileCheck class TestGraphRewritePasses(JitTestCase): def test_fuse_linear(self): class FunctionalLinear(torch.nn.Module): def __init__(self, weight, bia...
2,227
34.935484
81
py
pytorch
pytorch-main/test/jit/test_dtype_analysis.py
# Owner(s): ["oncall: jit"] from itertools import product from typing import Tuple from unittest.case import expectedFailure import torch from torch import complex32, float32, float64, int32, int64 from torch.jit._passes import _property_propagation from torch.testing._internal.common_methods_invocations import ( ...
13,270
33.559896
97
py
pytorch
pytorch-main/test/jit/test_batch_mm.py
# Owner(s): ["oncall: jit"] import torch from torch.testing import FileCheck from torch.testing._internal.jit_utils import JitTestCase if __name__ == "__main__": raise RuntimeError( "This test file is not meant to be run directly, use:\n\n" "\tpython test/test_jit.py TESTNAME\n\n" "instead...
10,140
33.848797
86
py
pytorch
pytorch-main/test/jit/test_symbolic_shape_analysis.py
# Owner(s): ["oncall: jit"] import operator import unittest from textwrap import dedent import torch from torch import nn from torch.testing import FileCheck from torch.testing._internal.common_methods_invocations import sample_inputs_cat_concat from torch.testing._internal.common_utils import make_tensor from torch....
27,271
42.705128
128
py
pytorch
pytorch-main/test/jit/test_isinstance.py
# Owner(s): ["oncall: jit"] import os import sys import torch import warnings from typing import List, Any, Dict, Tuple, Optional # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.testing._internal....
11,135
33.37037
87
py
pytorch
pytorch-main/test/jit/test_tracer.py
# Owner(s): ["oncall: jit"] import unittest import io import os import sys import copy import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable, Function from torch.testing import FileCheck # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os...
90,096
33.599462
123
py
pytorch
pytorch-main/test/jit/xnnpack/test_xnnpack_delegate.py
# Owner(s): ["oncall: jit"] import unittest import torch import torch._C torch.ops.load_library("//caffe2:xnnpack_backend") class TestXNNPackBackend(unittest.TestCase): def test_xnnpack_constant_data(self): class Module(torch.nn.Module): def __init__(self): super().__init__()...
5,568
29.767956
99
py
pytorch
pytorch-main/test/jit/_imported_class_test/foo.py
import torch from . import bar # This file contains definitions of script classes. # They are used by test_jit.py to test ScriptClass imports @torch.jit.script # noqa: B903 class FooSameName: def __init__(self, x): self.x = x self.nested = bar.FooSameName(x)
282
22.583333
58
py
pytorch
pytorch-main/test/jit/_imported_class_test/bar.py
import torch # This file contains definitions of script classes. # They are used by test_jit.py to test ScriptClass imports @torch.jit.script # noqa: B903 class FooSameName: # noqa: B903 def __init__(self, y): self.y = y
237
22.8
58
py
pytorch
pytorch-main/test/jit/_imported_class_test/very/very/nested.py
import torch # This file contains definitions of script classes. # They are used by test_jit.py to test ScriptClass imports @torch.jit.script # noqa: B903 class FooUniqueName: # noqa: B903 def __init__(self, y): self.y = y
239
23
58
py
pytorch
pytorch-main/test/jit/fixtures_srcs/test_upgrader_models_generation.py
# Owner(s): ["oncall: mobile"] import torch from test.jit.fixtures_srcs.generate_models import ALL_MODULES from torch.testing._internal.common_utils import TestCase, run_tests class TestUpgraderModelGeneration(TestCase): def test_all_modules(self): for a_module, expect_operator in ALL_MODULES.items(): ...
776
36
92
py
pytorch
pytorch-main/test/jit/fixtures_srcs/generate_models.py
import io import logging import sys import zipfile from pathlib import Path from typing import Set import torch # Use asterisk symbol so developer doesn't need to import here when they add tests for upgraders. from test.jit.fixtures_srcs.fixtures_src import * # noqa: F403 from torch.jit.mobile import _load_for_lite_i...
8,892
38.878924
126
py
pytorch
pytorch-main/test/jit/fixtures_srcs/fixtures_src.py
import torch from typing import Union class TestVersionedDivTensorExampleV7(torch.nn.Module): def forward(self, a, b): result_0 = a / b result_1 = torch.div(a, b) result_2 = a.div(b) return result_0, result_1, result_2 class TestVersionedLinspaceV7(torch.nn.Module): def forward...
1,860
31.086207
103
py
pytorch
pytorch-main/test/onnx/test_export_modes.py
# Owner(s): ["module: onnx"] import io import os import shutil import sys import tempfile import torch import torch.nn as nn from torch.autograd import Variable from torch.onnx import OperatorExportTypes # Make the helper files in test/ importable pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(_...
4,490
28.94
79
py
pytorch
pytorch-main/test/onnx/test_custom_ops.py
# Owner(s): ["module: onnx"] import onnx_test_common import pytorch_test_common import torch import torch.utils.cpp_extension from torch.onnx import symbolic_helper from torch.testing._internal import common_utils class TestCustomAutogradFunction(pytorch_test_common.ExportTestCase): opset_version = 9 keep_in...
3,970
31.818182
84
py
pytorch
pytorch-main/test/onnx/test_fx_op_consistency.py
# Owner(s): ["module: onnx"] """Test consistency between the output values of torch.onnx FX exported operators and torch operators given the same inputs. Usage: pytest test/onnx/test_op_consistency.py To run tests on a specific operator (e.g. torch.ceil): pytest test/onnx/test_op_consistency.py -k ceil...
21,222
32.527646
115
py
pytorch
pytorch-main/test/onnx/test_fx_to_onnx.py
# Owner(s): ["module: onnx"] from __future__ import annotations import tempfile import onnx import pytest import pytorch_test_common import torch from torch import nn from torch._subclasses import fake_tensor from torch.nn import functional as F from torch.onnx import dynamo_export, ExportOptions from torch.onnx._int...
14,238
37.174263
92
py
pytorch
pytorch-main/test/onnx/pytorch_test_common.py
# Owner(s): ["module: onnx"] from __future__ import annotations import functools import os import random import sys import unittest from typing import Optional import numpy as np import packaging.version import torch from torch.autograd import function from torch.onnx._internal import diagnostics from torch.testing....
9,485
27.65861
97
py
pytorch
pytorch-main/test/onnx/test_models_quantized_onnxruntime.py
# Owner(s): ["module: onnx"] import os import unittest import onnx_test_common import parameterized import PIL import torch import torchvision from torch import nn def _get_test_image_tensor(): data_dir = os.path.join(os.path.dirname(__file__), "assets") img_path = os.path.join(data_dir, "grace_hopper_517x...
3,322
32.908163
94
py
pytorch
pytorch-main/test/onnx/test_pytorch_jit_onnx.py
# Owner(s): ["module: onnx"] import onnxruntime import pytorch_test_common import torch from pytorch_test_common import skipIfNoCuda from torch.onnx import verification from torch.testing._internal import common_utils def _jit_graph_to_onnx_model(graph, operator_export_type, opset_version): r""" This functio...
5,934
30.737968
121
py
pytorch
pytorch-main/test/onnx/debug_embed_params.py
import sys import caffe2.python.onnx.backend as c2 import onnx import pytorch_test_common import torch import torch.jit from torch.autograd import Variable torch.set_default_tensor_type("torch.FloatTensor") try: import torch except ImportError: print("Cannot import torch, hence caffe2-torch test will not run...
1,535
26.927273
79
py
pytorch
pytorch-main/test/onnx/test_pytorch_onnx_onnxruntime_cuda.py
# Owner(s): ["module: onnx"] import unittest import onnx_test_common import onnxruntime # noqa: F401 import parameterized import torch from pytorch_test_common import ( skipIfNoBFloat16Cuda, skipIfNoCuda, skipIfUnsupportedMinOpsetVersion, skipScriptTest, ) from test_pytorch_onnx_onnxruntime import ...
4,879
30.082803
87
py
pytorch
pytorch-main/test/onnx/test_fx_type_promotion.py
# Owner(s): ["module: onnx"] import pytorch_test_common from torch.onnx._internal.fx.passes import type_promotion from torch.testing._internal import common_utils class TestGeneratedTypePromotionRuleSet(common_utils.TestCase): @pytorch_test_common.skip_in_ci( "Reduce noise in CI. " "The test serv...
857
30.777778
86
py
pytorch
pytorch-main/test/onnx/verify.py
import difflib import io import numpy as np import onnx import onnx.helper import torch import torch.jit import torch.onnx def colonize(msg, sep=": "): if not msg: return "" else: return msg + sep class Errors: """ An error-collecting object which supports error recovery. It i...
20,957
38.543396
101
py
pytorch
pytorch-main/test/onnx/test_pytorch_onnx_shape_inference.py
# Owner(s): ["module: onnx"] import io import numpy as np import onnx import pytorch_test_common import torch from pytorch_test_common import skipIfUnsupportedMinOpsetVersion from torch.onnx import _constants, symbolic_helper from torch.onnx._internal import jit_utils from torch.testing._internal import common_utils ...
20,682
41.210204
96
py
pytorch
pytorch-main/test/onnx/test_onnxscript_runtime.py
# Owner(s): ["module: onnx"] """Test the support on onnxscript in PyTorch-ONNX converter with onnxruntime.""" from typing import List import onnx_test_common import onnxscript import torch from onnxscript.onnx_types import FLOAT from torch.onnx._internal import jit_utils from torch.testing._internal import common_uti...
4,514
34.273438
96
py
pytorch
pytorch-main/test/onnx/test_pytorch_onnx_no_runtime.py
# Owner(s): ["module: onnx"] """Tests for onnx export that don't run the exported model.""" from __future__ import annotations import contextlib import io import itertools import unittest import unittest.mock import warnings from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union import numpy as n...
46,948
34.976245
106
py
pytorch
pytorch-main/test/onnx/test_fx_passes.py
# Owner(s): ["module: onnx"] import torch import torch._dynamo import torch.fx from torch._custom_op import impl as custom_op from torch.onnx._internal.fx.passes import _utils as pass_utils from torch.testing._internal import common_utils class TestFxPasses(common_utils.TestCase): def test_set_node_name_correctl...
3,554
32.224299
88
py
pytorch
pytorch-main/test/onnx/pytorch_helper.py
import io import onnx import torch.onnx from caffe2.python.core import BlobReference, Net from caffe2.python.onnx.backend import Caffe2Backend _next_idx = 0 # Clone net takes a dict instead of a lambda # It should probably take a lambda, it is more flexible # We fake dict here class _FakeDict: def __init__(sel...
3,381
35.365591
84
py
pytorch
pytorch-main/test/onnx/test_fx_to_onnx_with_onnxruntime.py
# Owner(s): ["module: onnx"] from __future__ import annotations import itertools import os import tempfile import unittest from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Type import onnx_test_common import onnxruntime # type: ignore[import] import parameterized import pytorch_test_common im...
35,308
36.642857
115
py
pytorch
pytorch-main/test/onnx/test_models.py
# Owner(s): ["module: onnx"] import unittest import pytorch_test_common import torch from model_defs.dcgan import _netD, _netG, bsz, imgsz, nz, weights_init from model_defs.emb_seq import EmbeddingNetwork1, EmbeddingNetwork2 from model_defs.mnist import MNIST from model_defs.op_test import ConcatNet, DummyNet, FakeQ...
10,947
37.146341
94
py
pytorch
pytorch-main/test/onnx/test_operators.py
# Owner(s): ["module: onnx"] """ Usage: python test/onnx/test_operators.py [--no-onnx] [--produce-onnx-test-data] --no-onnx: no onnx python dependency --produce-onnx-test-data: generate onnx test data --accept: accept onnx updates and overwrite models """ import glob import inspect import...
46,661
34.783742
112
py
pytorch
pytorch-main/test/onnx/test_op_consistency.py
# Owner(s): ["module: onnx"] """Test consistency between the output values of torch.onnx exported operators and torch operators given the same inputs. Usage: pytest test/onnx/test_op_consistency.py To run tests on a specific operator (e.g. torch.ceil): pytest test/onnx/test_op_consistency.py -k ceil ...
12,867
38.351682
127
py
pytorch
pytorch-main/test/onnx/test_models_onnxruntime.py
# Owner(s): ["module: onnx"] import os import unittest from collections import OrderedDict from typing import List, Mapping, Tuple import onnx_test_common import parameterized import PIL import pytorch_test_common import test_models import torch import torchvision from pytorch_test_common import skipIfUnsupportedMin...
14,313
31.311512
88
py
pytorch
pytorch-main/test/onnx/test_utility_funs.py
# Owner(s): ["module: onnx"] import copy import functools import io import re import warnings from typing import Callable import onnx import parameterized import pytorch_test_common import torch import torch.onnx import torch.utils.cpp_extension import torchvision from autograd_helper import CustomFunction as Custom...
71,755
35.911523
124
py
pytorch
pytorch-main/test/onnx/test_onnxscript_no_runtime.py
# Owner(s): ["module: onnx"] """Test the support on onnxscript in PyTorch-ONNX converter.""" import io from typing import List import onnx import onnxscript import torch from onnxscript.onnx_types import FLOAT from torch.onnx._internal import jit_utils from torch.testing._internal import common_utils class TestONNX...
6,170
36.858896
90
py
pytorch
pytorch-main/test/onnx/autograd_helper.py
# Owner(s): ["module: onnx"] import torch # Autograd funtion that is a replica of the autograd funtion in # test_utility_funs.py (test_autograd_module_name) class CustomFunction(torch.autograd.Function): @staticmethod def forward(ctx, input): ctx.save_for_backward(input) return input.clamp(mi...
518
24.95
63
py
pytorch
pytorch-main/test/onnx/test_autograd_funs.py
# Owner(s): ["module: onnx"] import pytorch_test_common import torch from onnx_test_common import run_model_test from torch.onnx import OperatorExportTypes from torch.onnx._globals import GLOBALS from torch.onnx.utils import _model_to_graph from torch.testing._internal import common_utils class TestAutogradFuns(pyt...
6,730
30.600939
73
py
pytorch
pytorch-main/test/onnx/onnx_test_common.py
# Owner(s): ["module: onnx"] from __future__ import annotations import contextlib import copy import dataclasses import io import os import unittest import warnings from typing import ( Any, Callable, Collection, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Un...
22,216
31.914074
124
py
pytorch
pytorch-main/test/onnx/test_symbolic_helper.py
# Owner(s): ["module: onnx"] """Unit tests on `torch.onnx.symbolic_helper`.""" import torch from torch.onnx import symbolic_helper from torch.onnx._globals import GLOBALS from torch.testing._internal import common_utils class TestHelperFunctions(common_utils.TestCase): def setUp(self): super().setUp() ...
2,292
30.847222
85
py
pytorch
pytorch-main/test/onnx/test_pytorch_onnx_onnxruntime.py
# Owner(s): ["module: onnx"] from __future__ import annotations import io import itertools import os import unittest from collections import OrderedDict from typing import Dict, List, Optional, Tuple, Type, Union import numpy as np import onnx import onnx_test_common import parameterized import torch import torchvis...
474,004
34.265605
119
py
pytorch
pytorch-main/test/onnx/test_verification.py
# Owner(s): ["module: onnx"] import contextlib import io import tempfile import unittest import numpy as np import onnx import parameterized import pytorch_test_common import torch from packaging import version from torch.onnx import _constants, _experimental, verification from torch.testing._internal import common_...
9,900
32.449324
103
py
pytorch
pytorch-main/test/onnx/test_onnx_opset.py
# Owner(s): ["module: onnx"] import io import itertools import onnx import pytorch_test_common import torch import torch.onnx from torch.nn import Module from torch.onnx import producer_name, producer_version from torch.onnx._globals import GLOBALS from torch.testing._internal import common_utils def check_onnx_op...
17,504
31.476809
87
py
pytorch
pytorch-main/test/onnx/model_defs/word_language_model.py
# The model is from here: # https://github.com/pytorch/examples/blob/master/word_language_model/model.py from typing import Optional, Tuple import torch import torch.nn as nn from torch import Tensor class RNNModel(nn.Module): """Container module with an encoder, a recurrent module, and a decoder.""" def...
4,642
33.649254
110
py
pytorch
pytorch-main/test/onnx/model_defs/rnn_model_with_packed_sequence.py
from torch import nn from torch.nn.utils import rnn as rnn_utils class RnnModelWithPackedSequence(nn.Module): def __init__(self, model, batch_first): super().__init__() self.model = model self.batch_first = batch_first def forward(self, input, *args): args, seq_lengths = args[...
1,626
34.369565
84
py
pytorch
pytorch-main/test/onnx/model_defs/lstm_flattening_result.py
from torch import nn from torch.nn.utils.rnn import PackedSequence class LstmFlatteningResult(nn.LSTM): def forward(self, input, *fargs, **fkwargs): output, (hidden, cell) = nn.LSTM.forward(self, input, *fargs, **fkwargs) return output, hidden, cell class LstmFlatteningResultWithSeqLength(nn.Mod...
1,503
31
88
py
pytorch
pytorch-main/test/onnx/model_defs/emb_seq.py
import torch.nn as nn class EmbeddingNetwork1(nn.Module): def __init__(self, dim=5): super().__init__() self.emb = nn.Embedding(10, dim) self.lin1 = nn.Linear(dim, 1) self.seq = nn.Sequential( self.emb, self.lin1, ) def forward(self, input): ...
658
24.346154
81
py
pytorch
pytorch-main/test/onnx/model_defs/squeezenet.py
import torch import torch.nn as nn import torch.nn.init as init class Fire(nn.Module): def __init__(self, inplanes, squeeze_planes, expand1x1_planes, expand3x3_planes): super().__init__() self.inplanes = inplanes self.squeeze = nn.Conv2d(inplanes, squeeze_planes, kernel_size=1) sel...
3,539
38.333333
85
py
pytorch
pytorch-main/test/onnx/model_defs/dcgan.py
import torch import torch.nn as nn # configurable bsz = 64 imgsz = 64 nz = 100 ngf = 64 ndf = 64 nc = 3 # custom weights initialization called on netG and netD def weights_init(m): classname = m.__class__.__name__ if classname.find("Conv") != -1: m.weight.data.normal_(0.0, 0.02) elif classname.fi...
2,951
31.8
82
py
pytorch
pytorch-main/test/onnx/model_defs/op_test.py
# Owner(s): ["module: onnx"] import torch import torch.nn as nn class DummyNet(nn.Module): def __init__(self, num_classes=1000): super().__init__() self.features = nn.Sequential( nn.LeakyReLU(0.02), nn.BatchNorm2d(3), nn.AvgPool2d(kernel_size=3, stride=2, paddi...
1,171
21.538462
78
py
pytorch
pytorch-main/test/onnx/model_defs/super_resolution.py
import torch.nn as nn import torch.nn.init as init class SuperResolutionNet(nn.Module): def __init__(self, upscale_factor): super().__init__() self.relu = nn.ReLU() self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2)) self.conv2 = nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1)) ...
1,051
34.066667
77
py
pytorch
pytorch-main/test/onnx/model_defs/srresnet.py
import math from torch import nn from torch.nn import init def _initialize_orthogonal(conv): prelu_gain = math.sqrt(2) init.orthogonal(conv.weight, gain=prelu_gain) if conv.bias is not None: conv.bias.data.zero_() class ResidualBlock(nn.Module): def __init__(self, n_filters): super(...
3,228
32.989474
86
py
pytorch
pytorch-main/test/onnx/model_defs/mnist.py
import torch.nn as nn import torch.nn.functional as F class MNIST(nn.Module): def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 10, kernel_size=5) self.conv2 = nn.Conv2d(10, 20, kernel_size=5) self.conv2_drop = nn.Dropout2d() self.fc1 = nn.Linear(320, 50) ...
672
29.590909
67
py
pytorch
pytorch-main/test/onnx/dynamo/test_exporter_api.py
# Owner(s): ["module: onnx"] import io import logging import os import onnx import torch from beartype import roar from torch.onnx import dynamo_export, ExportOptions, ExportOutput from torch.onnx._internal import exporter, io_adapter from torch.onnx._internal.diagnostics import infra from torch.onnx._internal.exporte...
6,822
37.988571
88
py
pytorch
pytorch-main/test/onnx/dynamo/test_registry_dispatcher.py
# Owner(s): ["module: onnx"] """Unit tests for the internal registration wrapper module.""" from __future__ import annotations import logging import operator from typing import TypeVar, Union import onnxscript # type: ignore[import] import torch import torch.fx from onnxscript import BFLOAT16, DOUBLE, FLOAT, FLOAT1...
17,619
36.172996
113
py
pytorch
pytorch-main/test/onnx/internal/test_beartype.py
# Owner(s): ["module: onnx"] """Unit tests for the internal beartype wrapper module.""" import unittest from torch.onnx._internal import _beartype from torch.testing._internal import common_utils def beartype_installed(): try: import beartype # noqa: F401 except ImportError: return False ...
2,783
31.752941
83
py
pytorch
pytorch-main/test/onnx/internal/test_diagnostics.py
# Owner(s): ["module: onnx"] from __future__ import annotations import contextlib import dataclasses import io import logging import typing import unittest from typing import AbstractSet, Protocol, Tuple import torch from torch.onnx import errors from torch.onnx._internal import diagnostics from torch.onnx._internal....
10,932
32.64
106
py
pytorch
pytorch-main/test/onnx/internal/test_registraion.py
# Owner(s): ["module: onnx"] """Unit tests for the internal registration wrapper module.""" from typing import Sequence from torch.onnx import errors from torch.onnx._internal import registration from torch.testing._internal import common_utils @common_utils.instantiate_parametrized_tests class TestGlobalHelpers(co...
9,767
37.305882
84
py
pytorch
pytorch-main/test/functorch/test_memory_efficient_fusion.py
# Owner(s): ["module: functorch"] import torch import torch.nn as nn import torch.fx as fx from functorch import make_fx from torch.nn import functional as F from functorch.compile import memory_efficient_fusion from torch._functorch.compile_utils import fx_graph_cse from torch.testing._internal.common_utils import Te...
11,537
30.016129
124
py
pytorch
pytorch-main/test/functorch/test_logging.py
# Owner(s): ["module: dynamo"] import torch from torch.testing._internal.logging_utils import LoggingTestCase, make_logging_test from torch._functorch.aot_autograd import aot_function from torch._functorch.compilers import nop import logging class TestAOTLogging(LoggingTestCase): @make_logging_test(aot=logging.DE...
608
28
84
py
pytorch
pytorch-main/test/functorch/attn_positional.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn import math class BertSelfAttention(nn.Module): def __init__(self, hidden_s...
4,406
45.882979
115
py
pytorch
pytorch-main/test/functorch/test_parsing.py
# Owner(s): ["module: functorch"] """Adapted from https://github.com/arogozhnikov/einops/blob/230ac1526c1f42c9e1f7373912c7f8047496df11/tests/test_parsing.py. MIT License Copyright (c) 2018 Alex Rogozhnikov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated d...
10,492
41.828571
123
py
pytorch
pytorch-main/test/functorch/test_vmap.py
# Owner(s): ["module: functorch"] # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import OrderedDict from unittest.case import skipIf from torch.tes...
211,235
39.794902
119
py
pytorch
pytorch-main/test/functorch/test_aotdispatch.py
# Owner(s): ["oncall: pt2"] # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Union, Callable, List, Any, Optional, Dict from unittest.mock imp...
135,053
43.928144
279
py
pytorch
pytorch-main/test/functorch/xfail_suggester.py
import re import torch """ Instructions: 1. pytest -n 8 test/test_vmap.py test/test_ops.py test/test_aotdispatch.py > result.txt 2. python test/xfail_suggester.py """ with open('result.txt') as f: lines = f.readlines() failed = [line for line in lines if line.startswith('FAILED')] p = re.compile('FAILED test/te...
3,756
24.732877
87
py
pytorch
pytorch-main/test/functorch/test_minifier.py
# Owner(s): ["module: functorch"] import torch from functorch.compile import minifier from torch._functorch.compile_utils import get_placeholders, get_outputs from functorch import make_fx from torch.testing._internal.common_utils import TestCase, run_tests class TestMinifier(TestCase): def test_has_mul_minifier...
3,557
29.410256
86
py