python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
# Owner(s): ["module: complex"] import torch from torch.testing._internal.common_device_type import instantiate_device_type_tests, dtypes from torch.testing._internal.common_utils import TestCase, run_tests from torch.testing._internal.common_dtype import complex_types devices = (torch.device('cpu'), torch.device('cu...
pytorch-master
test/test_complex.py
# Owner(s): ["module: unknown"] from collections.abc import Sequence from functools import partial import warnings import unittest import itertools import torch import contextlib from collections import defaultdict from importlib import import_module from torch.utils._pytree import tree_map from torch.testing import ...
pytorch-master
test/test_ops.py
# Owner(s): ["module: fx"] import math import numbers import operator import pickle import sys import tempfile import unittest from typing import Callable, Dict, Union, List, Optional from types import BuiltinFunctionType import torch import torch.fx.experimental.optimization as optimization from torch.fx._symbolic_t...
pytorch-master
test/test_fx_experimental.py
# Owner(s): ["module: tests"] import torch import numpy as np import itertools from itertools import product import math import random from numbers import Number import unittest import warnings import operator from functools import partial import torch.autograd.forward_ad as fwAD from torch._six import inf, nan from...
pytorch-master
test/test_binary_ufuncs.py
# Owner(s): ["oncall: profiler"] import functools import os import re import textwrap import traceback import unittest import expecttest import torch from torch._C._autograd import _ExtraFields_PyCall, _ExtraFields_PyCCall from torch.testing._internal.common_utils import ( TestCase, run_tests, IS_WINDOWS, TEST_W...
pytorch-master
test/test_profiler_tree.py
# Owner(s): ["oncall: jit"] import sys sys.argv.append("--jit_executor=simple") from test_jit import * # noqa: F403 if __name__ == '__main__': run_tests()
pytorch-master
test/test_jit_simple.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...
pytorch-master
test/test_autograd.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...
pytorch-master
test/test_openmp.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, ...
pytorch-master
test/test_overrides.py
# Owner(s): ["module: serialization"] import torch import unittest import io import tempfile import os 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._utils_internal import get_file_path_2 ...
pytorch-master
test/test_serialization.py
# Owner(s): ["oncall: distributed"] from typing import List, Optional, Tuple import torch 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_tests from torch.distributed.optim.utils impo...
pytorch-master
test/test_functional_optim.py
# Owner(s): ["module: meta tensors"] from torch.testing._internal.common_utils import TestCase, run_tests, skipIfCrossRef, skipIfRocm import torch import itertools import numpy as np from torch.testing._internal.jit_utils import RUN_CUDA from torch._subclasses.fake_tensor import ( FakeTensor, FakeTensorMode, ...
pytorch-master
test/test_fake_tensor.py
# Owner(s): ["oncall: jit"] import sys sys.argv.append("--jit_executor=profiling") from test_jit import * # noqa: F403 if __name__ == '__main__': run_tests()
pytorch-master
test/test_jit_profiling.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 = ...
pytorch-master
test/mkl_verbose.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_device_type import ( instantiate_device_type_tests, onlyCUDA, toleranceOverride, tol, ski...
pytorch-master
test/test_modules.py
# Owner(s): ["module: nn"] import contextlib import torch import torch.nn as nn import torch.nn.functional as F import unittest from unittest.mock import patch from torch.testing._internal.common_nn import NNTestCase from torch.testing._internal.common_utils import ( TEST_FAIRSEQ, run_tests, parametrize, ...
pytorch-master
test/test_transformers.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...
pytorch-master
test/test_cpp_extensions_jit.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...
pytorch-master
test/test_type_hints.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...
pytorch-master
test/test_spectral_ops.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...
pytorch-master
test/test_functional_autograd_benchmark.py
# Owner(s): ["module: mkldnn"] import itertools import unittest 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 = 'prim::TensorExprGroup' @unittest...
pytorch-master
test/test_mkldnn_fusion.py
# Owner(s): ["module: nestedtensor"] import torch import torch.nn import unittest from torch.testing._internal.common_device_type import ( dtypes, dtypesIfCUDA, instantiate_device_type_tests, skipMeta, onlyCPU ) from torch.testing._internal.common_utils import TestCase, IS_FBCODE, run_tests, freeze...
pytorch-master
test/test_nestedtensor.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(TwoLayerNet, self).__init__() self....
pytorch-master
test/test_throughput_benchmark.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, vmap import functools import itertools import warnings from torch.testing._internal.common_device_type import instantiate_device_type_tests, \ ski...
pytorch-master
test/test_vmap.py
import sys import torch if __name__ == '__main__': print(torch.jit.load(sys.argv[1])) sys.exit(0)
pytorch-master
test/load_torchscript_model.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...
pytorch-master
test/test_tensorexpr_pybind.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 import torch.nn.utils._stateless as _...
pytorch-master
test/test_fx.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...
pytorch-master
test/test_numpy_interop.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 import torch from torch.testing import make_tenso...
pytorch-master
test/test_testing.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...
pytorch-master
test/cpp_extensions/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...
pytorch-master
test/cpp_extensions/no_python_abi_suffix_test/setup.py
pytorch-master
test/cpp_extensions/torch_test_cpp_extension/__init__.py
# Owner(s): ["module: onnx"] import io import itertools import sys import unittest from typing import Tuple import caffe2.python.onnx.backend as c2 import model_defs.dcgan as dcgan import model_defs.word_language_model as word_language_model import numpy as np import onnx import torch.onnx import torch.onnx.operator...
pytorch-master
test/onnx/test_pytorch_onnx_caffe2.py
import argparse import glob import os import shutil import traceback import google.protobuf.text_format import onnx.backend.test import onnx_test_common from test_caffe2_common import run_generated_test from torch.testing._internal.common_device_type import get_all_device_types _fail_test_dir = os.path.join( os....
pytorch-master
test/onnx/export_onnx_tests_filter.py
# Owner(s): ["module: onnx"] import unittest import onnxruntime # noqa: F401 import torch from pytorch_test_common import ( skipIfNoBFloat16Cuda, skipIfNoCuda, skipIfUnsupportedMinOpsetVersion, skipScriptTest, ) from test_pytorch_onnx_onnxruntime import TestONNXRuntime from torch.cuda.amp import aut...
pytorch-master
test/onnx/test_pytorch_onnx_onnxruntime_cuda.py
# Owner(s): ["module: unknown"] import io import caffe2.python.onnx.backend as c2 import numpy as np import onnx import torch.nn as nn import torch.nn.quantized as nnq import torch.onnx from torch.testing._internal import common_utils class TestQuantizedOps(common_utils.TestCase): def generic_test( sel...
pytorch-master
test/onnx/test_pytorch_onnx_caffe2_quantized.py
import sys import caffe2.python.onnx.backend as c2 import onnx import pytorch_test_common import torch import torch.jit from torch.autograd import Variable torch.set_default_tensor_type("torch.FloatTensor") try: import torch except ImportError: print("Cannot import torch, hence caffe2-torch test will not run...
pytorch-master
test/onnx/debug_embed_params.py
# Owner(s): ["module: onnx"] from __future__ import annotations import os import random from typing import Any, Mapping, Type import numpy as np import onnxruntime import torch from torch.onnx import _constants, verification from torch.testing._internal import common_utils onnx_model_dir = os.path.join( os.pat...
pytorch-master
test/onnx/onnx_test_common.py
import io import onnx import torch.onnx from caffe2.python.core import BlobReference, Net from caffe2.python.onnx.backend import Caffe2Backend _next_idx = 0 # Clone net takes a dict instead of a lambda # It should probably take a lambda, it is more flexible # We fake dict here class _FakeDict: def __init__(sel...
pytorch-master
test/onnx/pytorch_helper.py
# Owner(s): ["module: onnx"] import caffe2.python.onnx.backend as backend import torch from torch.autograd import Function from torch.nn import Module, Parameter from torch.testing._internal import common_utils from verify import verify class TestVerify(common_utils.TestCase): maxDiff = None def assertVerif...
pytorch-master
test/onnx/test_verify.py
# Owner(s): ["module: onnx"] import copy import io import onnx import torch import torch.onnx import torch.utils.cpp_extension import torchvision from autograd_helper import CustomFunction as CustomFunction2 from pytorch_test_common import ( skipIfNoCuda, skipIfUnsupportedMaxOpsetVersion, skipIfUnsupport...
pytorch-master
test/onnx/test_utility_funs.py
# Owner(s): ["module: onnx"] import glob import inspect import io import itertools import os import shutil import tempfile import torch import torch.nn as nn import torch.nn.functional as F import torch.onnx from pytorch_test_common import ( BATCH_SIZE, flatten, RNN_HIDDEN_SIZE, RNN_INPUT_SIZE, R...
pytorch-master
test/onnx/test_operators.py
# Owner(s): ["module: onnx"] import unittest import torch from onnx_test_common import run_model_test from torch.onnx import OperatorExportTypes from torch.onnx._globals import GLOBALS from torch.onnx.utils import _model_to_graph class TestAutogradFuns(unittest.TestCase): opset_version = GLOBALS.export_onnx_op...
pytorch-master
test/onnx/test_autograd_funs.py
# Owner(s): ["module: onnx"] import caffe2.python.onnx.backend as c2 import numpy as np import onnx import onnx_test_common import torch import torch.utils.cpp_extension from test_pytorch_onnx_caffe2 import do_export from torch.onnx import symbolic_helper from torch.testing._internal import common_utils class TestCu...
pytorch-master
test/onnx/test_custom_ops.py
# Owner(s): ["module: onnx"] import numpy as np import torch from pytorch_test_common import skipIfUnsupportedMinOpsetVersion from torch.onnx import _constants, symbolic_helper from torch.testing._internal import common_utils def expect_tensor(scalar_type, shape=None): def verify(actual_type): np.testin...
pytorch-master
test/onnx/test_pytorch_onnx_shape_inference.py
# Owner(s): ["module: onnx"] import functools import os import sys import unittest import torch from torch.autograd import function pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.insert(-1, pytorch_test_dir) torch.set_default_tensor_type("torch.FloatTensor") BATCH_SIZE = 2...
pytorch-master
test/onnx/pytorch_test_common.py
# Owner(s): ["module: onnx"] import os import unittest import onnx_test_common import parameterized import PIL import torch import torchvision from torch import nn def _get_test_image_tensor(): data_dir = os.path.join(os.path.dirname(__file__), "assets") img_path = os.path.join(data_dir, "grace_hopper_517x...
pytorch-master
test/onnx/test_models_quantized_onnxruntime.py
import io import os import shutil import traceback import onnx import onnx_test_common import torch from onnx import numpy_helper from test_nn import new_module_tests from torch.autograd import Variable from torch.testing._internal.common_nn import module_tests # Take a test case (a dict) as input, return the test ...
pytorch-master
test/onnx/export_onnx_tests_generator.py
# Owner(s): ["module: onnx"] import os import unittest from collections import OrderedDict from typing import List, Mapping, Tuple import onnx_test_common import parameterized import PIL import test_models import torch import torchvision from pytorch_test_common import skipIfUnsupportedMinOpsetVersion, skipScriptTes...
pytorch-master
test/onnx/test_models_onnxruntime.py
# Owner(s): ["module: onnx"] import unittest import torch from model_defs.dcgan import _netD, _netG, bsz, imgsz, nz, weights_init from model_defs.emb_seq import EmbeddingNetwork1, EmbeddingNetwork2 from model_defs.mnist import MNIST from model_defs.op_test import ConcatNet, DummyNet, FakeQuantNet, PermuteNet, PReluN...
pytorch-master
test/onnx/test_models.py
# Owner(s): ["module: onnx"] from __future__ import annotations import io import itertools import os import unittest from collections import OrderedDict from typing import Dict, List, Optional, Tuple, Union import numpy as np import onnx_test_common import parameterized import torch import torchvision from model_de...
pytorch-master
test/onnx/test_pytorch_onnx_onnxruntime.py
import difflib import io import numpy as np import onnx import onnx.helper import torch import torch.jit import torch.onnx def colonize(msg, sep=": "): if not msg: return "" else: return msg + sep class Errors: """ An error-collecting object which supports error recovery. It i...
pytorch-master
test/onnx/verify.py
# Owner(s): ["module: onnx"] import io import itertools import onnx import torch import torch.onnx from torch.nn import Module from torch.onnx import producer_name, producer_version from torch.onnx._globals import GLOBALS from torch.testing._internal import common_utils def check_onnx_opset_operator( model, op...
pytorch-master
test/onnx/test_onnx_opset.py
# Owner(s): ["module: onnx"] import onnxruntime import torch from pytorch_test_common import skipIfNoCuda from torch.onnx import verification from torch.testing._internal import common_utils def _jit_graph_to_onnx_model(graph, operator_export_type, opset_version): r""" This function exports torch::jit::Graph...
pytorch-master
test/onnx/test_pytorch_jit_onnx.py
# Owner(s): ["module: onnx"] """Tests for onnx export that don't run the exported model.""" import contextlib import io import itertools import unittest from typing import Callable, Dict, Iterable, List, Optional, Tuple, Type, Union import onnx import onnx.numpy_helper import torch import torch.nn.functional as F f...
pytorch-master
test/onnx/test_pytorch_onnx_no_runtime.py
# Owner(s): ["module: onnx"] """Unit tests on `torch.onnx.symbolic_helper`.""" import torch from torch.onnx import symbolic_helper from torch.onnx._globals import GLOBALS from torch.testing._internal import common_utils class TestHelperFunctions(common_utils.TestCase): def setUp(self): super().setUp() ...
pytorch-master
test/onnx/test_symbolic_helper.py
# Owner(s): ["module: onnx"] import torch # Autograd funtion that is a replica of the autograd funtion in # test_utility_funs.py (test_autograd_module_name) class CustomFunction(torch.autograd.Function): @staticmethod def forward(ctx, input): ctx.save_for_backward(input) return input.clamp(mi...
pytorch-master
test/onnx/autograd_helper.py
# Owner(s): ["module: onnx"] # Some standard imports import unittest import numpy as np import torch.nn.init as init import torch.onnx from caffe2.python.core import workspace from caffe2.python.model_helper import ModelHelper from pytorch_helper import PyTorchModule from torch import nn from torch.testing._internal...
pytorch-master
test/onnx/test_pytorch_helper.py
# Owner(s): ["module: onnx"] import glob import os import caffe2.python.onnx.backend as c2 import numpy as np import onnx.backend.test from onnx import numpy_helper def load_tensor_as_numpy_array(f): tensor = onnx.TensorProto() with open(f, "rb") as file: tensor.ParseFromString(file.read()) ret...
pytorch-master
test/onnx/test_caffe2_common.py
# Owner(s): ["module: onnx"] import numpy as np import torch from torch.onnx import _experimental, verification from torch.testing._internal import common_utils class TestVerification(common_utils.TestCase): def setUp(self) -> None: super().setUp() torch.manual_seed(0) if torch.cuda.is_a...
pytorch-master
test/onnx/test_verification.py
import torch.nn as nn class EmbeddingNetwork1(nn.Module): def __init__(self, dim=5): super().__init__() self.emb = nn.Embedding(10, dim) self.lin1 = nn.Linear(dim, 1) self.seq = nn.Sequential( self.emb, self.lin1, ) def forward(self, input): ...
pytorch-master
test/onnx/model_defs/emb_seq.py
import torch.nn as nn import torch.nn.init as init class SuperResolutionNet(nn.Module): def __init__(self, upscale_factor): super().__init__() self.relu = nn.ReLU() self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2)) self.conv2 = nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1)) ...
pytorch-master
test/onnx/model_defs/super_resolution.py
# The model is from here: # https://github.com/pytorch/examples/blob/master/word_language_model/model.py from typing import Optional, Tuple import torch import torch.nn as nn from torch import Tensor class RNNModel(nn.Module): """Container module with an encoder, a recurrent module, and a decoder.""" def...
pytorch-master
test/onnx/model_defs/word_language_model.py
import torch import torch.nn as nn import torch.nn.init as init class Fire(nn.Module): def __init__(self, inplanes, squeeze_planes, expand1x1_planes, expand3x3_planes): super().__init__() self.inplanes = inplanes self.squeeze = nn.Conv2d(inplanes, squeeze_planes, kernel_size=1) sel...
pytorch-master
test/onnx/model_defs/squeezenet.py
from torch import nn from torch.nn.utils.rnn import PackedSequence class LstmFlatteningResult(nn.LSTM): def forward(self, input, *fargs, **fkwargs): output, (hidden, cell) = nn.LSTM.forward(self, input, *fargs, **fkwargs) return output, hidden, cell class LstmFlatteningResultWithSeqLength(nn.Mod...
pytorch-master
test/onnx/model_defs/lstm_flattening_result.py
from .op_test import * # noqa: F403 from .squeezenet import * # noqa: F403 from .srresnet import * # noqa: F403 from .super_resolution import * # noqa: F403
pytorch-master
test/onnx/model_defs/__init__.py
import torch import torch.nn as nn # configurable bsz = 64 imgsz = 64 nz = 100 ngf = 64 ndf = 64 nc = 3 # custom weights initialization called on netG and netD def weights_init(m): classname = m.__class__.__name__ if classname.find("Conv") != -1: m.weight.data.normal_(0.0, 0.02) elif classname.fi...
pytorch-master
test/onnx/model_defs/dcgan.py
import math from torch import nn from torch.nn import init def _initialize_orthogonal(conv): prelu_gain = math.sqrt(2) init.orthogonal(conv.weight, gain=prelu_gain) if conv.bias is not None: conv.bias.data.zero_() class ResidualBlock(nn.Module): def __init__(self, n_filters): super(...
pytorch-master
test/onnx/model_defs/srresnet.py
# Owner(s): ["module: onnx"] import torch import torch.nn as nn class DummyNet(nn.Module): def __init__(self, num_classes=1000): super().__init__() self.features = nn.Sequential( nn.LeakyReLU(0.02), nn.BatchNorm2d(3), nn.AvgPool2d(kernel_size=3, stride=2, paddi...
pytorch-master
test/onnx/model_defs/op_test.py
import torch.nn as nn import torch.nn.functional as F class MNIST(nn.Module): def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 10, kernel_size=5) self.conv2 = nn.Conv2d(10, 20, kernel_size=5) self.conv2_drop = nn.Dropout2d() self.fc1 = nn.Linear(320, 50) ...
pytorch-master
test/onnx/model_defs/mnist.py
from torch import nn from torch.nn.utils import rnn as rnn_utils class RnnModelWithPackedSequence(nn.Module): def __init__(self, model, batch_first): super().__init__() self.model = model self.batch_first = batch_first def forward(self, input, *args): args, seq_lengths = args[...
pytorch-master
test/onnx/model_defs/rnn_model_with_packed_sequence.py
# Owner(s): ["module: onnx"] """Tests for `torch.onnx.symbolic_opset9`.""" import torch from torch import _C from torch.onnx import symbolic_opset9 as opset9 from torch.testing._internal import common_utils class TestPrim(common_utils.TestCase): def setUp(self): super().setUp() self.graph = _C.Gr...
pytorch-master
test/onnx/symbolic_opsets/test_symbolic_opset9.py
import argparse import os.path import sys import torch def get_custom_op_library_path(): if sys.platform.startswith("win32"): library_filename = "custom_ops.dll" elif sys.platform.startswith("darwin"): library_filename = "libcustom_ops.dylib" else: library_filename = "libcustom_op...
pytorch-master
test/custom_operator/model.py
# Owner(s): ["module: unknown"] import os.path import tempfile import torch from torch import ops from model import Model, get_custom_op_library_path from torch.testing._internal.common_utils import TestCase, run_tests class TestCustomOperators(TestCase): def setUp(self): self.library_path = get_custom...
pytorch-master
test/custom_operator/test_custom_ops.py
# Owner(s): ["module: unknown"] import unittest import torch from torch import ops import torch.jit as jit import glob import os from torch.testing._internal.common_utils import TestCase, run_tests def get_custom_class_library_path(): library_filename = glob.glob("build/*custom_class*") assert (len(library_...
pytorch-master
test/custom_operator/test_custom_classes.py
pytorch-master
test/cpp_api_parity/__init__.py
from collections import namedtuple ParityStatus = namedtuple('ParityStatus', ['has_impl_parity', 'has_doc_parity']) ''' This function expects the parity tracker Markdown file to have the following format: ``` ## package1_name API | Implementation Parity | Doc Parity ------------- | ------------- | ------------- API...
pytorch-master
test/cpp_api_parity/parity_table_parser.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 #...
pytorch-master
test/cpp_api_parity/functional_impl_check.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...
pytorch-master
test/cpp_api_parity/sample_functional.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...
pytorch-master
test/cpp_api_parity/utils.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...
pytorch-master
test/cpp_api_parity/module_impl_check.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...
pytorch-master
test/cpp_api_parity/sample_module.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...
pytorch-master
test/distributed/test_c10d_pypg.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...
pytorch-master
test/distributed/test_distributed_spawn.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 ( ...
pytorch-master
test/distributed/test_c10d_object_collectives.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, ...
pytorch-master
test/distributed/test_nccl.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...
pytorch-master
test/distributed/test_data_parallel.py
# Owner(s): ["oncall: distributed"] import os 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 if not dist.is_available(): print("torch.distributed not available, skipping tests", file=...
pytorch-master
test/distributed/test_store.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 ( ...
pytorch-master
test/distributed/test_c10d_spawn_nccl.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...
pytorch-master
test/distributed/argparse_util_test.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(): print("c10d not available, skipping te...
pytorch-master
test/distributed/test_c10d_gloo.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...
pytorch-master
test/distributed/test_c10d_spawn.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...
pytorch-master
test/distributed/test_c10d_spawn_gloo.py
# Owner(s): ["oncall: distributed"] import copy import math import os import random import signal import sys import tempfile import threading import time from contextlib import contextmanager from datetime import timedelta from itertools import product from unittest import mock import torch import torch.distributed a...
pytorch-master
test/distributed/test_c10d_nccl.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...
pytorch-master
test/distributed/test_pg_wrapper.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...
pytorch-master
test/distributed/test_launcher.py
# Owner(s): ["oncall: distributed"] import copy import os import sys import tempfile import threading import time from datetime import timedelta from itertools import product from sys import platform from contextlib import suppress import torch import torch.distributed as dist if not dist.is_available(): print("...
pytorch-master
test/distributed/test_c10d_common.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. import tempfile import pytest import torch import torch.distributed as dist @pytest.fixtu...
pytorch-master
test/distributed/pipeline/sync/conftest.py
# Owner(s): ["oncall: distributed"] # Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.distribu...
pytorch-master
test/distributed/pipeline/sync/test_transparency.py
# Owner(s): ["oncall: distributed"] # Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from torch import nn from ...
pytorch-master
test/distributed/pipeline/sync/test_inplace.py