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/test_type_promotion.py | # Owner(s): ["module: type promotion"]
from functools import wraps
import itertools
import unittest
import torch
from torch.testing._internal.common_utils import (TestCase, run_tests, load_tests, make_tensor,
TEST_NUMPY, set_default_dtype, torch_to_numpy_dtype_dict,
... | 56,098 | 46.825234 | 118 | py |
pytorch | pytorch-main/test/test_fx_passes.py | # Owner(s): ["module: fx.passes"]
from dataclasses import dataclass
import operator
import logging
import sys
import torch
from torch.fx._symbolic_trace import symbolic_trace
from torch.fx.passes.infra.partitioner import CapabilityBasedPartitioner
from torch.fx.passes.operator_support import OperatorSupport
from tor... | 26,539 | 29.788863 | 128 | py |
pytorch | pytorch-main/test/test_tensorboard.py | # Owner(s): ["module: unknown"]
import io
import numpy as np
import os
import shutil
import sys
import tempfile
import unittest
import expecttest
TEST_TENSORBOARD = True
try:
import tensorboard.summary.writer.event_file_writer # noqa: F401
from tensorboard.compat.proto.summary_pb2 import Summary
except Impor... | 37,143 | 39.952591 | 123 | py |
pytorch | pytorch-main/test/test_multiprocessing_spawn.py | # Owner(s): ["module: multiprocessing"]
import os
import pickle
import random
import signal
import sys
import time
import unittest
from torch.testing._internal.common_utils import (TestCase, run_tests, IS_WINDOWS, NO_MULTIPROCESSING_SPAWN)
import torch.multiprocessing as mp
def _test_success_func(i):
pass
def... | 7,473 | 30.940171 | 131 | py |
pytorch | pytorch-main/test/test_xnnpack_integration.py | # Owner(s): ["oncall: mobile"]
import unittest
import torch
import torch.backends.xnnpack
from torch.nn import functional as F
from torch.utils.mobile_optimizer import optimize_for_mobile
from torch.testing import FileCheck
import torch.testing._internal.hypothesis_utils as hu
from torch.testing._internal.common_util... | 53,563 | 46.996416 | 121 | py |
pytorch | pytorch-main/test/test_mps.py | # -*- coding: utf-8 -*-
# Owner(s): ["module: mps"]
import io
import platform
import sys
import math
import random
import unittest
import warnings
import subprocess
import tempfile
import os
import copy
import gc
import torch
import torch.nn as nn
import torch.nn.functional as F
import itertools
from collections impor... | 466,633 | 42.488723 | 132 | py |
pytorch | pytorch-main/test/test_view_ops.py | # Owner(s): ["module: tests"]
import torch
import numpy as np
import unittest
from itertools import product, permutations, combinations
from functools import partial
import random
from torch.testing import make_tensor
from torch.testing._internal.common_utils import (
IS_FBCODE, TestCase, run_tests, suppress_warn... | 78,397 | 41.42316 | 126 | py |
pytorch | pytorch-main/test/test_out_dtype_op.py | # Owner(s): ["module: functorch"]
import unittest
import torch
import torch._dynamo
import torch._export
from torch._higher_order_ops.out_dtype import out_dtype
from torch.fx.experimental.proxy_tensor import make_fx
from torch.testing._internal.common_utils import run_tests, TestCase
from torch.testing import FileChec... | 6,346 | 35.901163 | 124 | py |
pytorch | pytorch-main/test/test_type_info.py | # Owner(s): ["module: typing"]
from torch.testing._internal.common_utils import TestCase, run_tests, TEST_NUMPY, 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
import torch
import unittest
if TES... | 3,128 | 39.636364 | 130 | py |
pytorch | pytorch-main/test/test_jiterator.py | # Owner(s): ["module: cuda"]
import torch
from torch.cuda.jiterator import _create_jit_fn as create_jit_fn
from torch.cuda.jiterator import _create_multi_output_jit_fn as create_multi_output_jit_fn
import sys
from itertools import product
from torch.testing._internal.common_utils import TestCase, parametrize, run_test... | 6,685 | 37.205714 | 123 | py |
pytorch | pytorch-main/test/test_numba_integration.py | # Owner(s): ["module: unknown"]
import unittest
import torch.testing._internal.common_utils as common
from torch.testing._internal.common_utils import TEST_NUMPY
from torch.testing._internal.common_cuda import TEST_NUMBA_CUDA, TEST_CUDA, TEST_MULTIGPU
import torch
if TEST_NUMPY:
import numpy
if TEST_NUMBA_CUDA... | 15,148 | 40.963989 | 113 | py |
pytorch | pytorch-main/test/test_custom_op_testing.py | # Owner(s): ["module: custom-operators"]
from torch.testing._internal.common_utils import * # noqa: F403
from torch.testing._internal.common_device_type import * # noqa: F403
from torch.testing._internal.optests.compile_check import operator_compile_check
from torch.testing._internal.custom_op_db import custom_op_db... | 10,860 | 32.012158 | 122 | py |
pytorch | pytorch-main/test/test_expanded_weights.py | # Owner(s): ["module: nn"]
from dataclasses import dataclass
from functools import partial
from itertools import product, chain
import unittest
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss
from torch.nn.utils._per_sample_grad import call_for_per_sample_grads
... | 41,669 | 51.947903 | 132 | py |
pytorch | pytorch-main/test/test_indexing.py | # Owner(s): ["module: tests"]
import torch
from torch import tensor
import unittest
import warnings
import random
from functools import reduce
import numpy as np
from torch.testing import make_tensor
from torch.testing._internal.common_utils import (
TestCase, run_tests, skipIfTorchDynamo)
from torch.testing._i... | 72,014 | 43.869159 | 124 | py |
pytorch | pytorch-main/test/test_python_dispatch.py | # Owner(s): ["module: __torch_dispatch__"]
import tempfile
import torch
from copy import deepcopy
from torch.library import Library, impl
from torch.fx.experimental.proxy_tensor import ShapeEnv
from torch import SymInt
from torch._subclasses.fake_tensor import FakeTensorMode
from torch.cuda.jiterator import _create_ji... | 112,204 | 37.048491 | 161 | py |
pytorch | pytorch-main/test/test_openmp.py | # Owner(s): ["module: unknown"]
import collections
import unittest
import torch
from torch.testing._internal.common_utils import (
TestCase, run_tests, TEST_WITH_ASAN)
try:
import psutil
HAS_PSUTIL = True
except ImportError:
HAS_PSUTIL = False
device = torch.device('cpu')
class Network(torch.nn.Mo... | 1,987 | 27 | 83 | py |
pytorch | pytorch-main/test/test_static_runtime.py | # Owner(s): ["module: unknown"]
import unittest
from typing import Dict, Optional
import numpy as np
import torch
from torch import nn
from torch.testing._internal.common_utils import TestCase, run_tests
from typing import List
class StaticModule:
def __init__(self, scripted):
# this is an nn.Module
... | 21,767 | 34.980165 | 114 | py |
pytorch | pytorch-main/test/test_tensor_creation_ops.py | # Owner(s): ["module: tensor creation"]
import torch
import numpy as np
import sys
import math
import warnings
import unittest
from itertools import product, combinations, combinations_with_replacement, permutations
import random
from torch.testing import make_tensor
from torch.testing._internal.common_utils import ... | 185,063 | 45.52187 | 132 | py |
pytorch | pytorch-main/test/linear.py | import torch
class LinearMod(torch.nn.Linear):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def forward(self, input):
return torch._C._nn.linear(input, self.weight, self.bias)
print(torch.jit.trace(LinearMod(20, 20), torch.rand([20, 20])).graph)
| 298 | 28.9 | 69 | py |
pytorch | pytorch-main/test/test_reductions.py | # Owner(s): ["module: tests"]
import contextlib
import torch
import numpy as np
import math
from typing import Dict, List, Sequence
import random
from functools import partial
from itertools import product, combinations, permutations
import warnings
from torch import inf, nan
from torch.testing import make_tensor
fr... | 168,810 | 46.876064 | 131 | py |
pytorch | pytorch-main/test/test_spectral_ops.py | # Owner(s): ["module: fft"]
import torch
import unittest
import math
from contextlib import contextmanager
from itertools import product
import itertools
import doctest
import inspect
from torch.testing._internal.common_utils import \
(TestCase, run_tests, TEST_NUMPY, TEST_LIBROSA, TEST_MKL, first_sample, TEST_WI... | 64,305 | 39.597222 | 129 | py |
pytorch | pytorch-main/test/test_cuda_primary_ctx.py | # Owner(s): ["module: cuda"]
import torch
from torch.testing._internal.common_utils import TestCase, run_tests, skipIfRocmVersionLessThan, NoTest
from torch.testing._internal.common_cuda import TEST_CUDA, TEST_MULTIGPU
import sys
import unittest
# NOTE: this needs to be run in a brand new process
if not TEST_CUDA:
... | 4,155 | 36.781818 | 118 | py |
pytorch | pytorch-main/test/test_typing.py | # Owner(s): ["module: typing"]
# based on NumPy numpy/typing/tests/test_typing.py
import itertools
import os
import re
import shutil
from collections import defaultdict
from typing import IO, Dict, List, Optional
import pytest
from torch.testing._internal.common_utils import run_tests
try:
from mypy import api
... | 7,314 | 29.606695 | 90 | py |
pytorch | pytorch-main/test/test_sparse.py | # Owner(s): ["module: sparse"]
import torch
import itertools
import functools
import operator
import random
import unittest
from torch.testing import make_tensor
from torch.testing._internal.common_utils import TestCase, run_tests, skipIfRocm, do_test_dtypes, \
load_tests, TEST_NUMPY, TEST_SCIPY, IS_WINDOWS, gradc... | 229,185 | 45.393927 | 132 | py |
pytorch | pytorch-main/test/test_jit_disabled.py | # Owner(s): ["oncall: jit"]
import sys
import os
import contextlib
import subprocess
from torch.testing._internal.common_utils import TestCase, run_tests, TemporaryFileName
@contextlib.contextmanager
def _jit_disabled():
cur_env = os.environ.get("PYTORCH_JIT", "1")
os.environ["PYTORCH_JIT"] = "0"
try:
... | 2,357 | 24.630435 | 87 | py |
pytorch | pytorch-main/test/test_compile_benchmark_util.py | # Owner(s): ["module: dynamo"]
import torch
import torch._dynamo as torchdynamo
from torch.testing._internal.common_utils import TestCase, run_tests
import unittest
# We cannot import TEST_CUDA from torch.testing._internal.common_cuda here, because if we do that,
# the TEST_CUDNN line from torch.testing._internal.com... | 1,694 | 38.418605 | 131 | py |
pytorch | pytorch-main/test/test_cpp_extensions_jit.py | # Owner(s): ["module: cpp-extensions"]
import os
import shutil
import sys
import unittest
import warnings
import re
import tempfile
import subprocess
import glob
import torch.testing._internal.common_utils as common
import torch
import torch.backends.cudnn
import torch.utils.cpp_extension
from torch.utils.cpp_extensi... | 35,408 | 37.033298 | 130 | py |
pytorch | pytorch-main/test/test_content_store.py | # Owner(s): ["oncall: pt2"]
import tempfile
import torch
from torch._prims.debug_prims import load_tensor_reader
from torch._subclasses.fake_tensor import FakeTensor, FakeTensorMode
from torch.multiprocessing.reductions import StorageWeakRef
from torch.testing._internal.common_device_type import instantiate_device_ty... | 4,383 | 34.934426 | 84 | py |
pytorch | pytorch-main/test/test_cuda_nvml_based_avail.py | # Owner(s): ["module: cuda"]
import os
import sys
import multiprocessing
import torch
import unittest
from unittest.mock import patch
# NOTE: Each of the tests in this module need to be run in a brand new process to ensure CUDA is uninitialized
# prior to test initiation.
with patch.dict(os.environ, {"PYTORCH_NVML_BA... | 6,902 | 50.902256 | 119 | py |
pytorch | pytorch-main/test/test_ops.py | # Owner(s): ["module: unknown"]
from collections.abc import Sequence
from functools import partial
import warnings
import unittest
import inspect
import itertools
import torch
import contextlib
import re
import os
from collections import defaultdict
from importlib import import_module
from torch.utils._pytree import ... | 94,838 | 41.816704 | 124 | py |
pytorch | pytorch-main/test/test_import_stats.py | # Owner(s): ["module: ci"]
from torch.testing._internal.common_utils import TestCase, run_tests
# these tests could eventually be changed to fail if the import/init
# time is greater than a certain threshold, but for now we just use them
# as a way to track the duration of `import torch`.
class TestImportTime(TestCa... | 626 | 28.857143 | 72 | py |
pytorch | pytorch-main/test/test_jit_fuser.py | # -*- coding: utf-8 -*-
# Owner(s): ["oncall: jit"]
import unittest
import os
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.testing import FileCheck
from unittest import skipIf
from torch.testing._internal.common_utils import run_tests, IS_SANDCASTLE, ProfilingMode, GRAPH_EX... | 41,316 | 40.608258 | 117 | py |
pytorch | pytorch-main/test/test_native_functions.py | # Owner(s): ["module: unknown"]
from typing import Optional, List
import torch
from torch.testing._internal.common_utils import TestCase, run_tests, skipIfTorchDynamo
# End-to-end tests of features in native_functions.yaml
class FloatListWrapperModule(torch.nn.Module):
def forward(self, values, incr: Optional[L... | 9,021 | 36.127572 | 105 | py |
pytorch | pytorch-main/test/test_namedtuple_return_api.py | # Owner(s): ["module: unknown"]
import os
import re
import yaml
import textwrap
import torch
from torch.testing._internal.common_utils import TestCase, run_tests
from collections import namedtuple
path = os.path.dirname(os.path.realpath(__file__))
aten_native_yaml = os.path.join(path, '../aten/src/ATen/native/nativ... | 9,567 | 52.155556 | 129 | py |
pytorch | pytorch-main/test/test_cuda_multigpu.py | # Owner(s): ["module: cuda"]
import collections
import contextlib
import ctypes
import io
import gc
import queue
import sys
import tempfile
import threading
import torch
import torch.cuda.comm as comm
import unittest
from itertools import repeat, chain
from typing import NamedTuple
from torch.nn.parallel import scatt... | 71,881 | 40.743322 | 126 | py |
pytorch | pytorch-main/test/test_set_default_mobile_cpu_allocator.py | # Owner(s): ["oncall: mobile"]
import torch
from torch.testing._internal.common_utils import TestCase, run_tests
class TestSetDefaultMobileCPUAllocator(TestCase):
def test_no_exception(self):
torch._C._set_default_mobile_cpu_allocator()
torch._C._unset_default_mobile_cpu_allocator()
def test_... | 976 | 31.566667 | 68 | py |
pytorch | pytorch-main/test/test_jit_llga_fuser.py | # Owner(s): ["module: mkldnn"]
import sys
import torch
import unittest
import itertools
import torch.nn as nn
from functools import wraps
from concurrent import futures
import torch.nn.functional as F
import torch.fx.experimental.optimization as optimization
from torch.testing._internal.jit_utils import JitTestCase
fro... | 32,735 | 37.153846 | 122 | py |
pytorch | pytorch-main/test/mkldnn_verbose.py | import argparse
import torch
class Module(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv = torch.nn.Conv2d(1, 10, 5, 1)
def forward(self, x):
y = self.conv(x)
return y
def run_model(level):
m = Module().eval()
d = torch.rand(1, 1, 112, 112)
with... | 625 | 22.185185 | 63 | py |
pytorch | pytorch-main/test/test_vulkan.py | # Owner(s): ["oncall: mobile"]
import unittest
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
@unittest.skipUnless(torch.is_vulkan_available(),
"Vulkan backend must be available ... | 6,857 | 40.563636 | 106 | py |
pytorch | pytorch-main/test/test_cuda_trace.py | # Owner(s): ["module: cuda"]
import sys
import unittest
import unittest.mock
import torch
import torch.utils._cuda_trace as cuda_trace
from torch.testing._internal.common_utils import TestCase, run_tests, NoTest
# NOTE: Each test needs to be run in a brand new process, to reset the registered hooks
# and make sure t... | 4,323 | 33.592 | 102 | py |
pytorch | pytorch-main/test/test_license.py | # Owner(s): ["module: unknown"]
import glob
import io
import os
import unittest
import torch
from torch.testing._internal.common_utils import TestCase, run_tests
try:
from third_party.build_bundled import create_bundled
except ImportError:
create_bundled = None
license_file = 'third_party/LICENSES_BUNDLED.... | 1,825 | 34.803922 | 83 | py |
pytorch | pytorch-main/test/test_scatter_gather_ops.py | # -*- coding: utf-8 -*-
# Owner(s): ["module: scatter & gather ops"]
import random
import torch
from torch.testing import make_tensor
from torch.testing._internal.common_utils import \
(parametrize, run_tests, TestCase, DeterministicGuard)
from torch.testing._internal.common_device_type import \
(instantiate... | 17,958 | 48.20274 | 128 | py |
pytorch | pytorch-main/test/test_sparse_csr.py | # Owner(s): ["module: sparse"]
import torch
import random
import itertools
import unittest
import functools
from torch.testing import make_tensor
from torch.testing._internal.common_cuda import SM53OrLater, SM80OrLater, TEST_CUSPARSE_GENERIC
from torch.testing._internal.common_utils import \
(TEST_WITH_TORCHINDUCT... | 182,140 | 48.320607 | 132 | py |
pytorch | pytorch-main/test/test_deploy.py | # Owner(s): ["oncall: package/deploy"]
import textwrap
import types
from torch.utils._freeze import Freezer, PATH_MARKER
from torch.testing._internal.common_utils import run_tests, TestCase
class TestFreezer(TestCase):
"""Tests the freeze.py script"""
def test_compile_string(self):
freezer = Freeze... | 1,068 | 23.295455 | 76 | py |
pytorch | pytorch-main/test/test_linalg.py | # -*- coding: utf-8 -*-
# Owner(s): ["module: linear algebra"]
import torch
import numpy as np
import unittest
import itertools
import warnings
import math
from math import inf, nan, isnan
import random
from random import randrange
from itertools import product
from functools import reduce, partial
from torch.testin... | 357,624 | 46.180079 | 131 | py |
pytorch | pytorch-main/test/test_native_mha.py | # Owner(s): ["module: nn"]
import math
import copy
import torch
from torch.testing._internal.common_device_type import (
dtypes,
dtypesIfCUDA,
instantiate_device_type_tests,
onlyCUDA,
skipMeta,
)
from torch.testing._internal.common_utils import parametrize, run_tests, TestCase
class TestMHADeviceT... | 13,485 | 39.620482 | 115 | py |
pytorch | pytorch-main/test/test_mobile_optimizer.py | # Owner(s): ["oncall: mobile"]
import unittest
import torch
import torch.nn as nn
import torch.utils.bundled_inputs
from torch.testing._internal.common_utils import TestCase, run_tests, skipIfNoXNNPACK
from torch.testing._internal.jit_utils import get_forward, get_forward_graph
from torch.utils.mobile_optimizer import... | 26,736 | 42.05475 | 131 | py |
pytorch | pytorch-main/test/test_throughput_benchmark.py | # Owner(s): ["module: unknown"]
import torch
from torch.utils import ThroughputBenchmark
from torch.testing._internal.common_utils import run_tests, TestCase, TemporaryFileName
class TwoLayerNet(torch.jit.ScriptModule):
def __init__(self, D_in, H, D_out):
super().__init__()
self.linear1 = torch.n... | 2,441 | 28.071429 | 87 | py |
pytorch | pytorch-main/test/test_mkldnn_fusion.py | # Owner(s): ["module: mkldnn"]
import itertools
import unittest
from typing import NamedTuple, List
import torch
from torch import nn
from torch.testing._internal.common_utils import run_tests
from torch.testing._internal.jit_utils import JitTestCase
from test_tensorexpr import warmup_and_run_forward
FUSION_GROUP =... | 17,761 | 43.740554 | 131 | py |
pytorch | pytorch-main/test/test_ops_jit.py | # Owner(s): ["module: unknown"]
from functools import partial
from textwrap import dedent
import torch
from torch.testing import FileCheck
from torch.testing._internal.common_utils import \
(run_tests, IS_SANDCASTLE, clone_input_helper, first_sample)
from torch.testing._internal.common_methods_invocations import... | 13,954 | 45.362126 | 132 | py |
pytorch | pytorch-main/test/test_multiprocessing.py | # Owner(s): ["module: multiprocessing"]
import contextlib
import gc
import os
import sys
import time
import unittest
import copy
from sys import platform
import torch
import torch.cuda
import torch.multiprocessing as mp
import torch.utils.hooks
from torch.nn import Parameter
from torch.testing._internal.common_utils ... | 34,364 | 35.442206 | 125 | py |
pytorch | pytorch-main/test/test_cuda.py | # Owner(s): ["module: cuda"]
from itertools import product, chain
import collections
import contextlib
from copy import deepcopy
import gc
import os
import pickle
import sys
import tempfile
import threading
import unittest
import warnings
import subprocess
import random
from random import randint
import json
import t... | 177,958 | 42.735316 | 130 | py |
pytorch | pytorch-main/test/test_transformers.py | # Owner(s): ["module: nn"]
import contextlib
from functools import partial
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
import unittest
from unittest.mock import patch, MagicMock, ANY
import math
from torch.backends.cuda import sdp_kernel, SDPBa... | 122,023 | 48.183394 | 131 | py |
pytorch | pytorch-main/test/test_functional_optim.py | # Owner(s): ["oncall: distributed"]
from typing import List, Optional, Tuple
import unittest
import torch
import torch.distributed
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
from torch.optim import SGD, Adam, AdamW
from torch.testing._internal.common_utils import TestCase, run_test... | 6,202 | 38.509554 | 98 | py |
pytorch | pytorch-main/test/test_maskedtensor.py | # Owner(s): ["module: masked operators"]
import torch
from torch.testing._internal.common_utils import (
TestCase,
run_tests,
make_tensor,
parametrize,
instantiate_parametrized_tests,
)
from torch.testing._internal.common_device_type import (
instantiate_device_type_tests,
ops,
)
from torch... | 36,355 | 38.9956 | 118 | py |
pytorch | pytorch-main/test/test_fx.py | # Owner(s): ["module: fx"]
import builtins
import contextlib
import copy
import functools
import inspect
import math
import numbers
import io
import operator
import os
import pickle
import sys
import torch
import traceback
import typing
import types
import warnings
import unittest
from math import sqrt
from functorch.... | 163,174 | 35.333779 | 128 | py |
pytorch | pytorch-main/test/test_subclass.py | # Owner(s): ["module: nn"]
import tempfile
from copy import deepcopy
from functools import partial
from unittest import expectedFailure
import torch
from torch import nn
from torch.nn.modules.lazy import LazyModuleMixin
from torch.nn.utils.parametrize import (
register_parametrization,
remove_parametrizations... | 9,778 | 36.467433 | 116 | py |
pytorch | pytorch-main/test/test_ops_fwd_gradients.py | # Owner(s): ["module: unknown"]
from functools import partial
import torch
from torch.testing._internal.common_utils import (
TestGradients, run_tests, skipIfTorchInductor, IS_MACOS)
from torch.testing._internal.common_methods_invocations import op_db
from torch.testing._internal.common_device_type import \
(... | 3,669 | 46.662338 | 119 | py |
pytorch | pytorch-main/test/test_sparse_semi_structured.py | # Owner(s): ["module: sparse"]
import itertools
import random
import unittest
import torch
from torch import nn
from torch.sparse.semi_structured import (
_DTYPE_TO_SEMI_STRUCTURED_SPARSE_CONFIG,
SparseSemiStructuredTensor,
to_sparse_semi_structured,
)
from torch.testing import make_tensor
from torch.te... | 15,001 | 40.441989 | 120 | py |
pytorch | pytorch-main/test/test_serialization.py | # -*- coding: utf-8 -*-
# Owner(s): ["module: serialization"]
import torch
import unittest
import io
import tempfile
import os
import gc
import sys
import zipfile
import warnings
import gzip
import copy
import pickle
import shutil
import pathlib
from copy import deepcopy
from itertools import product
from torch._util... | 268,208 | 65.208097 | 112 | py |
pytorch | pytorch-main/test/test_shape_ops.py | # Owner(s): ["module: tests"]
import torch
import numpy as np
from itertools import product, combinations, permutations, chain
from functools import partial
import random
import warnings
import unittest
from torch import nan
from torch.testing import make_tensor
from torch.testing._internal.common_utils import (
... | 32,007 | 43.148966 | 105 | py |
pytorch | pytorch-main/test/test_nn.py | # Owner(s): ["module: nn"]
import contextlib
import math
import random
import unittest
import io
import itertools
import warnings
import pickle
from copy import deepcopy
from itertools import product
from functools import partial
from collections import OrderedDict
from tempfile import NamedTemporaryFile
from unittest... | 594,809 | 45.433255 | 132 | py |
pytorch | pytorch-main/test/test_ops_gradients.py | # Owner(s): ["module: unknown"]
from functools import partial
import torch
from torch.testing._internal.common_utils import TestGradients, run_tests
from torch.testing._internal.common_methods_invocations import op_db
from torch.testing._internal.control_flow_opinfo_db import control_flow_opinfo_db
from torch.testing... | 4,215 | 43.851064 | 104 | py |
pytorch | pytorch-main/test/mkl_verbose.py | import argparse
import torch
def run_model(level):
m = torch.nn.Linear(20, 30)
input = torch.randn(128, 20)
with torch.backends.mkl.verbose(level):
m(input)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--verbose-level", default=0, type=int)
args = ... | 431 | 23 | 63 | py |
pytorch | pytorch-main/test/test_ao_sparsity.py | # -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
from torch.testing._internal.common_utils import run_tests, IS_ARM64
# Kernels
from ao.sparsity.test_kernels import TestQuantizedSparseKernels # noqa: F401
from ao.sparsity.test_kernels import TestQuantizedSparseLayers # noqa: F401
# Parametrizations
from ao.... | 1,802 | 37.361702 | 93 | py |
pytorch | pytorch-main/test/test_tensorexpr.py | # Owner(s): ["NNC"]
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
import unittest
import itertools
from torch.testing._internal.common_utils import suppress_warnings, num_profiled_runs, run_tests, skipIfTorchDynamo
from torch.testing._internal.jit_utils import JitTestCase, Tens... | 58,797 | 33.16502 | 124 | py |
pytorch | pytorch-main/test/test_dataloader.py | # Owner(s): ["module: dataloader"]
import math
import sys
import errno
import os
import ctypes
import faulthandler
import torch
import gc
import time
import signal
import unittest
import itertools
import warnings
import tempfile
import torch.utils.data.datapipes as dp
from torch import multiprocessing as mp
from torch... | 115,339 | 40.429598 | 131 | py |
pytorch | pytorch-main/test/test_numpy_interop.py | # Owner(s): ["module: numpy"]
import torch
import numpy as np
from itertools import product
from torch.testing._internal.common_utils import \
(TestCase, run_tests)
from torch.testing._internal.common_device_type import \
(instantiate_device_type_tests, onlyCPU, dtypes, skipMeta)
from torch.testing._internal... | 19,807 | 40.352818 | 118 | py |
pytorch | pytorch-main/test/test_flop_counter.py | # Owner(s): ["module: unknown"]
import torch
from torch.testing._internal.common_utils import TestCase, run_tests, TEST_WITH_TORCHDYNAMO
from torch.testing._internal.common_cuda import SM80OrLater, PLATFORM_SUPPORTS_FUSED_SDPA
import torch.utils.flop_counter
import torch.nn.functional as F
import unittest
import funct... | 9,465 | 38.115702 | 131 | py |
pytorch | pytorch-main/test/test_nnapi.py | #!/usr/bin/env python3
# Owner(s): ["oncall: mobile"]
import os
import ctypes
import torch
import unittest
from typing import Tuple
from torch.backends._nnapi.prepare import convert_model_to_nnapi
from torch.testing._internal.common_quantized import supported_qengines
from torch.testing._internal.common_utils import T... | 25,376 | 36.264317 | 116 | py |
pytorch | pytorch-main/test/test_mkldnn.py | # Owner(s): ["module: mkldnn"]
import copy
import itertools
import functools
import unittest
from contextlib import nullcontext
try:
import torchvision
HAS_TORCHVISION = True
except ImportError:
HAS_TORCHVISION = False
skipIfNoTorchVision = unittest.skipIf(not HAS_TORCHVISION, "no torchvision")
import t... | 63,800 | 42.431586 | 132 | py |
pytorch | pytorch-main/test/test_model_dump.py | #!/usr/bin/env python3
# Owner(s): ["oncall: mobile"]
import os
import io
import functools
import tempfile
import urllib
import unittest
import torch
import torch.backends.xnnpack
import torch.utils.model_dump
import torch.utils.mobile_optimizer
from torch.testing._internal.common_utils import TestCase, run_tests, IS... | 7,994 | 31.901235 | 99 | py |
pytorch | pytorch-main/test/test_pytree.py | # Owner(s): ["module: pytree"]
import torch
from torch.testing._internal.common_utils import TestCase, run_tests
from torch.utils._pytree import (
tree_flatten,
tree_map,
tree_unflatten,
TreeSpec,
LeafSpec,
pytree_to_str,
str_to_pytree,
)
import unittest
from torch.utils._pytree import _bro... | 12,037 | 36.501558 | 124 | py |
pytorch | pytorch-main/test/test_testing.py | # Owner(s): ["module: tests"]
import collections
import doctest
import functools
import importlib
import inspect
import itertools
import math
import os
import re
import subprocess
import sys
import unittest.mock
from typing import Any, Callable, Iterator, List, Tuple, Generator
import torch
from torch.testing import... | 93,269 | 39.237274 | 128 | py |
pytorch | pytorch-main/test/test_weak.py | # Owner(s): ["module: meta tensors"]
import copy
import gc
import random
import threading
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, TestCase
from torch.utils.weak import WeakIdKeyDictionary
def C():
return torch.randn(1)
# These tests are ported from cpython/Lib... | 18,378 | 31.414462 | 86 | py |
pytorch | pytorch-main/test/test_jit_cuda_fuser.py | # Owner(s): ["module: nvfuser"]
import torch
from torch.testing._internal.common_utils import set_default_dtype
try:
from _nvfuser.test_torchscript import * # noqa: F403,F401
except ImportError:
def run_tests():
return
pass
if __name__ == '__main__':
# TODO: Update nvfuser to work with float... | 397 | 22.411765 | 66 | py |
pytorch | pytorch-main/test/test_per_overload_api.py | # Owner(s): ["module: unknown"]
import torch
import copy
from torch.testing._internal.common_utils import TestCase, run_tests
class TestPerOverloadAPI(TestCase):
def test_basics_opoverloadpacket(self):
# add is ony used as an example here. It is ok to update the test
# if the semantics of add are m... | 2,524 | 33.589041 | 100 | py |
pytorch | pytorch-main/test/test_utils.py | # Owner(s): ["module: unknown"]
import sys
import os
import re
import shutil
import random
import subprocess
import tempfile
import traceback
import textwrap
import unittest
from typing import Any, List, Dict
import torch
import torch.nn as nn
import torch.utils.data
from torch.utils.data import DataLoader
from torch.... | 36,010 | 36.163055 | 127 | py |
pytorch | pytorch-main/test/test_autograd.py | # Owner(s): ["module: autograd"]
import contextlib
import gc
import io
import math
import os
import random
import sys
import tempfile
import threading
import time
import unittest
import uuid
import warnings
import operator
import subprocess
from copy import deepcopy
from collections import OrderedDict
from itertools i... | 439,620 | 37.825488 | 130 | py |
pytorch | pytorch-main/test/test_optim.py | # Owner(s): ["module: optimizer"]
from optim.test_optim import TestOptim, TestDifferentiableOptimizer # noqa: F401
from optim.test_lrscheduler import TestLRScheduler # noqa: F401
from optim.test_swa_utils import TestSWAUtils # noqa: F401
from torch.testing._internal.common_utils import run_tests
if __name__ == '__... | 345 | 33.6 | 81 | py |
pytorch | pytorch-main/test/error_messages/storage.py | import torch
def check_error(desc, fn, *required_substrings):
try:
fn()
except Exception as e:
error_message = e.args[0]
print('=' * 80)
print(desc)
print('-' * 80)
print(error_message)
print('')
for sub in required_substrings:
assert... | 1,873 | 25.027778 | 82 | py |
pytorch | pytorch-main/test/benchmark_utils/test_benchmark_utils.py | # Owner(s): ["module: unknown"]
import collections
import json
import os
import re
import textwrap
import timeit
from typing import Any, List, Tuple
import unittest
import torch
import torch.utils.benchmark as benchmark_utils
from torch.testing._internal.common_utils import TestCase, run_tests, IS_SANDCASTLE, IS_WIND... | 44,093 | 42.918327 | 260 | py |
pytorch | pytorch-main/test/nn/test_dropout.py | # Owner(s): ["module: nn"]
from itertools import product
import unittest
import random
import itertools
import torch
from torch.testing._internal.common_utils import run_tests, set_default_dtype, \
instantiate_parametrized_tests
from torch.testing._internal.common_cuda import TEST_CUDA
from torch.testing._interna... | 12,861 | 44.288732 | 109 | py |
pytorch | pytorch-main/test/nn/test_packed_sequence.py | # Owner(s): ["module: nn"]
import itertools
import random
import torch
from torch.testing._internal.common_utils import TestCase, run_tests
import torch.nn.utils.rnn as rnn_utils
class PackedSequenceTest(TestCase):
_type_by_name = {
'torch.DoubleTensor': (torch.DoubleTensor, 'double'),
'torch.F... | 17,970 | 44.381313 | 109 | py |
pytorch | pytorch-main/test/nn/test_pruning.py | # Owner(s): ["module: nn"]
import unittest
import unittest.mock as mock
import pickle
import torch
import torch.nn as nn
import torch.nn.utils.prune as prune
from torch.testing._internal.common_utils import TEST_NUMPY, TemporaryFileName, \
instantiate_parametrized_tests, run_tests
from torch.testing._internal.com... | 38,693 | 40.16383 | 103 | py |
pytorch | pytorch-main/test/nn/test_lazy_modules.py | # Owner(s): ["module: nn"]
import unittest
import pickle
import torch
import torch.nn as nn
from torch.nn.parameter import UninitializedParameter, UninitializedBuffer
from torch.nn import Buffer, Parameter
from torch.testing._internal.common_utils import TestCase, run_tests, suppress_warnings
from torch.testing._inter... | 28,962 | 45.639291 | 111 | py |
pytorch | pytorch-main/test/nn/test_multihead_attention.py | # Owner(s): ["module: nn"]
import contextlib
import random
import unittest
import unittest.mock as mock
from torch.nn import MultiheadAttention
from torch.testing._internal.common_device_type import instantiate_device_type_tests, dtypes, \
onlyCUDA
from torch.testing._internal.common_nn import NNTestCase
from torc... | 35,665 | 50.466089 | 118 | py |
pytorch | pytorch-main/test/nn/test_parametrization.py | # Owner(s): ["module: nn"]
from copy import deepcopy
from itertools import product
import pickle
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
import torch.nn.utils.parametrize as parametrize
from torch.nn import Buffer, Parameter
from torch.testing._internal.common_u... | 72,072 | 44.558154 | 120 | py |
pytorch | pytorch-main/test/nn/test_embedding.py | # Owner(s): ["module: nn"]
import unittest
import random
import itertools
from itertools import product
import torch
from torch.testing._internal.common_utils import run_tests, set_default_dtype, skipIfTorchDynamo, \
instantiate_parametrized_tests, parametrize as parametrize_test, _assertGradAndGradgradChecks, IS_... | 58,778 | 45.502373 | 129 | py |
pytorch | pytorch-main/test/nn/test_module_hooks.py | # Owner(s): ["module: nn"]
from torch.testing._internal.common_utils import (
TestCase,
run_tests,
skipIfTorchDynamo,
IS_WINDOWS
)
from torch.testing._internal.common_nn import NNTestCase, _create_basic_net
import torch
import torch.nn as nn
from functools import partial
from typing import Any, Dict, ... | 54,763 | 35.606952 | 130 | py |
pytorch | pytorch-main/test/nn/test_init.py | # Owner(s): ["module: nn"]
import random
import unittest
import math
import string
from functools import reduce
from operator import mul
from torch.testing._internal.common_utils import TestCase, TEST_SCIPY, skipIfNoLapack
import torch
import torch.nn.init as init
import torch.nn.functional as F
if TEST_SCIPY:
fr... | 19,019 | 42.724138 | 127 | py |
pytorch | pytorch-main/test/nn/test_convolution.py | # Owner(s): ["module: nn"]
import math
import unittest
import itertools
import warnings
from itertools import product
import torch
import torch.autograd.forward_ad as fwAD
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
from torch.testing._internal.common_dtype import floati... | 128,706 | 50.648074 | 130 | py |
pytorch | pytorch-main/test/nn/test_pooling.py | # Owner(s): ["module: nn"]
from functools import reduce
from functools import partial
from itertools import repeat
import unittest
import subprocess
import sys
import os
import random
import itertools
import math
from torch import inf, nan
import torch
from torch.testing import make_tensor
from torch.testing._internal... | 70,556 | 44.727155 | 120 | py |
pytorch | pytorch-main/test/cpp_api_parity/sample_module.py | import torch
'''
`SampleModule` is used by `test_cpp_api_parity.py` to test that Python / C++ API
parity test harness works for `torch.nn.Module` subclasses.
When `SampleModule.has_parity` is true, behavior of `forward` / `backward`
is the same as the C++ equivalent.
When `SampleModule.has_parity` is false, behavior... | 3,435 | 32.038462 | 118 | py |
pytorch | pytorch-main/test/cpp_api_parity/utils.py | from collections import namedtuple
import unittest
import os
import warnings
import shutil
import torch
import torch.utils.cpp_extension
import torch.testing._internal.common_nn as common_nn
from torch.testing._internal.common_cuda import TEST_CUDA
# Note that this namedtuple is for C++ parity test mechanism's intern... | 14,790 | 40.664789 | 121 | py |
pytorch | pytorch-main/test/cpp_api_parity/functional_impl_check.py | # The purpose of this test is to check that we have implementation parity between
# a Python `torch.nn.functional` function and its corresponding C++ `torch::nn::functional`
# function. Concretely, this test does the following:
#
# 1. Get a test params dict from common_nn.py, run forward pass on the Python functional
#... | 11,146 | 45.640167 | 116 | py |
pytorch | pytorch-main/test/cpp_api_parity/sample_functional.py | import torch
import torch.nn.functional as F
from torch.testing._internal.common_nn import wrap_functional
'''
`sample_functional` is used by `test_cpp_api_parity.py` to test that Python / C++ API
parity test harness works for `torch.nn.functional` functions.
When `has_parity=true` is passed to `sample_functional`, b... | 2,129 | 29.428571 | 89 | py |
pytorch | pytorch-main/test/cpp_api_parity/module_impl_check.py | # The purpose of this test is to check that we have implementation parity between
# a Python `torch.nn` module and its corresponding C++ `torch::nn` module. Concretely,
# this test does the following:
#
# 1. Get a test params dict from common_nn.py, run forward and backward on the
# Python module created using the test... | 13,759 | 43.820847 | 120 | py |
pytorch | pytorch-main/test/bottleneck_test/test_args.py | # Owner(s): ["module: unknown"]
import argparse
import torch
if __name__ == '__main__':
parser = argparse.ArgumentParser()
# Required args. Raises error if they aren't passed.
parser.add_argument('--foo', help='foo', required=True)
parser.add_argument('--bar', help='bar', required=True)
_ = parse... | 412 | 24.8125 | 59 | py |
pytorch | pytorch-main/test/bottleneck_test/test.py | # Owner(s): ["module: unknown"]
import torch
x = torch.ones((3, 3), requires_grad=True)
(3 * x).sum().backward()
| 115 | 15.571429 | 42 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.