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/bottleneck_test/test_cuda.py
# Owner(s): ["module: unknown"] import torch import torch.nn as nn class Model(nn.Module): def __init__(self): super().__init__() self.linear = nn.Linear(20, 20) def forward(self, input): out = self.linear(input[:, 10:30]) return out.sum() def main(): data = torch.randn...
596
18.9
62
py
pytorch
pytorch-main/test/mobile/test_bytecode.py
# Owner(s): ["oncall: mobile"] import fnmatch import io import shutil import tempfile import torch import torch.utils.show_pickle # from torch.utils.mobile_optimizer import optimize_for_mobile from torch.jit.mobile import ( _load_for_lite_interpreter, _get_mobile_model_contained_types, _get_model_bytecode_...
13,952
41.410334
130
py
pytorch
pytorch-main/test/mobile/test_upgrader_codegen.py
# Owner(s): ["oncall: mobile"] from torch.testing._internal.common_utils import TestCase, run_tests from torchgen.operator_versions.gen_mobile_upgraders import ( sort_upgrader, write_cpp, ) from pathlib import Path import tempfile import os from torch.jit.generate_bytecode import generate_upgraders_bytecode ...
1,453
40.542857
115
py
pytorch
pytorch-main/test/mobile/test_upgraders.py
# Owner(s): ["oncall: mobile"] import torch import torch.utils.bundled_inputs import io from torch.jit.mobile import _load_for_lite_interpreter from torch.testing._internal.common_utils import TestCase, run_tests from pathlib import Path from itertools import product pytorch_test_dir = Path(__file__).resolve().paren...
2,494
37.384615
110
py
pytorch
pytorch-main/test/mobile/test_lite_script_type.py
# Owner(s): ["oncall: mobile"] import torch import torch.utils.bundled_inputs import io from typing import Dict, List, NamedTuple import unittest from torch.jit.mobile import _load_for_lite_interpreter from torch.testing._internal.common_utils import TestCase, run_tests from collections import namedtuple class Test...
6,181
33.730337
109
py
pytorch
pytorch-main/test/mobile/test_lite_script_module.py
# Owner(s): ["oncall: mobile"] import torch import torch.utils.bundled_inputs import io from typing import Dict, List import inspect from torch.testing import FileCheck from torch.jit.mobile import _load_for_lite_interpreter, _export_operator_list from torch.testing._internal.common_utils import TestCase, run_tests f...
21,039
36.978339
128
py
pytorch
pytorch-main/test/mobile/test_quantize_fx_lite_script_module.py
# Owner(s): ["oncall: mobile"] import torch import torch.nn as nn import torch.ao.nn.quantized as nnq import torch.utils.bundled_inputs from torch.ao.quantization import ( default_qconfig, float_qparams_weight_only_qconfig, ) # graph mode quantization based on fx from torch.ao.quantization.quantize_fx import ...
3,189
29.673077
82
py
pytorch
pytorch-main/test/mobile/custom_build/prepare_model.py
""" This is a script for end-to-end mobile custom build test purpose. It prepares MobileNetV2 TorchScript model, and dumps root ops used by the model for custom build script to create a tailored build which only contains these used ops. """ import torch import torchvision import yaml # Download and trace the model. m...
1,554
37.875
80
py
pytorch
pytorch-main/test/mobile/model_test/gen_test_model.py
import io import sys import torch import yaml from android_api_module import AndroidAPIModule from builtin_ops import ( TSBuiltinOpsModule, TSCollectionOpsModule, ) from math_ops import ( PointwiseOpsModule, ReductionOpsModule, ComparisonOpsModule, OtherMathOpsModule, SpectralOpsModule, ...
8,392
33.257143
97
py
pytorch
pytorch-main/test/mobile/model_test/sampling_ops.py
import torch # https://pytorch.org/docs/stable/torch.html#random-sampling class SamplingOpsModule(torch.nn.Module): def forward(self): a = torch.empty(3, 3).uniform_(0.0, 1.0) size = (1, 4) weights = torch.tensor([0, 10, 3, 0], dtype=torch.float) return len( # torch.se...
1,002
27.657143
64
py
pytorch
pytorch-main/test/mobile/model_test/quantization_ops.py
import torch import torch.nn as nn class GeneralQuantModule(torch.nn.Module): def __init__(self): super().__init__() self.embedding = torch.ao.nn.quantized.Embedding( num_embeddings=10, embedding_dim=12 ) self.embedding_input = torch.tensor([9, 6, 5, 7, 8, 8, 9, 2, 8]) ...
7,996
35.022523
121
py
pytorch
pytorch-main/test/mobile/model_test/torchvision_models.py
import torch import torchvision from torch.utils.bundled_inputs import augment_model_with_bundled_inputs from torch.utils.mobile_optimizer import optimize_for_mobile class MobileNetV2Module: def getModule(self): model = torchvision.models.mobilenet_v2(pretrained=True) model.eval() example ...
689
30.363636
72
py
pytorch
pytorch-main/test/mobile/model_test/android_api_module.py
from typing import Dict, List, Tuple, Optional import torch from torch import Tensor class AndroidAPIModule(torch.jit.ScriptModule): @torch.jit.script_method def forward(self, input): return None @torch.jit.script_method def eqBool(self, input: bool) -> bool: return input @torch...
3,488
26.690476
82
py
pytorch
pytorch-main/test/mobile/model_test/math_ops.py
# https://pytorch.org/docs/stable/torch.html#math-operations import math import torch class PointwiseOpsModule(torch.nn.Module): def forward(self): return self.pointwise_ops() def pointwise_ops(self): a = torch.randn(4) b = torch.randn(4) t = torch.tensor([-1, -2, 3], dtype=...
16,551
35.619469
110
py
pytorch
pytorch-main/test/mobile/model_test/update_production_ops.py
""" This is a script to aggregate production ops from xplat/pytorch_models/build/all_mobile_model_configs.yaml. Specify the file path in the first argument. The results will be dump to model_ops.yaml """ import sys import yaml root_operators = {} traced_operators = {} kernel_metadata = {} with open(sys.argv[1]) as i...
1,489
40.388889
107
py
pytorch
pytorch-main/test/mobile/model_test/nn_ops.py
import torch import torch.nn as nn import torch.nn.functional as F # https://pytorch.org/docs/stable/nn.html class NNConvolutionModule(torch.nn.Module): def __init__(self): super().__init__() self.input1d = torch.randn(1, 4, 36) self.input2d = torch.randn(1, 4, 30, 10) self.input3d ...
13,222
30.558473
102
py
pytorch
pytorch-main/test/mobile/model_test/tensor_ops.py
import torch class TensorOpsModule(torch.nn.Module): def forward(self): return self.tensor_general_ops() def tensor_general_ops(self): a = torch.randn(4) b = torch.tensor([1.5]) x = torch.ones((2,)) c = torch.randn(4, dtype=torch.cfloat) w = torch.rand(4, 4, 4,...
8,635
31.588679
81
py
pytorch
pytorch-main/test/mobile/model_test/builtin_ops.py
import torch # https://pytorch.org/docs/stable/jit_builtin_functions.html#builtin-functions class TSBuiltinOpsModule(torch.nn.Module): def forward(self): x = torch.tensor(1) y = torch.tensor(0.5) b = float(1) s = "abcde" l = ["1", "2", "test", "a{}b"] d = {"key": ...
2,998
23.991667
78
py
pytorch
pytorch-main/test/mobile/nnc/aot_test_model.py
import torch from torch import nn class NeuralNetwork(nn.Module): def forward(self, x): return torch.add(x, 10) model = NeuralNetwork() script = torch.jit.script(model) torch.jit.save(script, "aot_test_model.pt")
228
18.083333
43
py
pytorch
pytorch-main/test/mobile/lightweight_dispatch/tests_setup.py
import functools import os from io import BytesIO import shutil import sys import torch from torch.jit.mobile import _load_for_lite_interpreter, _export_operator_list _OPERATORS = set() _FILENAMES = [] _MODELS = [] def save_model(cls): """Save a model and dump all the ops""" @functools.wraps(cls) def ...
4,331
29.083333
117
py
pytorch
pytorch-main/test/cpp_extensions/setup.py
import sys import torch.cuda import os from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension from torch.utils.cpp_extension import CUDA_HOME, ROCM_HOME from torch.testing._internal.common_utils import IS_WINDOWS if sys.platform == 'win32': vc_version = os.ge...
3,327
33.666667
90
py
pytorch
pytorch-main/test/cpp_extensions/no_python_abi_suffix_test/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CppExtension setup( name="no_python_abi_suffix_test", ext_modules=[ CppExtension("no_python_abi_suffix_test", ["no_python_abi_suffix_test.cpp"]) ], cmdclass={"build_ext": BuildExtension.with_options(no_python_abi...
338
29.818182
84
py
pytorch
pytorch-main/test/jit_hooks/model.py
import argparse import os import sys import torch # grab modules from test_jit_hooks.cpp pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(pytorch_test_dir) from jit.test_hooks_modules import ( create_forward_tuple_input, create_module_forward_multiple_inputs, crea...
2,879
45.451613
109
py
pytorch
pytorch-main/test/distributions/test_distributions.py
# Owner(s): ["module: distributions"] """ Note [Randomized statistical tests] ----------------------------------- This note describes how to maintain tests in this file as random sources change. This file contains two types of randomized tests: 1. The easier type of randomized test are tests that should always pass ...
260,439
48.288418
123
py
pytorch
pytorch-main/test/distributions/test_constraints.py
# Owner(s): ["module: distributions"] import pytest import torch from torch.distributions import biject_to, constraints, transform_to from torch.testing._internal.common_cuda import TEST_CUDA from torch.testing._internal.common_utils import run_tests EXAMPLES = [ (constraints.symmetric, False, [[2., 0], [2., 2]...
5,723
43.030769
109
py
pytorch
pytorch-main/test/distributions/test_transforms.py
# Owner(s): ["module: distributions"] import io from numbers import Number import pytest import torch from torch.autograd.functional import jacobian from torch.distributions import Dirichlet, Independent, Normal, TransformedDistribution, constraints from torch.distributions.transforms import (AbsTransform, AffineTra...
20,658
40.318
130
py
pytorch
pytorch-main/test/distributions/test_utils.py
# Owner(s): ["module: distributions"] import pytest import torch from torch.distributions.utils import tril_matrix_to_vec, vec_to_tril_matrix from torch.testing._internal.common_utils import run_tests @pytest.mark.parametrize('shape', [ (2, 2), (3, 3), (2, 4, 4), (2, 2, 4, 4), ]) def test_tril_matrix...
638
22.666667
76
py
pytorch
pytorch-main/test/_nvfuser/test_torchscript.py
../../third_party/nvfuser/python_tests/test_torchscript.py
58
58
58
py
pytorch
pytorch-main/test/backends/xeon/test_launch.py
# Owner(s): ["module: intel"] from torch.testing._internal.common_utils import TestCase, run_tests, IS_LINUX import shutil import subprocess import tempfile import unittest @unittest.skipIf(not IS_LINUX, "Only works on linux") class TestTorchrun(TestCase): def setUp(self): self._test_dir = tempfile.mkdtem...
2,312
34.045455
110
py
pytorch
pytorch-main/test/lazy/test_debug_util.py
# Owner(s): ["oncall: jit"] import os import re import tempfile import torch.nn as nn import unittest import torch._lazy import torch._lazy.ts_backend from torch.testing._internal.common_utils import IS_WINDOWS, run_tests, TestCase torch._lazy.ts_backend.init() @unittest.skipIf(IS_WINDOWS, "To be fixed") class Deb...
1,444
31.111111
88
py
pytorch
pytorch-main/test/lazy/test_ts_opinfo.py
# Owner(s): ["oncall: jit"] from typing import Sequence import torch import functools from torch.testing._internal.common_utils import run_tests, TestCase from torch.testing._internal.jit_utils import JitTestCase from torch.testing._internal.common_methods_invocations import op_db from torch.testing._internal.common_...
11,625
35.791139
176
py
pytorch
pytorch-main/test/lazy/test_reuse_ir.py
# Owner(s): ["oncall: jit"] import torch import torch._lazy import torch._lazy.config import torch._lazy.ir_cache import torch._lazy.ts_backend import torch._lazy.metrics as metrics from torch.testing._internal.common_utils import IS_WINDOWS, run_tests, TestCase import os import unittest torch._lazy.ts_backend.init()...
4,665
33.820896
121
py
pytorch
pytorch-main/test/lazy/test_bindings.py
# Owner(s): ["oncall: jit"] import torch._lazy.metrics def test_metrics(): names = torch._lazy.metrics.counter_names() assert len(names) == 0, f"Expected no counter names, but got {names}"
199
24
73
py
pytorch
pytorch-main/test/lazy/test_extract_compiled_graph.py
# Owner(s): ["oncall: jit"] import unittest from torch._lazy.ts_backend import init as init_ts_backend init_ts_backend() from torch._lazy import config from torch._lazy.extract_compiled_graph import extract_compiled_graph import torch from torch import nn import dis import inspect from torch import fx import re from ...
5,869
31.977528
132
py
pytorch
pytorch-main/test/lazy/test_step_closures.py
# Owner(s): ["oncall: jit"] from threading import Event from time import sleep import torch._lazy import torch._lazy.ts_backend from torch.testing._internal.common_utils import run_tests, TestCase torch._lazy.ts_backend.init() class ClosuresTest(TestCase): def test_synchronous(self): flag = Event() ...
2,318
24.206522
81
py
pytorch
pytorch-main/test/lazy/test_meta_kernel.py
# Owner(s): ["oncall: jit"] import torch from torch.testing._internal.common_utils import TestCase import torch._lazy import torch._lazy.ts_backend torch._lazy.ts_backend.init() class TestMetaKernel(TestCase): def test_addmm_invalid_dtype(self): """Tests that the addmm meta kernel returns the correct o...
1,189
33
79
py
pytorch
pytorch-main/test/cpp/api/init_baseline.py
"""Script to generate baseline values from PyTorch initialization algorithms""" import sys import torch HEADER = """ #include <torch/types.h> #include <vector> namespace expected_parameters { """ FOOTER = "} // namespace expected_parameters" PARAMETERS = "inline std::vector<std::vector<torch::Tensor>> {}() {{" I...
2,059
27.219178
90
py
pytorch
pytorch-main/test/cpp/api/optim_baseline.py
"""Script to generate baseline values from PyTorch optimization algorithms""" import argparse import math import sys import torch import torch.optim HEADER = """ #include <torch/types.h> #include <vector> namespace expected_parameters { """ FOOTER = "} // namespace expected_parameters" PARAMETERS = "inline std:...
4,469
33.921875
118
py
pytorch
pytorch-main/test/cpp/jit/tests_setup.py
import sys import os import torch class Setup: def setup(self): raise NotImplementedError() def shutdown(self): raise NotImplementedError() class FileSetup: path = None def shutdown(self): if os.path.exists(self.path): os.remove(self.path) pass cla...
2,569
21.347826
92
py
pytorch
pytorch-main/test/cpp/aot_inductor/test.py
import shutil import torch import torch._dynamo import torch._inductor class Net(torch.nn.Module): def __init__(self): super().__init__() self.fc = torch.nn.Linear(64, 10) def forward(self, x, y): return self.fc(torch.sin(x) + torch.cos(y)) x = torch.randn((32, 64), device="cuda") ...
743
23.8
74
py
pytorch
pytorch-main/test/typing/reveal/namedtuple.py
import torch t = torch.tensor([[3.0, 1.5], [2.0, 1.5]]) t_sort = t.sort() t_sort[0][0, 0] == 1.5 # noqa: B015 t_sort.indices[0, 0] == 1 # noqa: B015 t_sort.values[0, 0] == 1.5 # noqa: B015 reveal_type(t_sort) # E: Tuple[{Tensor}, {Tensor}, fallback=torch.return_types.sort] t_qr = torch.linalg.qr(t) t_qr[0]...
477
28.875
85
py
pytorch
pytorch-main/test/typing/reveal/module_list.py
import torch # ModuleList with elements of type Module class FooModule(torch.nn.Module): pass class BarModule(torch.nn.Module): pass ml: torch.nn.ModuleList = torch.nn.ModuleList([FooModule(), BarModule()]) ml[0].children() == [] # noqa: B015 reveal_type(ml) # E: {ModuleList}
290
21.384615
73
py
pytorch
pytorch-main/test/typing/reveal/torch_optim.py
import torch def foo(opt: torch.optim.Optimizer) -> None: opt.zero_grad() opt_adagrad = torch.optim.Adagrad([torch.tensor(0.0)]) reveal_type(opt_adagrad) # E: {Adagrad} foo(opt_adagrad) opt_adam = torch.optim.Adam([torch.tensor(0.0)], lr=1e-2, eps=1e-6) reveal_type(opt_adam) # E: {Adam} foo(opt_adam)
312
21.357143
67
py
pytorch
pytorch-main/test/typing/reveal/opt_size.py
import torch avg_pool1 = torch.nn.AdaptiveAvgPool2d((1, None)) reveal_type(avg_pool1) # E: {AdaptiveAvgPool2d} avg_pool2 = torch.nn.AdaptiveAvgPool2d((None, 1)) reveal_type(avg_pool2) # E: {AdaptiveAvgPool2d} max_pool1 = torch.nn.AdaptiveMaxPool2d((1, None)) reveal_type(max_pool1) # E: {AdaptiveMaxPool2d} max_pool2...
410
36.363636
49
py
pytorch
pytorch-main/test/typing/reveal/size.py
import torch input = [] input.append(torch.tensor([1.0, 2.0, 3.0, 4.0])) input.append(torch.tensor([[1.0, 2.0, 3.0, 4.0]])) input.append(torch.tensor([[[1.0, 2.0, 3.0, 4.0]]])) reveal_type(input[0].shape[0]) # E: int reveal_type(input[1].shape[1]) # E: int reveal_type(input[2].shape[2]) # E: int
300
32.444444
52
py
pytorch
pytorch-main/test/typing/reveal/tensor_copy.py
import torch t = torch.randn(2, 3) reveal_type(t) # E: {Tensor} u = torch.randn(2, 3) reveal_type(u) # E: {Tensor} t.copy_(u) reveal_type(t) # E: {Tensor} r = (t == u).all() reveal_type(r) # E: {Tensor}
209
16.5
29
py
pytorch
pytorch-main/test/typing/reveal/tensor_constructors.py
# flake8: noqa import torch from torch.testing._internal.common_utils import TEST_NUMPY if TEST_NUMPY: import numpy as np # From the docs, there are quite a few ways to create a tensor: # https://pytorch.org/docs/stable/tensors.html # torch.tensor() reveal_type(torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]])) ...
4,408
37.008621
113
py
pytorch
pytorch-main/test/typing/reveal/tensor_sampling.py
# flake8: noqa import torch # seed reveal_type(torch.seed()) # E: int # manual_seed reveal_type(torch.manual_seed(3)) # E: torch._C.Generator # initial_seed reveal_type(torch.initial_seed()) # E: int # get_rng_state reveal_type(torch.get_rng_state()) # E: {Tensor} # bernoulli reveal_type(torch.bernoulli(torch....
1,481
23.295082
77
py
pytorch
pytorch-main/test/typing/pass/creation_ops.py
# flake8: noqa import torch from torch.testing._internal.common_utils import TEST_NUMPY if TEST_NUMPY: import numpy as np # From the docs, there are quite a few ways to create a tensor: # https://pytorch.org/docs/stable/tensors.html # torch.tensor() torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) torch.tensor(...
3,127
25.285714
104
py
pytorch
pytorch-main/test/typing/pass/math_ops.py
# flake8: noqa import torch import math a = torch.randn(4) b = torch.randn(4) t = torch.tensor([-1, -2, 3], dtype=torch.int8) # abs/absolute torch.abs(torch.tensor([-1, -2, 3])) torch.absolute(torch.tensor([-1, -2, 3])) # acos/arccos torch.acos(a) torch.arccos(a) # acosh/arccosh torch.acosh(a.uniform_(1, 2)) # add...
7,613
22.003021
106
py
pytorch
pytorch-main/test/typing/fail/creation_ops.py
# flake8: noqa import torch torch.tensor([3], dtype='int32') # E: expected "Optional[dtype]" torch.ones(3, dtype='int32') # E: No overload variant of "ones" matches argument types "int", "str" torch.zeros(3, dtype='int32') # E: No overload variant of "zeros" matches argument types "int", "str"
299
41.857143
102
py
pytorch
pytorch-main/test/typing/fail/random.py
# flake8: noqa import torch torch.set_rng_state([1, 2, 3]) # E: Argument 1 to "set_rng_state" has incompatible type "List[int]"; expected "Tensor"
149
29
119
py
pytorch
pytorch-main/test/typing/fail/bitwise_ops.py
# flake8: noqa import torch # binary ops: <<, >>, |, &, ~, ^ a = torch.ones(3, dtype=torch.float64) i = int() i | a # E: Unsupported operand types
151
14.2
38
py
pytorch
pytorch-main/test/autograd/test_fallback.py
# Owner(s): ["module: autograd"] import torch from torch.library import Library from torch.testing._internal.common_utils import ( TestCase, parametrize, instantiate_parametrized_tests, run_tests, ) import contextlib import numpy as np import warnings @contextlib.contextmanager def autograd_fallback_m...
13,694
35.715818
107
py
pytorch
pytorch-main/test/autograd/test_complex.py
# Owner(s): ["module: autograd"] import torch from torch.testing._internal.common_utils import TestCase, run_tests, gradcheck class TestAutogradComplex(TestCase): def test_view_func_for_complex_views(self): # case 1: both parent and child have view_func x = torch.randn(2, 2, 2, dtype=torch.doubl...
3,157
28.792453
102
py
pytorch
pytorch-main/test/autograd/test_functional.py
# Owner(s): ["module: autograd"] import types import unittest import warnings import torch import torch.autograd.functional as autogradF from torch.testing._internal.common_cuda import TEST_CUDA from torch.testing._internal.common_utils import ( TestCase, run_tests, subtest, gradcheck, gradgradcheck, parametrize...
57,504
39.46798
132
py
pytorch
pytorch-main/test/optim/test_lrscheduler.py
# Owner(s): ["module: optimizer", "module: LrScheduler" ] import types import warnings import math import pickle import torch import torch.optim as optim import torch.nn.functional as F from torch.nn import Parameter from torch.optim import Adam, SGD from torch.optim.lr_scheduler import ( LambdaLR, Multiplicat...
83,966
36.77193
117
py
pytorch
pytorch-main/test/optim/test_swa_utils.py
# Owner(s): ["module: optimizer"] import itertools import pickle import torch from torch.optim.swa_utils import AveragedModel, update_bn, get_swa_multi_avg_fn, get_ema_multi_avg_fn from torch.testing._internal.common_utils import ( TestCase, load_tests, parametrize, instantiate_parametrized_tests, ) ...
12,367
38.263492
112
py
pytorch
pytorch-main/test/optim/test_optim.py
# Owner(s): ["module: optimizer"] import math import unittest import functools import itertools from copy import deepcopy import torch import torch.optim as optim from torch.nn import Parameter from torch.optim import Adam, SGD, Optimizer from torch.optim.lr_scheduler import ( StepLR, ConstantLR, LinearLR...
87,710
38.959453
130
py
pytorch
pytorch-main/test/scripts/cuda_memcheck_common.py
# this file contains a simple parser that parses report # from cuda-memcheck class ParseError(Exception): """Whenever the simple parser is unable to parse the report, this exception will be raised""" pass class Report: """A report is a container of errors, and a summary on how many errors are found""" ...
4,516
42.432692
129
py
pytorch
pytorch-main/test/scripts/run_cuda_memcheck.py
#!/usr/bin/env python3 """This script runs cuda-memcheck on the specified unit test. Each test case is run in its isolated process with a timeout so that: 1) different test cases won't influence each other, and 2) in case of hang, the script would still finish in a finite amount of time. The output will be written to ...
6,801
40.730061
121
py
pytorch
pytorch-main/test/distributed/argparse_util_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: distributed"] # 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 os import unittest from argparse import Argumen...
5,373
38.226277
84
py
pytorch
pytorch-main/test/distributed/test_c10d_spawn.py
# Owner(s): ["oncall: distributed"] import os import sys import tempfile import torch import torch.distributed as c10d import torch.multiprocessing as mp from torch.testing._internal.common_distributed import \ MultiProcessTestCase from torch.testing._internal.common_utils import load_tests,\ NO_MULTIPROCESSI...
9,355
35.980237
102
py
pytorch
pytorch-main/test/distributed/test_launcher.py
# Owner(s): ["oncall: distributed"] import os import sys from contextlib import closing import torch.distributed as dist import torch.distributed.launch as launch from torch.distributed.elastic.utils import get_socket_with_port if not dist.is_available(): print("Distributed not available, skipping tests", file=s...
1,403
23.631579
87
py
pytorch
pytorch-main/test/distributed/test_collective_utils.py
# Owner(s): ["oncall: distributed"] from unittest import mock import torch.distributed as c10d from torch.distributed.collective_utils import all_gather, broadcast from torch.testing._internal.common_distributed import MultiProcessTestCase class TestCollectiveUtils(MultiProcessTestCase): def setUp(self): ...
3,666
32.036036
119
py
pytorch
pytorch-main/test/distributed/test_c10d_object_collectives.py
# Owner(s): ["oncall: distributed"] import os import sys from functools import wraps, partial import torch import torch.distributed as dist if not dist.is_available(): print("Distributed not available, skipping tests", file=sys.stderr) sys.exit(0) from torch.testing._internal.common_distributed import ( ...
4,989
29.060241
94
py
pytorch
pytorch-main/test/distributed/test_store.py
# Owner(s): ["oncall: distributed"] import os import socket import sys import tempfile import time from datetime import timedelta from sys import platform import torch import torch.distributed as dist import torch.distributed.rpc as rpc from torch.testing._internal.common_distributed import MultiThreadedTestCase from...
26,235
34.890561
112
py
pytorch
pytorch-main/test/distributed/test_c10d_spawn_ucc.py
# Owner(s): ["oncall: distributed"] import sys import test_c10d_spawn import torch import torch.distributed as c10d from test_c10d_spawn import _torch_dist_nn_available, TestDistributedNNFunctions from torch.testing._internal.common_cuda import TEST_MULTIGPU from torch.testing._internal.common_distributed import ( ...
4,366
37.991071
115
py
pytorch
pytorch-main/test/distributed/test_multi_threaded_pg.py
# Owner(s): ["oncall: distributed"] import os import sys import torch import torch.distributed as dist from torch._C._distributed_c10d import ReduceOp from unittest import skip, SkipTest import operator from functools import reduce import threading import torch.autograd if not dist.is_available(): print("Distribu...
10,459
36.092199
99
py
pytorch
pytorch-main/test/distributed/test_functional_api.py
# Owner(s): ["oncall: distributed"] import os import sys from functools import wraps, partial import torch import torch.distributed as dist import torch.distributed._functional_collectives as ft_c import torch.distributed.distributed_c10d as c10d import torch.distributed._tensor as dt from torch.testing import FileC...
14,155
33.781327
124
py
pytorch
pytorch-main/test/distributed/test_c10d_logger.py
# Owner(s): ["oncall: distributed"] import json import logging import os import re import sys import time from functools import partial, wraps import torch import torch.distributed as dist from torch.distributed.c10d_logger import _c10d_logger, _exception_logger, _time_logger if not dist.is_available(): print("...
5,687
31.135593
110
py
pytorch
pytorch-main/test/distributed/test_c10d_spawn_nccl.py
# Owner(s): ["oncall: distributed"] import sys import test_c10d_spawn import torch import torch.distributed as c10d from test_c10d_spawn import _torch_dist_nn_available, TestDistributedNNFunctions from torch.testing._internal.common_cuda import TEST_MULTIGPU from torch.testing._internal.common_distributed import ( ...
9,028
41.389671
110
py
pytorch
pytorch-main/test/distributed/test_data_parallel.py
# Owner(s): ["oncall: distributed"] import contextlib import io from copy import deepcopy from collections import OrderedDict from itertools import product import functools import torch from torch import nn from torch.cuda.amp import autocast import torch.nn.parallel as dp from torch.testing._internal.common_cuda imp...
36,174
40.014739
118
py
pytorch
pytorch-main/test/distributed/test_c10d_gloo.py
# Owner(s): ["oncall: distributed"] import copy import logging import math import operator import os import random import sys import tempfile from functools import reduce from itertools import groupby import torch import torch.distributed as c10d if not c10d.is_available() or not c10d.is_gloo_available(): print(...
92,835
35.9423
128
py
pytorch
pytorch-main/test/distributed/test_nccl.py
# Owner(s): ["oncall: distributed"] import sys import torch import torch.cuda.nccl as nccl import torch.cuda import torch.distributed as c10d from torch.testing._internal.common_utils import ( TestCase, run_tests, IS_WINDOWS, load_tests, TEST_WITH_ROCM, skip_but_pass_in_sandcastle_if, NoTe...
8,023
32.714286
88
py
pytorch
pytorch-main/test/distributed/test_dynamo_distributed.py
# Owner(s): ["module: dynamo"] import copy import functools from io import StringIO from typing import List import random import unittest from unittest.mock import patch import numpy as np import torch from torch._C import FileCheck import torch._dynamo from torch._dynamo.backends.distributed import DDPOptimizer import...
35,521
39.783008
117
py
pytorch
pytorch-main/test/distributed/test_c10d_spawn_gloo.py
# Owner(s): ["oncall: distributed"] import copy import os import sys import tempfile import test_c10d_spawn import torch import torch.distributed as c10d import torch.nn as nn from test_c10d_spawn import _torch_dist_nn_available, TestDistributedNNFunctions from torch.testing._internal.common_cuda import TEST_CUDA, TE...
11,753
39.954704
124
py
pytorch
pytorch-main/test/distributed/test_distributed_spawn.py
# Owner(s): ["oncall: distributed"] import os import sys import torch import torch.distributed as dist torch.backends.cuda.matmul.allow_tf32 = False if not dist.is_available(): print("Distributed not available, skipping tests", file=sys.stderr) sys.exit(0) from torch.testing._internal.common_utils import r...
1,206
27.069767
108
py
pytorch
pytorch-main/test/distributed/test_c10d_ucc.py
# Owner(s): ["oncall: distributed"] import copy import logging import math import operator import os import random import sys import tempfile from functools import reduce import torch import torch.distributed as c10d if not c10d.is_available() or not c10d.is_ucc_available(): print("c10d UCC not available, skippi...
39,953
34.016652
128
py
pytorch
pytorch-main/test/distributed/test_fake_pg.py
# Owner(s): ["oncall: distributed"] import sys import torch import torch.distributed as dist import torch.nn as nn import unittest import torch.distributed._functional_collectives as funcol from torch.fx.experimental.proxy_tensor import make_fx from torch.testing._internal.distributed.fake_pg import FakeStore from tor...
3,446
30.916667
79
py
pytorch
pytorch-main/test/distributed/test_c10d_common.py
# Owner(s): ["oncall: distributed"] import copy import os import pickle import sys import tempfile import threading import time from contextlib import nullcontext from dataclasses import dataclass from datetime import timedelta from itertools import product from sys import platform from typing import Callable, Dict, O...
78,290
36.281429
121
py
pytorch
pytorch-main/test/distributed/test_pg_wrapper.py
# Owner(s): ["oncall: distributed"] import os import sys from datetime import timedelta import torch import torch.distributed as c10d if not c10d.is_available(): print("c10d not available, skipping tests", file=sys.stderr) sys.exit(0) from test_c10d_common import LOOPBACK from torch.testing._internal.common...
15,935
36.673759
87
py
pytorch
pytorch-main/test/distributed/test_inductor_collectives.py
# Owner(s): ["module: dynamo"] import functools import unittest from unittest.mock import patch import torch from torch._C import FileCheck # for some reason importing functional collectives after dynamo breaks collectives handling! import torch.distributed._functional_collectives as _functional_collectives import torc...
26,229
41.035256
124
py
pytorch
pytorch-main/test/distributed/test_c10d_nccl.py
# Owner(s): ["oncall: distributed"] import copy import math import os import random import re import signal import sys import tempfile import threading from contextlib import contextmanager from datetime import timedelta from itertools import product from unittest import mock import torch import torch.distributed as ...
123,405
37.917061
126
py
pytorch
pytorch-main/test/distributed/test_c10d_pypg.py
# Owner(s): ["oncall: distributed"] import os import torch import torch.distributed as dist from torch.testing._internal.common_utils import ( run_tests, ) from torch.futures import Future import torch.nn as nn from torch.nn.parallel import DistributedDataParallel as DDP import test_c10d_common import weakref fro...
4,309
26.806452
115
py
pytorch
pytorch-main/test/distributed/nn/jit/test_instantiator.py
#!/usr/bin/env python3 # Owner(s): ["oncall: distributed"] import pathlib import sys from typing import Tuple import torch from torch import Tensor, nn import torch.distributed as dist if not dist.is_available(): print("Distributed not available, skipping tests", file=sys.stderr) sys.exit(0) from torch.dist...
3,110
30.744898
86
py
pytorch
pytorch-main/test/distributed/elastic/events/lib_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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.abs import json import logging from dataclasses import asdict ...
5,448
38.485507
103
py
pytorch
pytorch-main/test/distributed/elastic/multiprocessing/redirects_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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 ctypes import os import shutil import sys import tempfi...
4,613
31.723404
80
py
pytorch
pytorch-main/test/distributed/elastic/multiprocessing/tail_log_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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 io import os import shutil import sys import tempfile i...
3,811
31.033613
86
py
pytorch
pytorch-main/test/distributed/elastic/multiprocessing/api_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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 ctypes import multiprocessing import os import shutil i...
32,382
36.350634
103
py
pytorch
pytorch-main/test/distributed/elastic/multiprocessing/errors/api_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] import json import os import shutil import signal import tempfile import unittest from unittest import mock from torch.distributed.elastic.multiprocessing.errors import ( ChildFailedError, ProcessFailure, record, ) from torch.distributed.elastic.multiproc...
8,512
36.668142
97
py
pytorch
pytorch-main/test/distributed/elastic/multiprocessing/errors/error_handler_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] import filecmp import json import os import shutil import tempfile import unittest from unittest.mock import patch from torch.distributed.elastic.multiprocessing.errors.error_handler import ErrorHandler from torch.distributed.elastic.multiprocessing.errors.handlers i...
4,081
36.796296
98
py
pytorch
pytorch-main/test/distributed/elastic/metrics/api_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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.abs import abc import unittest.mock as mock from torch.distrib...
3,396
27.788136
88
py
pytorch
pytorch-main/test/distributed/elastic/timer/file_based_local_timer_test.py
# Owner(s): ["oncall: r2p"] # Copyright (c) Meta Platforms, 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 multiprocessing as mp import signal import time import unittest import u...
10,154
37.033708
121
py
pytorch
pytorch-main/test/distributed/elastic/timer/local_timer_test.py
# Owner(s): ["oncall: r2p"] # 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 multiprocessing as mp import signal import time import unittest import unittes...
11,114
35.804636
91
py
pytorch
pytorch-main/test/distributed/elastic/timer/api_test.py
# Owner(s): ["oncall: r2p"] # 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 unittest import unittest.mock as mock from torch.distributed.elastic.timer im...
2,442
30.727273
85
py
pytorch
pytorch-main/test/distributed/elastic/timer/local_timer_example.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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 logging import multiprocessing as mp import signal impo...
4,116
33.308333
94
py
pytorch
pytorch-main/test/distributed/elastic/utils/logging_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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.distributed.elastic.utils.logging as logging from...
1,070
28.75
71
py
pytorch
pytorch-main/test/distributed/elastic/utils/distributed_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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 multiprocessing as mp import os import socket import s...
4,979
30.923077
117
py
pytorch
pytorch-main/test/distributed/elastic/utils/util_test.py
#!/usr/bin/env python3 # Owner(s): ["oncall: r2p"] # 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 unittest import mock import torch.distributed.elastic.u...
3,687
34.461538
87
py