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/package/test_mangling.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO from torch.package import PackageExporter, PackageImporter from torch.package._mangling import ( demangle, get_mangle_prefix, is_mangled, PackageMangler, ) from torch.testing._internal.common_utils import run_tests try: from .common im...
3,770
32.371681
89
py
pytorch
pytorch-main/test/package/test_repackage.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO from torch.package import PackageExporter, PackageImporter, sys_importer from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except ImportError: # Support the case where we run this file directly. ...
1,361
27.978723
80
py
pytorch
pytorch-main/test/package/test_analyze.py
# Owner(s): ["oncall: package/deploy"] import torch from torch.package import analyze from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except ImportError: # Support the case where we run this file directly. from common import PackageTestCase class TestA...
719
23
75
py
pytorch
pytorch-main/test/package/test_load_bc_packages.py
# Owner(s): ["oncall: package/deploy"] from pathlib import Path from unittest import skipIf from torch.package import PackageImporter from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests try: from .common import PackageTestCase except ImportError: # Support the case where we r...
1,762
32.903846
88
py
pytorch
pytorch-main/test/package/test_dependency_hooks.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO from torch.package import PackageExporter from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except ImportError: # Support the case where we run this file directly. from common import PackageTes...
3,969
31.276423
95
py
pytorch
pytorch-main/test/package/test_importer.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO import torch from torch.package import ( Importer, OrderedImporter, PackageExporter, PackageImporter, sys_importer, ) from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except Import...
5,638
33.808642
87
py
pytorch
pytorch-main/test/package/test_glob_group.py
# Owner(s): ["oncall: package/deploy"] from typing import Iterable from torch.package import GlobGroup from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except ImportError: # Support the case where we run this file directly. from common import PackageTest...
4,364
35.375
87
py
pytorch
pytorch-main/test/package/test_dependency_api.py
# Owner(s): ["oncall: package/deploy"] import importlib from io import BytesIO from sys import version_info from textwrap import dedent from unittest import skipIf import torch.nn from torch.package import EmptyMatchError, Importer, PackageExporter, PackageImporter from torch.package.package_exporter import Packagin...
13,677
34.619792
121
py
pytorch
pytorch-main/test/package/test_directory_reader.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: package/deploy"] import os import zipfile from sys import version_info from tempfile import TemporaryDirectory from textwrap import dedent from unittest import skipIf import torch from torch.package import PackageExporter, PackageImporter from torch.testing._internal.comm...
10,586
35.888502
111
py
pytorch
pytorch-main/test/package/test_misc.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: package/deploy"] import inspect import os import platform import sys from io import BytesIO from pathlib import Path from textwrap import dedent from unittest import skipIf from torch.package import is_from_package, PackageExporter, PackageImporter from torch.package.pack...
12,025
33.36
103
py
pytorch
pytorch-main/test/package/test_save_load.py
# Owner(s): ["oncall: package/deploy"] import pickle from io import BytesIO from textwrap import dedent from torch.package import PackageExporter, PackageImporter, sys_importer from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except ImportError: # Support th...
9,489
34.543071
95
py
pytorch
pytorch-main/test/package/test_digraph.py
# Owner(s): ["oncall: package/deploy"] from torch.package._digraph import DiGraph from torch.testing._internal.common_utils import run_tests try: from .common import PackageTestCase except ImportError: # Support the case where we run this file directly. from common import PackageTestCase class TestDiGra...
3,717
27.166667
88
py
pytorch
pytorch-main/test/package/test_package_script.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO from textwrap import dedent from unittest import skipIf import torch from torch.package import PackageExporter, PackageImporter from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests try: from .common import PackageTestCa...
28,074
35.086118
88
py
pytorch
pytorch-main/test/package/test_resources.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: package/deploy"] from io import BytesIO from sys import version_info from textwrap import dedent from unittest import skipIf from torch.package import PackageExporter, PackageImporter from torch.testing._internal.common_utils import run_tests try: from .common import...
5,505
35.463576
87
py
pytorch
pytorch-main/test/package/common.py
import os import sys from tempfile import NamedTemporaryFile import torch.package.package_exporter from torch.testing._internal.common_utils import IS_WINDOWS, TestCase class PackageTestCase(TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._temporary_files = ...
1,288
29.690476
78
py
pytorch
pytorch-main/test/package/generate_bc_packages.py
from pathlib import Path import torch from torch.fx import symbolic_trace from torch.package import PackageExporter from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE packaging_directory = f"{Path(__file__).parent}/package_bc" torch.package.package_exporter._gate_torchscript_serialization = Fal...
1,405
37
87
py
pytorch
pytorch-main/test/package/test_package_fx.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO import torch from torch.fx import Graph, GraphModule, symbolic_trace from torch.package import ( ObjMismatchError, PackageExporter, PackageImporter, sys_importer, ) from torch.testing._internal.common_utils import run_tests try: from ....
6,059
30.5625
85
py
pytorch
pytorch-main/test/package/test_model.py
# Owner(s): ["oncall: package/deploy"] from io import BytesIO from textwrap import dedent from unittest import skipIf import torch from torch.package import PackageExporter, PackageImporter, sys_importer from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests try: from torchvision.mo...
7,386
36.120603
107
py
pytorch
pytorch-main/test/package/package_d/imports_indirectly.py
import torch from .subpackage_0 import important_string class ImportsIndirectlyFromSubPackage(torch.nn.Module): key = important_string def forward(self, inp): return torch.sum(inp)
202
15.916667
55
py
pytorch
pytorch-main/test/package/package_d/imports_directly.py
import torch from .subpackage_0.subsubpackage_0 import important_string class ImportsDirectlyFromSubSubPackage(torch.nn.Module): key = important_string def forward(self, inp): return torch.sum(inp)
219
17.333333
58
py
pytorch
pytorch-main/test/package/package_c/test_module.py
# Owner(s): ["oncall: package/deploy"] import torch try: from torchvision.models import resnet18 class TorchVisionTest(torch.nn.Module): def __init__(self): super().__init__() self.tvmod = resnet18() def forward(self, x): x = a_non_torch_leaf(x, x) ...
429
17.695652
43
py
pytorch
pytorch-main/test/package/test_trace_dep/__init__.py
import torch import yaml class SumMod(torch.nn.Module): def forward(self, inp): return torch.sum(inp)
116
13.625
30
py
pytorch
pytorch-main/test/package/package_a/use_torch_package_importer.py
try: import torch_package_importer # noqa: F401 except ImportError: pass
82
15.6
47
py
pytorch
pytorch-main/test/package/package_a/test_nn_module.py
# Owner(s): ["oncall: package/deploy"] import torch class TestNnModule(torch.nn.Module): def __init__(self, nz=6, ngf=9, nc=3): super().__init__() self.main = torch.nn.Sequential( # input is Z, going into a convolution torch.nn.ConvTranspose2d(nz, ngf * 8, 4, 1, 0, bias=Fa...
1,233
35.294118
76
py
pytorch
pytorch-main/test/package/package_a/std_sys_module_hacks.py
import os # noqa: F401 import os.path # noqa: F401 import typing # noqa: F401 import typing.io # noqa: F401 import typing.re # noqa: F401 import torch class Module(torch.nn.Module): def forward(self): return os.path.abspath("test")
252
18.461538
38
py
pytorch
pytorch-main/test/package/package_a/test_all_leaf_modules_tracer.py
# Owner(s): ["oncall: package/deploy"] from torch.fx import Tracer class TestAllLeafModulesTracer(Tracer): def is_leaf_module(self, m, qualname): return True
173
18.333333
42
py
pytorch
pytorch-main/test/package/package_a/test_module.py
# Owner(s): ["oncall: package/deploy"] import torch from torch.fx import wrap wrap("a_non_torch_leaf") class ModWithSubmod(torch.nn.Module): def __init__(self, script_mod): super().__init__() self.script_mod = script_mod def forward(self, x): return self.script_mod(x) class ModWit...
1,480
21.439394
66
py
pytorch
pytorch-main/test/package/package_a/fake_script_class.py
from typing import Any import torch @torch.jit.script class MyScriptClass: """Intended to be scripted.""" def __init__(self, x): self.foo = x def set_foo(self, x): self.foo = x @torch.jit.script def uses_script_class(x): """Intended to be scripted.""" foo = MyScriptClass(x) ...
707
17.631579
46
py
pytorch
pytorch-main/test/package/package_a/fake_interface.py
import torch from torch import Tensor @torch.jit.interface class ModuleInterface(torch.nn.Module): def one(self, inp1: Tensor, inp2: Tensor) -> Tensor: pass class OrigModule(torch.nn.Module): """A module that implements ModuleInterface.""" def one(self, inp1: Tensor, inp2: Tensor) -> Tensor: ...
1,056
23.581395
63
py
pytorch
pytorch-main/test/package/package_a/use_dunder_package.py
if "__torch_package__" in dir(): def is_from_package(): return True else: def is_from_package(): return False
137
12.8
32
py
pytorch
pytorch-main/test/ao/sparsity/test_structured_sparsifier.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import copy import logging import random import torch from torch import nn from torch.ao.pruning._experimental.pruner import ( SaliencyPruner, LSTMSaliencyPruner, BaseStructuredSparsifier, FakeStructuredSparsity, ) from torch.nn.utils import param...
31,601
33.35
113
py
pytorch
pytorch-main/test/ao/sparsity/test_qlinear_packed_params.py
#!/usr/bin/env python3 # Owner(s): ["oncall: mobile"] import tempfile import torch from torch.ao.nn.sparse.quantized.dynamic.linear import Linear from torch.testing._internal.common_quantization import ( skipIfNoFBGEMM, skipIfNoQNNPACK, ) from torch.testing._internal.common_quantized import ( qengine_is_qn...
10,014
37.079848
124
py
pytorch
pytorch-main/test/ao/sparsity/test_sparsifier.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import itertools import logging import re import torch from torch import nn from torch.ao.pruning import BaseSparsifier, WeightNormSparsifier, FakeSparsity, NearlyDiagonalSparsifier from torch.nn.utils.parametrize import is_parametrized from torch.testing._inte...
19,940
43.117257
123
py
pytorch
pytorch-main/test/ao/sparsity/test_parametrization.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import logging from torch import nn from torch.ao.pruning.sparsifier import utils from torch.nn.utils import parametrize import torch from torch.testing._internal.common_utils import TestCase logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s ...
6,906
44.741722
102
py
pytorch
pytorch-main/test/ao/sparsity/test_kernels.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] from torch.testing._internal.common_utils import run_tests import copy import numpy as np import io import logging from itertools import product import torch import torch.ao.quantization as tq from torch import nn from torch.ao.pruning.sparsifier.utils import ...
12,266
37.697161
103
py
pytorch
pytorch-main/test/ao/sparsity/test_data_sparsifier.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import logging import torch from torch.nn.utils.parametrize import is_parametrized from torch.testing._internal.common_utils import TestCase from typing import Tuple from torch import nn import itertools import math import copy from torch.ao.pruning._experiment...
28,602
47.234401
130
py
pytorch
pytorch-main/test/ao/sparsity/test_activation_sparsifier.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import copy from torch.testing._internal.common_utils import TestCase, skipIfTorchDynamo import logging import torch from torch.ao.pruning._experimental.activation_sparsifier.activation_sparsifier import ActivationSparsifier import torch.nn as nn import torch.nn....
14,796
37.939474
119
py
pytorch
pytorch-main/test/ao/sparsity/test_composability.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import logging import torch import torch.ao.quantization as tq from torch import nn from torch.ao import pruning from torch.testing._internal.common_utils import TestCase from torch.ao.quantization.quantize_fx import prepare_fx, convert_fx, convert_to_reference...
25,228
42.200342
109
py
pytorch
pytorch-main/test/ao/sparsity/test_sparsity_utils.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import logging import torch from torch.ao.pruning.sparsifier.utils import ( fqn_to_module, get_arg_info_from_tensor_fqn, module_to_fqn, ) from torch.testing._internal.common_quantization import ( ConvBnReLUModel, ConvModel, FunctionalLi...
5,778
37.271523
91
py
pytorch
pytorch-main/test/ao/sparsity/test_scheduler.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] from torch import nn from torch.ao.pruning import WeightNormSparsifier from torch.ao.pruning import BaseScheduler, LambdaSL, CubicSL from torch.testing._internal.common_utils import TestCase import warnings class ImplementedScheduler(BaseScheduler): def g...
7,018
37.779006
103
py
pytorch
pytorch-main/test/ao/sparsity/test_data_scheduler.py
# -*- coding: utf-8 -*- # Owner(s): ["module: unknown"] import logging import warnings from torch.testing._internal.common_utils import TestCase from torch import nn import torch from typing import Tuple import copy from torch.ao.pruning._experimental.data_sparsifier import DataNormSparsifier from torch.ao.pruning._e...
6,423
39.402516
112
py
pytorch
pytorch-main/test/dynamo/test_decorators.py
# Owner(s): ["module: dynamo"] import os import unittest.mock as mock from unittest.mock import patch import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.exc import IncorrectUsage def my_custom_function(x): return x + 1 class DecoratorTests(torch._dynamo.test_case.TestC...
7,817
27.742647
93
py
pytorch
pytorch-main/test/dynamo/test_functions.py
# Owner(s): ["module: dynamo"] # flake8: noqa import collections import functools import inspect import itertools import operator import unittest from dataclasses import dataclass, field from typing import Any, Dict, List, NamedTuple from unittest.mock import patch import torch import torch._dynamo.test_case import t...
33,973
24.391629
88
py
pytorch
pytorch-main/test/dynamo/test_python_autograd.py
# Owner(s): ["module: dynamo"] from typing import Callable, Dict, List, NamedTuple, Optional import torch import torch._dynamo from torch._dynamo.test_case import run_tests, TestCase from torch._dynamo.testing import CompileCounter, same """ This is an example of a pure-python version of autograd implemented by @zde...
8,831
29.666667
89
py
pytorch
pytorch-main/test/dynamo/test_logging.py
# Owner(s): ["module: dynamo"] import atexit import contextlib import functools import logging import os import re import unittest.mock import torch import torch._dynamo.test_case import torch._dynamo.testing import torch.distributed as dist from torch.nn.parallel import DistributedDataParallel as DDP from torch.test...
14,314
31.983871
87
py
pytorch
pytorch-main/test/dynamo/test_skip_non_tensor.py
# Owner(s): ["module: dynamo"] from unittest.mock import patch import torch import torch._dynamo import torch._dynamo.test_case from torch._dynamo.testing import CompileCounter class SkipNonTensorTests(torch._dynamo.test_case.TestCase): def test_add_tensor1(self): def fn(a, b): return a + b ...
2,634
22.114035
76
py
pytorch
pytorch-main/test/dynamo/test_autograd_function.py
# Owner(s): ["module: dynamo"] import math import unittest import torch import torch._dynamo.test_case import torch._dynamo.testing class CustomFunc1(torch.autograd.Function): @staticmethod def forward(ctx, foo): return foo + foo @staticmethod def backward(ctx, grad_output): return...
10,721
28.866295
77
py
pytorch
pytorch-main/test/dynamo/test_repros.py
""" PYTEST_DONT_REWRITE (prevents pytest from rewriting assertions, which interferes with test_rewrite_assert_with_msg and test_rewrite_assert_without_msg) """ # Owner(s): ["module: dynamo"] import collections import contextlib import copy import functools import inspect import itertools import random import unittest i...
113,214
32.036183
117
py
pytorch
pytorch-main/test/dynamo/test_aot_autograd.py
# Owner(s): ["module: dynamo"] from unittest.mock import patch import torch import torch._dynamo import torch._dynamo.test_case from torch._dynamo.testing import CompileCounter, expectedFailureDynamic, rand_strided from torch.testing._internal.common_utils import compare_equal_outs_and_grads def maybe_dupe_op(x): ...
25,344
34.055325
104
py
pytorch
pytorch-main/test/dynamo/test_global.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.testing import same try: from . import utils except ImportError: import utils class Pair: # noqa: B903 def __init__(self, x, y): self.x = x self.y = y def Foo(): ...
6,485
26.956897
70
py
pytorch
pytorch-main/test/dynamo/test_export_mutations.py
# Owner(s): ["module: dynamo"] import unittest import torch import torch._dynamo.test_case import torch._dynamo.testing from torch.testing._internal.common_utils import IS_FBCODE class MutationExportTests(torch._dynamo.test_case.TestCase): def check_failure_on_export(self, mod, *args): with self.assertRa...
4,632
33.066176
80
py
pytorch
pytorch-main/test/dynamo/test_ctx_manager.py
# Owner(s): ["module: dynamo"] import unittest import torch import torch._dynamo.test_case import torch._dynamo.testing import torch.onnx.operators from torch._dynamo.testing import same from torch.nn import functional as F from torch.testing._internal.common_cuda import ( PLATFORM_SUPPORTS_FUSED_SDPA, SM80O...
26,765
35.615595
93
py
pytorch
pytorch-main/test/dynamo/test_profiler.py
# Owner(s): ["module: dynamo"] from unittest.mock import patch import torch import torch._dynamo.test_case import torch._dynamo.testing import torch._dynamo.utils from torch._dynamo.utils import dynamo_timed class DynamoProfilerTests(torch._dynamo.test_case.TestCase): def test_dynamo_timed_profiling_isolated(s...
2,633
29.275862
85
py
pytorch
pytorch-main/test/dynamo/test_dynamic_shapes.py
# Owner(s): ["module: dynamo"] import unittest from torch._dynamo import config from torch._dynamo.testing import make_test_cls_with_patches try: from . import ( test_aot_autograd, test_ctx_manager, test_export, test_functions, test_higher_order_ops, test_misc, ...
1,925
23.379747
74
py
pytorch
pytorch-main/test/dynamo/test_input_attr_tracking.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.testing import CompileCounter class TestInputAttrTracking(torch._dynamo.test_case.TestCase): def test_tensor_property_on_tensor(self): def fn(x): retu...
13,564
35.465054
121
py
pytorch
pytorch-main/test/dynamo/test_backends.py
# Owner(s): ["module: dynamo"] import functools import unittest import torch import torch._dynamo import torch._dynamo.test_case from torch._dynamo.backends.debugging import ExplainWithBackend from torch._dynamo.backends.onnxrt import has_onnxruntime from torch._dynamo.backends.tvm import has_tvm from torch._dynamo.t...
7,415
30.159664
114
py
pytorch
pytorch-main/test/dynamo/test_modules.py
# Owner(s): ["module: dynamo"] import collections import itertools import traceback import types import unittest from copy import deepcopy from functools import partial from typing import Tuple from unittest.mock import patch import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo...
62,101
30.051
89
py
pytorch
pytorch-main/test/dynamo/test_interop.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo.test_case import torch._dynamo.testing import torch.onnx.operators from torch._dynamo.testing import same def fn(a, b): return a + b * 0.67 class InteropTests(torch._dynamo.test_case.TestCase): def _common(self, fn): inputs = [torch.r...
1,015
25.051282
74
py
pytorch
pytorch-main/test/dynamo/test_config.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.utils import disable_cache_limit # NB: do NOT include this test class in test_dynamic_shapes.py class ConfigTests(torch._dynamo.test_case.TestCase): @disable_cache_limit() def test_no_a...
2,208
32.469697
73
py
pytorch
pytorch-main/test/dynamo/test_minifier.py
# Owner(s): ["module: dynamo"] import functools import unittest import torch._dynamo from torch._dynamo.test_minifier_common import MinifierTestBase requires_cuda = functools.partial( unittest.skipIf, not torch.cuda.is_available(), "requires cuda" ) class MinifierTests(MinifierTestBase): # Test that compile...
7,508
33.131818
105
py
pytorch
pytorch-main/test/dynamo/test_verify_correctness.py
# Owner(s): ["module: dynamo"] import operator import torch import torch._dynamo import torch._dynamo.config as config import torch._dynamo.test_case from torch._dynamo.testing import same class Seq(torch.nn.Module): def __init__(self): super().__init__() self.layers = torch.nn.Sequential( ...
4,049
27.321678
87
py
pytorch
pytorch-main/test/dynamo/test_misc.py
# Owner(s): ["module: dynamo"] import abc import collections import copy import dataclasses import dis import enum import logging import math import operator import os import sys import traceback import typing import unittest import unittest.mock as mock import warnings import weakref from unittest.mock import patch i...
202,466
31.219446
129
py
pytorch
pytorch-main/test/dynamo/utils.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo g_tensor_export = torch.ones(10) tensor_for_import_testing = torch.ones(10, 10) def inner_func(): return torch.is_grad_enabled() def outer_func(func): def wrapped(*args): a = func(*args) torch._dynamo.graph_break() ...
379
14.833333
46
py
pytorch
pytorch-main/test/dynamo/test_after_aot.py
# Owner(s): ["module: dynamo"] import io import os import shutil import sys import tempfile import unittest import torch._dynamo.test_case from torch._dynamo.repro.after_aot import InputReader, InputWriter, save_graph_repro from torch.fx.experimental.proxy_tensor import make_fx from torch.testing._internal.common_u...
2,811
32.47619
93
py
pytorch
pytorch-main/test/dynamo/test_comptime.py
# Owner(s): ["module: dynamo"] import re import sys from io import StringIO import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.comptime import comptime # Because we don't support free variables in comptime at the moment, # we have to communicate via globals. This also means these tests c...
7,857
24.105431
78
py
pytorch
pytorch-main/test/dynamo/test_subclasses.py
# Owner(s): ["module: dynamo"] import contextlib import torch import torch._dynamo.test_case import torch._dynamo.testing import torch._functorch.config import torch.utils.checkpoint class MockSubclass(torch.Tensor): @classmethod def __torch_function__(cls, func, types, args=(), kwargs=None): if kwa...
3,096
26.651786
81
py
pytorch
pytorch-main/test/dynamo/test_recompiles.py
# Owner(s): ["module: dynamo"] from unittest.mock import patch import torch import torch._dynamo.test_case import torch._dynamo.testing class RecompileTests(torch._dynamo.test_case.TestCase): def test_automatic_dynamic_reduce_recompiles(self): # Test the counterfactual, lots of recompiles without this c...
7,408
33.784038
86
py
pytorch
pytorch-main/test/dynamo/test_unspec.py
# Owner(s): ["module: dynamo"] import math import random import unittest import numpy as np import torch import torch._dynamo.test_case import torch._dynamo.testing import torch.nn.functional as F from torch._dynamo.comptime import comptime from torch._dynamo.testing import same # The intention of this test file is...
10,916
33.009346
114
py
pytorch
pytorch-main/test/dynamo/test_activation_checkpointing.py
# Owner(s): ["module: dynamo"] import functools import unittest from importlib import import_module import torch import torch._dynamo.test_case import torch._functorch.config import torch.utils.checkpoint from torch._dynamo.backends.common import aot_autograd from torch._dynamo.testing import CompileCounterWithBacken...
11,596
33.20944
90
py
pytorch
pytorch-main/test/dynamo/test_replay_record.py
# Owner(s): ["module: dynamo"] import logging import re import shutil import unittest import torch import torch._dynamo.test_case import torch._dynamo.testing try: import dill except ImportError: dill = None requires_dill = unittest.skipIf(dill is None, "requires dill") class ReplayRecordTests(torch._dynam...
5,790
28.850515
86
py
pytorch
pytorch-main/test/dynamo/test_compile.py
# Owner(s): ["module: dynamo"] import inspect import os import tempfile import unittest import torch from torch._dynamo.testing import CompileCounter class ToyModel(torch.nn.Module): def __init__(self): super(ToyModel, self).__init__() self.linear = torch.nn.Linear(10, 10) self.relu = to...
3,301
31.372549
121
py
pytorch
pytorch-main/test/dynamo/test_cudagraphs.py
# Owner(s): ["module: cuda graphs"] import functools import unittest import torch import torch._dynamo import torch._dynamo.config import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.testing import same from torch.testing._internal.common_utils import ( skipIfRocm, TEST_CUDA_GRAPH,...
5,869
25.681818
86
py
pytorch
pytorch-main/test/dynamo/test_export.py
# Owner(s): ["module: dynamo"] """ PYTEST_DONT_REWRITE (prevents pytest from rewriting assertions, which interferes with test_export_persist_assert) """ import functools import inspect import math import operator import unittest from enum import Enum from typing import Dict, List, Sequence from unittest.mock import pat...
107,680
32.163228
207
py
pytorch
pytorch-main/test/dynamo/test_recompile_ux.py
# Owner(s): ["module: dynamo"] import unittest import weakref from unittest.mock import patch import torch import torch._dynamo import torch._dynamo.config import torch._dynamo.test_case import torch._dynamo.testing class RecompileUxTests(torch._dynamo.test_case.TestCase): # TODO(whc) dynamo actually recompiles...
7,955
36.352113
100
py
pytorch
pytorch-main/test/dynamo/test_pre_dispatch.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo import torch._dynamo.test_case class PreDispatchTests(torch._dynamo.test_case.TestCase): def test_no_grad_simple(self): def f(a): b = a.sin() with torch.no_grad(): c = b.cos() return b * c...
2,140
26.805195
67
py
pytorch
pytorch-main/test/dynamo/test_nops.py
# Owner(s): ["module: dynamo"] import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo import eval_frame from torch._dynamo.hooks import Hooks c = 10 def fn1(a, b): return a + b - c def fn2(a, b): x = 0 y = 1 def modify(): nonlocal x x += a + b ...
1,486
19.094595
87
py
pytorch
pytorch-main/test/dynamo/test_subgraphs.py
# Owner(s): ["module: dynamo"] import unittest from unittest.mock import patch import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.testing import unsupported from torch._dynamo.utils import ifdynstaticdefault globalmod = torch.nn.ReLU() def indirectly_unsupported(a, b): ...
16,421
26.415693
87
py
pytorch
pytorch-main/test/dynamo/test_sources.py
# Owner(s): ["module: dynamo"] """ PYTEST_DONT_REWRITE (prevents pytest from rewriting assertions, which interferes with test_export_persist_assert) """ import torch import torch._dynamo import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.source import ( AttrSource, GlobalSource, ...
719
23.827586
80
py
pytorch
pytorch-main/test/dynamo/test_higher_order_ops.py
# Owner(s): ["module: dynamo"] import contextlib import functools import re import unittest import functorch.experimental.control_flow as control_flow import torch import torch._dynamo.config as config import torch._dynamo.test_case import torch._functorch.config import torch.nn as nn import torch.utils.checkpoint f...
68,115
28.875439
100
py
pytorch
pytorch-main/test/dynamo/test_optimizers.py
""" PYTEST_DONT_REWRITE (prevents pytest from rewriting assertions, which interferes with test_adam in OptimizerTests) """ import functools # Owner(s): ["module: dynamo"] import inspect import torch import torch._dynamo import torch._dynamo.test_case import torch._dynamo.testing from torch.nn import Parameter inpu...
4,785
30.486842
91
py
pytorch
pytorch-main/test/dynamo/test_model_output.py
# Owner(s): ["module: dynamo"] import dataclasses import unittest.mock import torch import torch._dynamo.test_case import torch._dynamo.testing from torch._dynamo.testing import same try: from transformers import modeling_outputs from transformers.configuration_utils import PretrainedConfig from transfor...
5,094
29.147929
81
py
pytorch
pytorch-main/test/dynamo/mock_modules/mock_module2.py
# from . import mock_module3 import torch from . import mock_module3 class Class1: def __init__(self, x, y): self.x = x self.y = y def method2(self, x): return mock_module3.method1([], x) def method1(x, y): torch.ones(1, 1) x.append(y) return x
295
13.8
42
py
pytorch
pytorch-main/test/dynamo/mock_modules/mock_module3.py
import torch def method1(x, y): torch.ones(1, 1) x.append(y) return x
84
9.625
20
py
pytorch
pytorch-main/test/fx/test_fx_const_fold.py
# Owner(s): ["module: fx"] import operator import torch import torch.fx from torch.fx.experimental import const_fold from torch.fx.passes.shape_prop import _extract_tensor_metadata, ShapeProp from torch.testing._internal.common_utils import TestCase class TestConstFold(TestCase): def _get_attr(self, node): ...
27,754
38.146685
90
py
pytorch
pytorch-main/test/fx/named_tup.py
from typing import NamedTuple import torch class MyNamedTup(NamedTuple): i : torch.Tensor f : torch.Tensor
117
13.75
29
py
pytorch
pytorch-main/test/fx/quantization.py
r''' **This file is EXPERIMENTAL and is mostly used for testing purposes! Do not rely on it for anything!** ''' from torch.fx import Graph, GraphModule from torch.fx.graph import map_arg from torch.fx.proxy import Proxy import sys import torch from torch.nn.utils import fuse_conv_bn_weights import operator # can be a ...
12,417
37.209231
131
py
pytorch
pytorch-main/test/fx/test_fx_param_shape_control_flow.py
# Owner(s): ["module: fx"] import unittest import torch import torch.fx from torch.testing._internal.common_utils import TestCase class MyModuleBase(torch.nn.Module): def forward(self, x): matrx = self.get_mul_matrix() if self.no_relu(): return torch.mm(x, matrx) else: ...
4,990
30.99359
105
py
pytorch
pytorch-main/test/fx/test_gradual_type.py
# Owner(s): ["module: fx"] import unittest import torch from torch.fx import symbolic_trace from torch.fx.experimental.unify_refinements import infer_symbolic_types from torch.fx.experimental.refinement_types import Equality from torch.fx.tensor_type import TensorType, Dyn, is_consistent, is_more_precise from torch.fx...
38,810
37.733533
111
py
pytorch
pytorch-main/test/fx/test_dce_pass.py
# Owner(s): ["module: fx"] from typing import Set, Type import torch import torch.fx from torch.testing._internal.common_utils import TestCase class TestDCE(TestCase): def _has_nodes_without_users(self, m: torch.fx.GraphModule): for node in m.graph.nodes: if node.is_impure(): ...
5,660
31.164773
87
py
pytorch
pytorch-main/test/fx/test_pass_infra.py
# Owner(s): ["module: fx"] import torch import torch.fx as fx from torch.fx.passes.infra.pass_base import PassBase, PassResult from torch.fx.passes.infra.pass_manager import ( _topological_sort_passes, pass_result_wrapper, PassManager, this_before_that_pass_constraint, ) from torch.testing._internal.c...
7,605
31.784483
131
py
pytorch
pytorch-main/test/fx/test_source_matcher_utils.py
# Owner(s): ["module: fx"] import os import sys import unittest import torch pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch._dynamo.eval_frame import is_dynamo_supported from torch.fx.passes.utils.source_matcher_utils import get_source_par...
6,756
45.280822
130
py
pytorch
pytorch-main/test/fx/test_common_passes.py
# Owner(s): ["oncall: fx"] import torch from torch.testing._internal.common_utils import ( TestCase, parametrize, instantiate_parametrized_tests, run_tests) from torch.fx.experimental.proxy_tensor import make_fx from torch.fx.passes.dialect.common.cse_pass import CSEPass from torch.fx.graph_module import GraphMod...
2,745
21.694215
105
py
pytorch
pytorch-main/test/fx/test_future.py
# Owner(s): ["module: fx"] from __future__ import annotations # type: ignore[attr-defined] import torch import typing from torch.fx import symbolic_trace class A: def __call__(self, x: torch.Tensor): return torch.add(x, x) # No forward references class M1(torch.nn.Module): def forward(self, x: tor...
1,303
24.568627
78
py
pytorch
pytorch-main/test/fx/test_cse_pass.py
# Owner(s): ["oncall: fx"] import torch from torch.testing._internal.common_utils import ( TestCase, run_tests) from torch.fx.experimental.proxy_tensor import make_fx from torch.fx.passes.dialect.common.cse_pass import CSEPass, get_CSE_banned_ops from torch.fx import symbolic_trace import random banned_ops = g...
6,819
28.145299
116
py
pytorch
pytorch-main/test/fx/test_subgraph_rewriter.py
# Owner(s): ["module: fx"] import os import sys import torch from torch.fx import symbolic_trace, subgraph_rewriter from torch.fx.annotate import annotate # Make the helper files in test/ importable from torch.fx.experimental.rewriter import RewritingTracer pytorch_test_dir = os.path.dirname(os.path.dirname(os.path....
31,922
32.115145
121
py
pytorch
pytorch-main/test/fx/test_matcher_utils.py
# Owner(s): ["module: fx"] import os import sys import torch from torch.fx import symbolic_trace from torch.fx.experimental.proxy_tensor import make_fx pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from torch.fx.passes.utils.matcher_utils import Sub...
5,405
42.248
108
py
pytorch
pytorch-main/test/fx/test_z3_gradual_types.py
# Owner(s): ["module: fx"] import operator import unittest from torch.fx import GraphModule, symbolic_trace from torch.fx.experimental.meta_tracer import symbolic_trace as meta_symbolic_trace from torch.fx.experimental.migrate_gradual_types.constraint import BinConstraintT, DVar, TVar, T from torch.fx.experimental.migr...
87,388
36.586667
107
py
pytorch
pytorch-main/scripts/diagnose_protobuf.py
## @package diagnose_protobuf # Module scripts.diagnose_protobuf """Diagnoses the current protobuf situation. Protocol buffer needs to be properly installed for Caffe2 to work, and sometimes it is rather tricky. Specifically, we will need to have a consistent version between C++ and python simultaneously. This is a co...
3,039
32.406593
80
py
pytorch
pytorch-main/scripts/model_zoo/update-caffe2-models.py
#! /usr/bin/env python3 import os import subprocess import sys import tarfile import tempfile from urllib.request import urlretrieve from caffe2.python.models.download import downloadFromURLToFile, getURLFromName, deleteDirectory class SomeClass: # largely copied from # https://github.com/onnx/onnx-caffe2/b...
5,537
33.6125
100
py
pytorch
pytorch-main/scripts/model_zoo/update-models-from-caffe2.py
#! /usr/bin/env python3 import onnx.backend import argparse import caffe2.python.workspace as c2_workspace import glob import json import numpy as np import onnx import caffe2.python.onnx.frontend import caffe2.python.onnx.backend import os import shutil import tarfile import tempfile import boto3 from urllib.reque...
13,354
39.225904
133
py