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/torch/fx/passes/shape_prop.py
import torch import torch.fx import traceback from torch._dispatch.python import enable_python_dispatcher from torch.fx.node import Node, map_aggregate from typing import Any, Tuple, NamedTuple, Optional, Dict from torch.fx._compatibility import compatibility from torch._guards import detect_fake_mode __all__ = ['Ten...
7,103
35.618557
120
py
pytorch
pytorch-main/torch/fx/passes/annotate_getitem_nodes.py
import operator import torch def annotate_getitem_nodes(graph: torch.fx.Graph) -> None: """ Annotate the type of getitem nodes, inferred from the type of sequence node. If sequence node is not annotated with a type, do nothing. Currently support getitem nodes from Tuple, List, and NamedTuple sequence...
1,869
42.488372
99
py
pytorch
pytorch-main/torch/fx/passes/operator_support.py
import abc import typing as t import torch import torch.fx from torch.fx._compatibility import compatibility from .shape_prop import TensorMetadata from .tools_common import get_node_target, CALLABLE_NODE_OPS __all__ = ['OperatorSupportBase', 'OperatorSupport', 'create_op_support', 'chain', 'OpSupports', 'any_chain'...
7,829
34.429864
109
py
pytorch
pytorch-main/torch/fx/passes/param_fetch.py
from torch.fx.graph_module import GraphModule from typing import Any, Callable, Dict, List, Tuple, Type import torch import torch.nn as nn from torch.fx._compatibility import compatibility __all__ = ['default_matching', 'extract_attrs_for_lowering', 'lift_lowering_attrs_to_nodes'] # Matching method matches the attri...
3,527
51.656716
124
py
pytorch
pytorch-main/torch/fx/passes/graph_manipulation.py
from typing import Any, Dict, List, NamedTuple, Optional import torch from torch.fx._compatibility import compatibility from torch.fx.graph import Graph from torch.fx.graph_module import GraphModule from torch.fx.node import ( map_arg, Node, Target, ) from torch.fx.passes.shape_prop import ShapeProp __all...
3,981
34.873874
97
py
pytorch
pytorch-main/torch/fx/passes/tools_common.py
from typing import List, Tuple, Union, Dict, Any, Set, Mapping import collections from dataclasses import dataclass import torch import torch.fx from torch.fx.node import _get_qualified_name from torch.fx._compatibility import compatibility __all__ = ['get_acc_ops_name', 'get_node_target', 'is_node_output_tensor', 'F...
9,570
36.533333
117
py
pytorch
pytorch-main/torch/fx/passes/split_utils.py
from dataclasses import dataclass, field from typing import List, Optional, Dict import torch.fx from torch.fx.graph import map_arg from .tools_common import NodeList from torch.fx._compatibility import compatibility from torch.fx.passes.utils import lift_subgraph_as_module, HolderModule __all__ = ['getattr_recursive...
10,279
35.978417
110
py
pytorch
pytorch-main/torch/fx/passes/fake_tensor_prop.py
from typing import Optional import torch.fx from torch.fx import Node from torch.fx._compatibility import compatibility from torch._subclasses.fake_tensor import FakeTensorMode, FakeTensor from torch.fx.experimental.proxy_tensor import py_sym_types, snapshot_fake from torch.fx.node import map_aggregate __all__ = ['Fa...
2,299
36.096774
114
py
pytorch
pytorch-main/torch/fx/passes/net_min_base.py
import logging from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Tuple import torch import torch.fx from torch.fx._compatibility import compatibility from torch.fx.node import map_arg from .shape_prop import ShapeProp from .split_utils import split_by_tags from .tools_common im...
21,724
34.096931
93
py
pytorch
pytorch-main/torch/fx/passes/graph_drawer.py
import hashlib import torch import torch.fx from typing import Dict, Any, TYPE_CHECKING from torch.fx.node import _get_qualified_name, _format_arg from torch.fx.passes.shape_prop import TensorMetadata from torch.fx._compatibility import compatibility from itertools import chain __all__ = ['FxGraphDrawer'] try: im...
13,744
38.497126
122
py
pytorch
pytorch-main/torch/fx/passes/backends/cudagraphs.py
import torch from torch.fx.passes.infra.partitioner import CapabilityBasedPartitioner from torch.fx.passes.operator_support import OperatorSupport from torch.fx.passes.tools_common import CALLABLE_NODE_OPS from torch.fx.passes.fake_tensor_prop import FakeTensorProp from torch.utils._pytree import tree_map import opera...
2,023
34.508772
98
py
pytorch
pytorch-main/torch/fx/passes/infra/partitioner.py
from typing import Dict, List, Set, Iterable, Sequence, Optional, Deque from torch.fx.passes.utils.fuser_utils import fuse_by_partitions from torch.fx.graph_module import GraphModule from torch.fx.node import Node, _get_qualified_name from torch.fx.passes.operator_support import OperatorSupportBase import logging im...
12,689
44.483871
105
py
pytorch
pytorch-main/torch/fx/passes/infra/pass_base.py
import abc from collections import namedtuple from typing import Optional from torch.fx.graph_module import GraphModule from torch.fx._compatibility import compatibility __all__ = ['PassResult', 'PassBase'] @compatibility(is_backward_compatible=False) class PassResult(namedtuple("PassResult", ["graph_module", "modi...
2,490
31.776316
82
py
pytorch
pytorch-main/torch/fx/passes/infra/pass_manager.py
import inspect import logging from queue import Queue from functools import wraps from typing import Callable, Dict, List import torch.nn as nn from torch.fx.graph_module import GraphModule from torch.fx._compatibility import compatibility from torch.fx.passes.infra.pass_base import PassResult logger = logging.getLog...
10,311
32.921053
126
py
pytorch
pytorch-main/torch/fx/passes/dialect/common/cse_pass.py
from typing import Dict, Tuple, Any import torch from torch.fx.passes.infra.pass_base import PassBase, PassResult from torch.utils._pytree import tree_flatten from torch.fx import GraphModule, Graph from torch.fx import Node aten = torch.ops.aten # stateful ops are banned from CSE rand_ops = {aten.dropout, aten._f...
4,911
42.469027
264
py
pytorch
pytorch-main/torch/fx/passes/utils/source_matcher_utils.py
from dataclasses import dataclass, field from torch.fx.graph import Graph from torch.fx.node import Node from torch.fx._compatibility import compatibility from typing import Dict, List, Any, Type import logging import os __all__ = ['get_source_partitions', 'check_subgraphs_connected', 'SourcePartition'] # Set`PYTORC...
4,136
31.069767
94
py
pytorch
pytorch-main/torch/fx/passes/utils/fuser_utils.py
import copy from queue import SimpleQueue from typing import List, Dict, Tuple import torch.fx from torch.fx.graph_module import GraphModule from torch.fx.graph import Graph from torch.fx.node import Node from torch.fx.passes.tools_common import NodeList, NodeSet, legalize_graph from torch.fx.passes.utils import lift_...
8,620
35.84188
118
py
pytorch
pytorch-main/torch/fx/passes/utils/common.py
from torch.nn import Module from torch.fx.graph_module import GraphModule from torch.fx.graph import Graph from torch.fx.passes.utils.matcher_utils import SubgraphMatcher from torch.fx._compatibility import compatibility __all__ = ['HolderModule', 'lift_subgraph_as_module', 'compare_graphs'] @compatibility(is_backw...
2,817
32.547619
115
py
pytorch
pytorch-main/torch/fx/passes/utils/matcher_utils.py
from dataclasses import dataclass, field from collections import defaultdict import copy import torch from torch.fx.graph import Graph from torch.fx.node import Node from torch.fx._compatibility import compatibility from typing import Dict, List, Set, Any, Union, Tuple import logging import os __all__ = ['SubgraphMatc...
16,427
41.89295
118
py
pytorch
pytorch-main/torch/fft/__init__.py
import sys import torch from torch._C import _add_docstr, _fft # type: ignore[attr-defined] from torch._torch_docs import factory_common_args, common_args __all__ = ['fft', 'ifft', 'fft2', 'ifft2', 'fftn', 'ifftn', 'rfft', 'irfft', 'rfft2', 'irfft2', 'rfftn', 'irfftn', 'hfft', 'ihfft', 'fftfreq...
55,060
39.456282
109
py
pytorch
pytorch-main/.circleci/generate_config_yml.py
#!/usr/bin/env python3 """ This script is the source of truth for config.yml. Please see README.md in this directory for details. """ import os import shutil import sys from collections import namedtuple import cimodel.data.simple.docker_definitions import cimodel.data.simple.mobile_definitions import cimodel.data.s...
6,116
30.209184
109
py
pytorch
pytorch-main/.circleci/cimodel/data/binary_build_definitions.py
from collections import OrderedDict import cimodel.data.simple.util.branch_filters as branch_filters import cimodel.data.binary_build_data as binary_build_data import cimodel.lib.conf_tree as conf_tree import cimodel.lib.miniutils as miniutils class Conf(object): def __init__(self, os, gpu_version, pydistro, parm...
8,602
34.258197
127
py
pytorch
pytorch-main/.circleci/cimodel/data/binary_build_data.py
""" This module models the tree of configuration variants for "smoketest" builds. Each subclass of ConfigNode represents a layer of the configuration hierarchy. These tree nodes encapsulate the logic for whether a branch of the hierarchy should be "pruned". """ from collections import OrderedDict from cimodel.lib.co...
5,595
31.534884
117
py
pytorch
pytorch-main/.circleci/cimodel/data/pytorch_build_data.py
from cimodel.lib.conf_tree import ConfigNode CONFIG_TREE_DATA = [ ] def get_major_pyver(dotted_version): parts = dotted_version.split(".") return "py" + parts[0] class TreeConfigNode(ConfigNode): def __init__(self, parent, node_name, subtree): super().__init__(parent, self.modify_label(node_na...
7,734
25.672414
98
py
pytorch
pytorch-main/.circleci/cimodel/data/pytorch_build_definitions.py
from collections import OrderedDict from dataclasses import dataclass, field from typing import List, Optional import cimodel.data.dimensions as dimensions import cimodel.lib.conf_tree as conf_tree import cimodel.lib.miniutils as miniutils from cimodel.data.pytorch_build_data import CONFIG_TREE_DATA, TopLevelNode from...
14,050
35.496104
116
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/macos_definitions.py
class MacOsJob: def __init__(self, os_version, is_build=False, is_test=False, extra_props=tuple()): # extra_props is tuple type, because mutable data structures for argument defaults # is not recommended. self.os_version = os_version self.is_build = is_build self.is_test = is...
1,703
29.981818
90
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/docker_definitions.py
from collections import OrderedDict from cimodel.lib.miniutils import quote from cimodel.data.simple.util.branch_filters import gen_filter_dict, RC_PATTERN # NOTE: All hardcoded docker image builds have been migrated to GHA IMAGE_NAMES = [ ] # This entry should be an element from the list above # This should contai...
1,481
36.05
79
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/anaconda_prune_defintions.py
from collections import OrderedDict from cimodel.data.simple.util.branch_filters import gen_filter_dict from cimodel.lib.miniutils import quote CHANNELS_TO_PRUNE = ["pytorch-nightly", "pytorch-test"] PACKAGES_TO_PRUNE = "pytorch torchvision torchaudio torchtext ignite torchcsprng" def gen_workflow_job(channel: str...
851
28.37931
81
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/mobile_definitions.py
""" PyTorch Mobile PR builds (use linux host toolchain + mobile build options) """ import cimodel.lib.miniutils as miniutils import cimodel.data.simple.util.branch_filters class MobileJob: def __init__( self, docker_image, docker_requires, variant_parts, ...
1,391
24.777778
93
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/nightly_ios.py
import cimodel.data.simple.ios_definitions as ios_definitions import cimodel.lib.miniutils as miniutils class IOSNightlyJob: def __init__(self, variant, is_full_jit=False, is_upload=False): self.variant = variant self.is_full_jit = is_full_jit ...
2,587
29.093023
92
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/ios_definitions.py
from cimodel.data.simple.util.versions import MultiPartVersion from cimodel.data.simple.util.branch_filters import gen_filter_dict_exclude import cimodel.lib.miniutils as miniutils XCODE_VERSION = MultiPartVersion([12, 5, 1]) class ArchVariant: def __init__(self, name, custom_build_name=""): self.name = ...
3,069
35.987952
101
py
pytorch
pytorch-main/.circleci/cimodel/data/simple/util/docker_constants.py
AWS_DOCKER_HOST = "308535385114.dkr.ecr.us-east-1.amazonaws.com" def gen_docker_image(container_type): return ( "/".join([AWS_DOCKER_HOST, "pytorch", container_type]), f"docker-{container_type}", ) def gen_docker_image_requires(image_name): return [f"docker-{image_name}"] DOCKER_IMAGE_BA...
946
26.852941
80
py
pytorch
pytorch-main/test/test_kernel_launch_checks.py
# Owner(s): ["module: unknown"] from torch.testing._internal.common_utils import TestCase, run_tests from torch.testing._internal.check_kernel_launches import ( check_cuda_kernel_launches, check_code_for_cuda_kernel_launches ) class AlwaysCheckCudaLaunchTest(TestCase): def test_check_code(self): """V...
3,207
38.121951
86
py
pytorch
pytorch-main/test/test_unary_ufuncs.py
# Owner(s): ["module: tests"] import torch import numpy as np import math from numbers import Number import random import unittest from torch import inf, nan from torch.testing._internal.common_utils import ( TestCase, run_tests, torch_to_numpy_dtype_dict, numpy_to_torch_dtype_dict, suppress_warn...
65,544
40.775016
126
py
pytorch
pytorch-main/test/test_bundled_inputs.py
#!/usr/bin/env python3 # Owner(s): ["oncall: mobile"] import io import textwrap from typing import List, Optional, Dict import torch import torch.utils.bundled_inputs from torch.testing._internal.common_utils import TestCase, run_tests def model_size(sm): buffer = io.BytesIO() torch.jit.save(sm, buffer) ...
16,454
36.060811
113
py
pytorch
pytorch-main/test/test_nestedtensor.py
# Owner(s): ["module: nestedtensor"] import unittest from functools import partial import numpy as np import torch import torch.nn from torch.testing._internal.common_device_type import ( dtypes, dtypesIfCUDA, instantiate_device_type_tests, onlyCPU, onlyCUDA, skipMeta, ) from torch.testing._in...
121,490
44.656144
130
py
pytorch
pytorch-main/test/test_matmul_cuda.py
# -*- coding: utf-8 -*- # Owner(s): ["module: linear algebra"] import unittest from functools import partial import torch from torch.testing import make_tensor from torch.testing._internal.common_cuda import SM53OrLater from torch.testing._internal.common_device_type import ( dtypes, instantiate_device_type_t...
7,664
40.657609
104
py
pytorch
pytorch-main/test/test_logging.py
# Owner(s): ["module: unknown"] import torch from torch.testing._internal.common_utils import TestCase, run_tests class LoggingTest(TestCase): def testApiUsage(self): """ This test verifies that api usage logging is not triggered via static initialization. Since it's triggered at first in...
807
34.130435
114
py
pytorch
pytorch-main/test/test_sort_and_select.py
# Owner(s): ["module: tests"] import torch import numpy as np import random from torch import nan from itertools import permutations, product from torch.testing import make_tensor from torch.testing._internal.common_dtype import all_types, all_types_and, floating_types_and, integral_types from torch.testing._interna...
52,100
45.066313
131
py
pytorch
pytorch-main/test/test_functionalization.py
# Owner(s): ["module: codegen"] import torch from contextlib import nullcontext from torch.testing._internal.common_utils import ( TestCase, run_tests, skipIfTorchDynamo, TEST_WITH_TORCHDYNAMO, IS_WINDOWS, xfail_inherited_tests ) from torch.testing._internal.logging_tensor import LoggingTensor, capture_logs fr...
69,427
44.586343
198
py
pytorch
pytorch-main/test/test_masked.py
# Owner(s): ["module: masked operators"] """Tests for masked operations. """ import itertools import torch from typing import List, Any from functools import wraps import unittest from torch.testing._internal.common_utils import skipIfTorchDynamo from torch.testing._internal.common_utils import \ (TestCase, par...
18,650
41.777523
131
py
pytorch
pytorch-main/test/test_decomp.py
# Owner(s): ["module: primTorch", "module: decompositions"] from collections import defaultdict from torch import Tensor import torch.autograd from torch._decomp import decomposition_table from torch.utils._python_dispatch import TorchDispatchMode from torch.utils._pytree import tree_map, tree_flatten, tree_unflatten...
33,090
39.853086
127
py
pytorch
pytorch-main/test/test_functionalization_of_rng_ops.py
# Owner(s): ["oncall: pt2"] import sys import unittest import torch from torch.testing._internal.common_utils import ( TestCase, run_tests, ) from torch.testing._internal.common_device_type import instantiate_device_type_tests, dtypes from functorch.compile import aot_function, nop, min_cut_rematerialization_p...
11,571
31.968661
115
py
pytorch
pytorch-main/test/test_cpp_extensions_aot.py
# Owner(s): ["module: cpp-extensions"] from itertools import repeat import os import re from typing import Union, get_args, get_origin import unittest import torch.testing._internal.common_utils as common from torch.testing._internal.common_utils import IS_WINDOWS, skipIfTorchDynamo from torch.testing._internal.commo...
13,935
38.256338
109
py
pytorch
pytorch-main/test/test_fx_reinplace_pass.py
# Owner(s): ["module: functionalization"] import torch from torch.testing._internal.common_utils import TestCase, run_tests from torch.fx.passes.reinplace import reinplace from torch.fx.experimental.proxy_tensor import make_fx try: from functorch.experimental import functionalize HAS_FUNCTIONALIZATION = True e...
13,704
36.754821
108
py
pytorch
pytorch-main/test/test_cpp_extensions_open_device_registration.py
# Owner(s): ["module: cpp-extensions"] import os import shutil import sys from typing import Union import tempfile import unittest import torch.testing._internal.common_utils as common from torch.testing._internal.common_utils import IS_ARM64 import torch import torch.utils.cpp_extension from torch.utils.cpp_extensio...
20,200
45.43908
126
py
pytorch
pytorch-main/test/test_legacy_vmap.py
# Owner(s): ["module: vmap"] from torch.testing._internal.common_utils import TestCase, run_tests import torch import torch.nn.functional as F from torch import Tensor from torch._vmap_internals import vmap import functools import itertools import warnings from torch.testing._internal.common_device_type import instant...
102,955
40.231878
115
py
pytorch
pytorch-main/test/test_stateless.py
# Owner(s): ["module: nn"] import contextlib import os import re import subprocess import sys import unittest import torch import torch.nn.utils.stateless as stateless from torch.testing._internal.common_cuda import TEST_MULTIGPU from torch.testing._internal.common_utils import run_tests, TestCase, parametrize, insta...
37,109
39.870044
125
py
pytorch
pytorch-main/test/test_pruning_op.py
# Owner(s): ["module: unknown"] import hypothesis.strategies as st from hypothesis import given import numpy as np import torch from torch.testing._internal.common_utils import TestCase, run_tests import torch.testing._internal.hypothesis_utils as hu hu.assert_deadline_disabled() class PruningOpTest(TestCase): ...
3,681
43.361446
108
py
pytorch
pytorch-main/test/test_hub.py
# Owner(s): ["module: hub"] import unittest from unittest.mock import patch import os import tempfile import warnings import torch import torch.hub as hub from torch.testing._internal.common_utils import retry, IS_SANDCASTLE, TestCase def sum_of_state_dict(state_dict): s = 0 for v in state_dict.values(): ...
11,304
42.314176
115
py
pytorch
pytorch-main/test/test_dispatch.py
# Owner(s): ["module: dispatch"] import torch._C as C from torch.testing._internal.common_utils import TestCase, run_tests from torch._python_dispatcher import PythonDispatcher from collections import namedtuple import itertools import os import re import torch.utils.cpp_extension # TODO: Expand the dispatcher API t...
41,564
42.342023
130
py
pytorch
pytorch-main/test/test_binary_ufuncs.py
# Owner(s): ["module: tests"] import torch import numpy as np import itertools from itertools import chain from itertools import product import math import random from numbers import Number import warnings import operator from functools import partial import torch.autograd.forward_ad as fwAD from torch import inf, n...
179,145
39.131272
131
py
pytorch
pytorch-main/test/test_cuda_sanitizer.py
# Owner(s): ["module: cuda"] import sys import textwrap import traceback from typing import List import torch import torch.cuda._sanitizer as csan from torch.cuda._sanitizer import StreamId, DataPtr, EventId from torch.testing._internal.common_utils import TestCase, run_tests, NoTest # We cannot import TEST_CUDA fr...
20,323
39.166008
102
py
pytorch
pytorch-main/test/test_overrides.py
# Owner(s): ["module: __torch_function__"] import torch import numpy as np import inspect import functools import pprint import pickle import collections import unittest from torch.testing._internal.common_utils import TestCase, run_tests, TEST_WITH_CROSSREF from torch.overrides import ( handle_torch_function, ...
53,189
33.696673
114
py
pytorch
pytorch-main/test/test_namedtensor.py
# Owner(s): ["module: named tensor"] import unittest from torch.testing._internal.common_utils import TestCase, run_tests, TEST_NUMPY from torch.testing._internal.common_cuda import TEST_CUDA from torch.testing._internal.common_device_type import get_all_device_types from collections import namedtuple, OrderedDict imp...
82,300
38.913191
124
py
pytorch
pytorch-main/test/test_fx_experimental.py
# Owner(s): ["module: fx"] import math import numbers import operator import pickle import sys import tempfile import unittest from types import BuiltinFunctionType from typing import Callable, Dict, List, NamedTuple, Optional, Tuple, Union import torch import torch.fx.experimental.meta_tracer import torch.fx.experim...
62,779
36.480597
121
py
pytorch
pytorch-main/test/test_cpp_api_parity.py
# Owner(s): ["module: cpp"] import torch # NN tests use double as the default dtype torch.set_default_dtype(torch.double) import os import torch.testing._internal.common_utils as common import torch.testing._internal.common_nn as common_nn from cpp_api_parity.parity_table_parser import parse_parity_tracker_table fro...
2,869
44.555556
103
py
pytorch
pytorch-main/test/test_functional_autograd_benchmark.py
# Owner(s): ["module: autograd"] from torch.testing._internal.common_utils import TestCase, run_tests, slowTest, IS_WINDOWS import subprocess import tempfile import os import unittest PYTORCH_COLLECT_COVERAGE = bool(os.environ.get("PYTORCH_COLLECT_COVERAGE")) # This is a very simple smoke test for the functional au...
2,574
39.234375
126
py
pytorch
pytorch-main/test/test_jit_fuser_te.py
# Owner(s): ["NNC"] import operator import os import unittest import contextlib import math import torch import torch.nn.functional as F from torch.testing import FileCheck from typing import List import warnings # these needs to be set before `common_utils` # infers `GRAPH_EXECUTOR`. # this file **requires** these s...
107,464
37.162287
123
py
pytorch
pytorch-main/test/test_monitor.py
# Owner(s): ["oncall: r2p"] from torch.testing._internal.common_utils import ( TestCase, run_tests, ) from datetime import timedelta, datetime import tempfile import time from torch.monitor import ( Aggregation, Event, log_event, register_event_handler, unregister_event_handler, Stat, ...
4,481
27.367089
100
py
pytorch
pytorch-main/test/test_bundled_images.py
#!/usr/bin/env python3 # Owner(s): ["oncall: mobile"] import torch import torch.utils.bundled_inputs import io import cv2 from torch.testing._internal.common_utils import TestCase torch.ops.load_library("//caffe2/torch/fb/operators:decode_bundled_image") def model_size(sm): buffer = io.BytesIO() torch.jit.sa...
3,081
36.585366
107
py
pytorch
pytorch-main/test/test_function_schema.py
# Owner(s): ["module: unknown"] import torch from torch.testing._internal.common_utils import TestCase, run_tests from torch._C import parse_schema class TestFunctionSchema(TestCase): def test_serialize_and_deserialize(self): schemas = torch._C._jit_get_all_schemas() # so far we have around 1700 ...
16,485
64.420635
132
py
pytorch
pytorch-main/test/test_cuda_expandable_segments.py
# Owner(s): ["module: cuda"] # run time cuda tests, but with the allocator using expandable segments import os import torch if torch.cuda.is_available(): torch.cuda.memory._set_allocator_settings('expandable_segments:True') current_dir = os.path.dirname(os.path.abspath(__file__)) filepath = os.path.join(current_...
406
30.307692
73
py
pytorch
pytorch-main/test/test_foreach.py
# Owner(s): ["module: mta"] from contextlib import nullcontext from numbers import Number import random import re import torch import unittest import itertools from torch.testing import make_tensor from torch.testing._comparison import default_tolerances from torch.testing._internal.common_utils import \ TestCase...
51,291
49.187867
130
py
pytorch
pytorch-main/test/test_fake_tensor.py
# Owner(s): ["module: meta tensors"] from torch.testing._internal.common_utils import ( TestCase, run_tests, skipIfCrossRef, skipIfRocm, skipIfTorchDynamo, parametrize, instantiate_parametrized_tests) import torch import torch._dynamo import itertools import numpy as np from torch.testing._internal.jit_utils i...
43,472
37.335979
121
py
pytorch
pytorch-main/test/test_dynamic_shapes.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: jit"] import contextlib import copy import itertools import inspect import math import operator import re import sympy import torch import torch.fx import torch.nn.functional as F from torch import sym_int, SymBool, SymFloat, SymInt from torch._C import _disabled_torch_fu...
64,533
34.264481
138
py
pytorch
pytorch-main/test/test_segment_reductions.py
# Owner(s): ["module: scatter & gather ops"] from itertools import product from functools import partial import numpy as np import torch from torch.testing._internal.common_device_type import ( instantiate_device_type_tests, dtypes, ) from torch.testing._internal.common_utils import ( TestCase, run_te...
23,285
39.287197
118
py
pytorch
pytorch-main/test/_test_bazel.py
# Owner(s): ["module: bazel"] """ This test module contains a minimalistic "smoke tests" for the bazel build. Currently it doesn't use any testing framework (i.e. pytest) TODO: integrate this into the existing pytorch testing framework. The name uses underscore `_test_bazel.py` to avoid globbing into other non-bazel...
894
27.870968
107
py
pytorch
pytorch-main/test/test_comparison_utils.py
#!/usr/bin/env python3 # Owner(s): ["module: internals"] import torch from torch.testing._internal.common_utils import TestCase, run_tests class TestComparisonUtils(TestCase): def test_all_equal_no_assert(self): t = torch.tensor([0.5]) torch._assert_tensor_metadata(t, [1], [1], torch.float) d...
1,045
27.27027
69
py
pytorch
pytorch-main/test/test_module_init.py
# Owner(s): ["module: nn"] import inspect import torch from unittest import mock from unittest.mock import MagicMock, patch from torch.testing._internal.common_dtype import floating_types from torch.testing._internal.common_device_type import instantiate_device_type_tests, dtypes from torch.testing._internal.common_qu...
24,936
45.437616
112
py
pytorch
pytorch-main/test/test_mkl_verbose.py
# Owner(s): ["module: unknown"] from torch.testing._internal.common_utils import TestCase, run_tests import os import subprocess import sys class TestMKLVerbose(TestCase): def test_verbose_on(self): num = 0 loc = os.path.dirname(os.path.abspath(__file__)) with subprocess.Popen(f'{sys.execu...
1,464
40.857143
115
py
pytorch
pytorch-main/test/test_prims.py
# Owner(s): ["module: primTorch"] from functools import partial from itertools import product import warnings from warnings import catch_warnings import unittest import torch from torch.testing import make_tensor from torch.testing._internal.common_utils import (parametrize, run_tests, TestCase, TEST_SCIPY, ...
52,009
38.075883
116
py
pytorch
pytorch-main/test/test_proxy_tensor.py
# Owner(s): ["module: ProxyTensor"] from torch.testing._internal.common_utils import TestCase, run_tests, xfail_inherited_tests import torch import unittest import warnings import operator from collections.abc import Iterable from torch.testing._internal.common_device_type import instantiate_device_type_tests from tor...
65,996
38.781193
221
py
pytorch
pytorch-main/test/test_quantization.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: quantization"] import logging from torch.testing._internal.common_utils import run_tests # Quantization core tests. These include tests for # - quantized kernels # - quantized functional operators # - quantized workflow modules # - quantized workflow operators # - quantiz...
8,685
54.679487
112
py
pytorch
pytorch-main/test/test_determination.py
# Owner(s): ["module: ci"] import os import run_test from torch.testing._internal.common_utils import TestCase, run_tests class DummyOptions: verbose = False class DeterminationTest(TestCase): # Test determination on a subset of tests TESTS = [ "test_nn", "test_jit_profiling", ...
4,556
32.021739
102
py
pytorch
pytorch-main/test/test_public_bindings.py
# -*- coding: utf-8 -*- # Owner(s): ["module: autograd"] from torch.testing._internal.common_utils import TestCase, run_tests, IS_JETSON, IS_WINDOWS import pkgutil import torch import sys from typing import Callable import inspect import json import os import unittest # TODO(jansel): we should remove this workaround...
15,150
41.203343
119
py
pytorch
pytorch-main/test/test_schema_check.py
# Owner(s): ["oncall: jit"] import os import sys import torch from torch.utils._pytree import tree_map import unittest from torch.testing._internal.common_utils import run_tests from torch.fx.operator_schemas import normalize_function from torch._subclasses.schema_check_mode import SchemaCheckMode from torch.utils._p...
21,690
41.698819
116
py
pytorch
pytorch-main/test/test_jit_autocast.py
# Owner(s): ["oncall: jit"] import torch from torch.cuda.amp import autocast from typing import Optional, Tuple import unittest from test_jit import JitTestCase from torch.testing._internal.common_cuda import TEST_CUDA from torch.testing._internal.common_utils import run_tests, skipIfTorchDynamo from torch.testing im...
36,464
37.669141
117
py
pytorch
pytorch-main/test/test_modules.py
# Owner(s): ["module: nn"] from itertools import product from inspect import signature, isgenerator from copy import deepcopy import tempfile from operator import methodcaller import torch from torch.testing._internal.common_cuda import with_tf32_off from torch.testing._internal.common_device_type import ( instan...
37,694
49.870445
131
py
pytorch
pytorch-main/test/create_dummy_torchscript_model.py
# Usage: python create_dummy_model.py <name_of_the_file> import sys import torch from torch import nn class NeuralNetwork(nn.Module): def __init__(self): super().__init__() self.flatten = nn.Flatten() self.linear_relu_stack = nn.Sequential( nn.Linear(28 * 28, 512), ...
892
23.135135
56
py
pytorch
pytorch-main/test/test_autocast.py
# Owner(s): ["module: unknown"] import collections import unittest import torch from torch.testing._internal.common_utils import TestCase, run_tests, IS_WINDOWS from torch.testing._internal.autocast_test_lists import AutocastCPUTestLists from torch.utils._python_dispatch import TorchDispatchMode class TestAutocastCP...
10,556
42.089796
113
py
pytorch
pytorch-main/test/simulate_nccl_errors.py
import torch.distributed as c10d import torch import argparse import os import logging logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) if __name__ == "__main__": parser = argparse.ArgumentParser( description='Simple script to simulate NCCL errors. The...
1,628
41.868421
102
py
pytorch
pytorch-main/test/test_datapipe.py
# Owner(s): ["module: dataloader"] import copy import itertools import os import os.path import pickle import pydoc import random import sys import tempfile import warnings from functools import partial from typing import ( Any, Awaitable, Dict, Generic, Iterator, List, Optional, Set, ...
144,393
39.720248
122
py
pytorch
pytorch-main/test/test_tensorexpr_pybind.py
# Owner(s): ["NNC"] import torch import numpy as np import torch._C._te as te from torch.testing._internal.common_utils import run_tests from torch.testing._internal.jit_utils import JitTestCase import unittest LLVM_ENABLED = torch._C._llvm_enabled() def construct_adder(n: int, dtype=torch.float32): A = te.Buf...
16,471
34.196581
109
py
pytorch
pytorch-main/test/test_itt.py
# Owner(s): ["module: intel"] import torch import unittest from torch.testing._internal.common_utils import TestCase, run_tests, load_tests # load_tests from common_utils is used to automatically filter tests for # sharding on sandcastle. This line silences flake warnings load_tests = load_tests @unittest.skipIf(not...
641
29.571429
80
py
pytorch
pytorch-main/test/test_show_pickle.py
# Owner(s): ["oncall: mobile"] import unittest import io import tempfile import torch import torch.utils.show_pickle from torch.testing._internal.common_utils import TestCase, run_tests, IS_WINDOWS class TestShowPickle(TestCase): @unittest.skipIf(IS_WINDOWS, "Can't re-open temp file on Windows") def test_sc...
1,052
27.459459
91
py
pytorch
pytorch-main/test/test_mkldnn_verbose.py
# Owner(s): ["module: unknown"] from torch.testing._internal.common_utils import TestCase, run_tests import os import subprocess import sys class TestMKLDNNVerbose(TestCase): def test_verbose_on(self): num = 0 loc = os.path.dirname(os.path.abspath(__file__)) with subprocess.Popen(f'{sys.ex...
1,482
41.371429
118
py
pytorch
pytorch-main/test/test_package.py
# Owner(s): ["oncall: package/deploy"] from package.test_resources import TestResources # noqa: F401 from package.test_model import ModelTest # noqa: F401 from package.test_dependency_api import TestDependencyAPI # noqa: F401 from package.test_mangling import TestMangling # noqa: F401 from package.test_misc import...
1,353
51.076923
97
py
pytorch
pytorch-main/test/test_type_hints.py
# Owner(s): ["module: typing"] import unittest from torch.testing._internal.common_utils import TestCase, run_tests, set_cwd import tempfile import torch import doctest import os import inspect from pathlib import Path try: import mypy.api HAVE_MYPY = True except ImportError: HAVE_MYPY = False def get_e...
5,064
35.438849
94
py
pytorch
pytorch-main/test/test_sympy_utils.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: pt2"] import itertools import sys import sympy from torch.testing._internal.common_utils import ( instantiate_parametrized_tests, parametrize, run_tests, TestCase, ) from torch.utils._sympy.value_ranges import ValueRangeAnalysis, ValueRanges from torch.uti...
10,038
34.725979
112
py
pytorch
pytorch-main/test/test_futures.py
# Owner(s): ["module: unknown"] import threading import time import torch import unittest from torch.futures import Future from torch.testing._internal.common_utils import IS_WINDOWS, TestCase, TemporaryFileName, run_tests from typing import TypeVar T = TypeVar("T") def add_one(fut): return fut.wait() + 1 cla...
10,488
29.759531
99
py
pytorch
pytorch-main/test/load_torchscript_model.py
import sys import torch if __name__ == '__main__': script_mod = torch.jit.load(sys.argv[1]) mod = torch.load(sys.argv[1] + ".orig") print(script_mod) inp = torch.rand(2, 28 * 28) _ = mod(inp) sys.exit(0)
229
19.909091
44
py
pytorch
pytorch-main/test/test_meta.py
# Owner(s): ["module: primTorch"] import itertools import torch import os from enum import Enum from torch.overrides import resolve_name from torch.utils._pytree import tree_map, tree_flatten, tree_unflatten from torch._subclasses.meta_utils import MetaConverter, assert_metadata_eq import torch.utils._python_dispatch ...
53,095
38.012491
132
py
pytorch
pytorch-main/test/test_metal.py
# Owner(s): ["oncall: mobile"] import torch from torch.nn import functional as F from torch.testing._internal.common_utils import TestCase, run_tests from torch.testing import FileCheck import io class TestMetalRewritePass(TestCase): @staticmethod def validate_transformed_module( # To please flak...
6,650
40.055556
105
py
pytorch
pytorch-main/test/test_jit.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: jit"] import torch # This is how we include tests located in test/jit/... # They are included here so that they are invoked when you call `test_jit.py`, # do not run these test files directly. from jit.test_tracer import TestTracer, TestMixTracingScripting # noqa: F401 f...
574,650
34.345737
132
py
pytorch
pytorch-main/test/test_dlpack.py
# -*- coding: utf-8 -*- # Owner(s): ["module: tests"] import torch from torch.testing import make_tensor from torch.testing._internal.common_utils import TestCase, run_tests, IS_JETSON from torch.testing._internal.common_device_type import ( instantiate_device_type_tests, onlyCUDA, dtypes, skipMeta, skipCUDAIfRocm...
7,928
35.539171
83
py
pytorch
pytorch-main/test/test_torch.py
# -*- coding: utf-8 -*- # Owner(s): ["module: tests"] import torch import torch.utils.data import numpy as np import contextlib import gc import io import inspect import itertools import math import random import re import copy import os import tempfile import unittest import warnings import types import pickle impor...
411,053
43.409464
132
py
pytorch
pytorch-main/test/test_complex.py
# Owner(s): ["module: complex"] import torch from torch.testing._internal.common_device_type import ( instantiate_device_type_tests, dtypes, onlyCPU, ) from torch.testing._internal.common_utils import TestCase, run_tests from torch.testing._internal.common_dtype import complex_types devices = (torch.devic...
9,347
53.348837
131
py
pytorch
pytorch-main/test/test_jit_string.py
# Owner(s): ["oncall: jit"] from test_jit import JitTestCase from torch.testing._internal.common_utils import run_tests from typing import List, Tuple class TestScript(JitTestCase): def test_str_ops(self): def test_str_is(s: str) -> Tuple[bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool]:...
13,131
38.317365
123
py
pytorch
pytorch-main/test/run_test.py
#!/usr/bin/env python3 import argparse import copy import glob import json import os import pathlib import shutil import signal import subprocess import sys import tempfile from datetime import datetime from distutils.version import LooseVersion from typing import Any, cast, Dict, List, Optional, Union import pkg_res...
60,191
34.743468
127
py