python_code stringlengths 0 1.02M | repo_name stringlengths 9 48 | file_path stringlengths 5 114 |
|---|---|---|
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... | pytorch-master | test/error_messages/storage.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"
| pytorch-master | test/typing/fail/creation_ops.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"
| pytorch-master | test/typing/fail/random.py |
# flake8: noqa
import torch
# binary ops: <<, >>, |, &, ~, ^
a = torch.ones(3, dtype=torch.float64)
i = int()
i | a # E: Unsupported operand types
| pytorch-master | test/typing/fail/bitwise_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(... | pytorch-master | test/typing/pass/creation_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... | pytorch-master | test/typing/pass/math_ops.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... | pytorch-master | test/typing/reveal/opt_size.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}
| pytorch-master | test/typing/reveal/tensor_copy.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
| pytorch-master | test/typing/reveal/size.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]... | pytorch-master | test/typing/reveal/namedtuple.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)
| pytorch-master | test/typing/reveal/torch_optim.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]])) ... | pytorch-master | test/typing/reveal/tensor_constructors.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.... | pytorch-master | test/typing/reveal/tensor_sampling.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}
| pytorch-master | test/typing/reveal/module_list.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... | pytorch-master | test/mobile/test_upgraders.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_... | pytorch-master | test/mobile/test_bytecode.py |
# Owner(s): ["oncall: mobile"]
import torch
import torch.nn as nn
import torch.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 (
... | pytorch-master | test/mobile/test_quantize_fx_lite_script_module.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
... | pytorch-master | test/mobile/test_upgrader_codegen.py |
# Owner(s): ["oncall: mobile"]
import torch
import torch.utils.bundled_inputs
import io
from typing import Dict, List, NamedTuple
from torch.jit.mobile import _load_for_lite_interpreter
from torch.testing._internal.common_utils import TestCase, run_tests
from collections import namedtuple
class TestLiteScriptModule... | pytorch-master | 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
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... | pytorch-master | test/mobile/test_lite_script_module.py |
import torch
from torch import nn
class NeuralNetwork(nn.Module):
def __init__(self):
super(NeuralNetwork, self).__init__()
def forward(self, x):
return torch.add(x, 10)
model = NeuralNetwork()
script = torch.jit.script(model)
torch.jit.save(script, "aot_test_model.pt")
| pytorch-master | test/mobile/nnc/aot_test_model.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 ... | pytorch-master | test/mobile/lightweight_dispatch/tests_setup.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... | pytorch-master | test/mobile/custom_build/prepare_model.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... | pytorch-master | test/mobile/model_test/update_production_ops.py |
from typing import Dict, List, Tuple, Optional
import torch
from torch import Tensor
class AndroidAPIModule(torch.jit.ScriptModule):
def __init__(self):
super(AndroidAPIModule, self).__init__()
@torch.jit.script_method
def forward(self, input):
return None
@torch.jit.script_method
... | pytorch-master | test/mobile/model_test/android_api_module.py |
import torch
# https://pytorch.org/docs/stable/jit_builtin_functions.html#builtin-functions
class TSBuiltinOpsModule(torch.nn.Module):
def __init__(self):
super(TSBuiltinOpsModule, self).__init__()
def forward(self):
x = torch.tensor(1)
y = torch.tensor(0.5)
b = float(1)
... | pytorch-master | test/mobile/model_test/builtin_ops.py |
import torch
class TensorOpsModule(torch.nn.Module):
def __init__(self):
super(TensorOpsModule, self).__init__()
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,))
... | pytorch-master | test/mobile/model_test/tensor_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(NNConvolutionModule, self).__init__()
self.input1d = torch.randn(1, 4, 36)
self.input2d = torch.randn(1, 4, 30, ... | pytorch-master | test/mobile/model_test/nn_ops.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 __init__(self):
super(MobileNetV2Module, self).__init__()
def getModule(self):
model = torchvision... | pytorch-master | test/mobile/model_test/torchvision_models.py |
import torch
# https://pytorch.org/docs/stable/torch.html#random-sampling
class SamplingOpsModule(torch.nn.Module):
def __init__(self):
super(SamplingOpsModule, self).__init__()
def forward(self):
a = torch.empty(3, 3).uniform_(0.0, 1.0)
size = (1, 4)
weights = torch.tensor([... | pytorch-master | test/mobile/model_test/sampling_ops.py |
import torch
import torch.nn as nn
class GeneralQuantModule(torch.nn.Module):
def __init__(self):
super(GeneralQuantModule, self).__init__()
self.embedding = torch.nn.quantized.Embedding(
num_embeddings=10, embedding_dim=12
)
self.embedding_input = torch.tensor([9, 6, 5... | pytorch-master | test/mobile/model_test/quantization_ops.py |
# https://pytorch.org/docs/stable/torch.html#math-operations
import math
import torch
class PointwiseOpsModule(torch.nn.Module):
def __init__(self):
super(PointwiseOpsModule, self).__init__()
def forward(self):
return self.pointwise_ops()
def pointwise_ops(self):
a = torch.rand... | pytorch-master | test/mobile/model_test/math_ops.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,
... | pytorch-master | test/mobile/model_test/gen_test_model.py |
pytorch-master | test/cpp/__init__.py | |
import sys
import os
import torch
class Setup(object):
def setup(self):
raise NotImplementedError()
def shutdown(self):
raise NotImplementedError()
class FileSetup(object):
path = None
def shutdown(self):
if os.path.exists(self.path):
os.remove(self.path)
... | pytorch-master | test/cpp/jit/tests_setup.py |
pytorch-master | test/cpp/jit/__init__.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... | pytorch-master | test/cpp/api/init_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:... | pytorch-master | test/cpp/api/optim_baseline.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import tempfile
import random
from textwrap import dedent
import torch
from torch.testing._internal.jit_utils import JitTestCase, execWrapper
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sy... | pytorch-master | test/jit/test_python_builtins.py |
# Owner(s): ["oncall: jit"]
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase
from typing import Dict, Any, List
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
if _... | pytorch-master | test/jit/test_module_apis.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
import torch
import torch._C
from pathlib import Path
from test_nnapi import TestNNAPI
from torch.testing._internal.common_utils import TEST_WITH_ASAN
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.pat... | pytorch-master | test/jit/test_backend_nnapi.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import inspect
import unittest
from typing import Dict, List
import torch
from torch.testing import FileCheck
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
... | pytorch-master | test/jit/test_builtins.py |
r"""
Define exceptions used in test_exception.py. We define them in a
separate file on purpose to make sure the fully qualified exception class name
is captured correctly in suce cases.
"""
class MyKeyError(KeyError):
def __init__(self, msg):
super(KeyError, self).__init__(msg)
| pytorch-master | test/jit/myexception.py |
# Owner(s): ["oncall: jit"]
import torch
from typing import List, Tuple
class SubmoduleNoForwardInputs(torch.nn.Module):
def __init__(self, name):
super().__init__()
self.name = name
def forward(self):
assert self.name == "inner_mod_name"
class ModuleNoForwardInputs(torch.nn.Module... | pytorch-master | test/jit/test_hooks_modules.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing import FileCheck
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == "__main__":
raise RuntimeError(
"This test file is not meant to be run directly, use:\n\n"
"\tpython test/test_jit.py TESTNAME\n\n"
"instead... | pytorch-master | test/jit/test_batch_mm.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import io
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing._internal.... | pytorch-master | test/jit/test_type_sharing.py |
# Owner(s): ["oncall: mobile"]
import torch
import torch._C
import torch.nn.functional as F
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing._internal.common_utils import skipIfNoXNNPACK
class TestOptimizeForMobilePreserveDebugInfo(JitTestCase):
def check_replacement(
self,
... | pytorch-master | test/jit/test_optimize_for_mobile_preserve_debug_info.py |
# Owner(s): ["oncall: jit"]
from torch.testing._internal.jit_utils import JitTestCase
from torch._C import parse_ir
import torch
if __name__ == '__main__':
raise RuntimeError("This test file is not meant to be run directly, use:\n\n"
"\tpython test/test_jit.py TESTNAME\n\n"
... | pytorch-master | test/jit/test_alias_analysis.py |
# Owner(s): ["oncall: jit"]
from typing import Any, Dict, List, Optional, Tuple
from torch.testing._internal.jit_utils import JitTestCase, make_global
from torch.testing import FileCheck
from torch import jit
from jit.test_module_interface import TestModuleInterface # noqa: F401
import os
import sys
import torch
imp... | pytorch-master | test/jit/test_misc.py |
# Owner(s): ["oncall: jit"]
import io
import os
import shutil
import sys
import tempfile
import torch
import torch.nn as nn
from torch.onnx import OperatorExportTypes
from torch.autograd import Variable
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__... | pytorch-master | test/jit/test_export_modes.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '__main__':
raise R... | pytorch-master | test/jit/test_logging.py |
# Owner(s): ["oncall: jit"]
import os
import sys
from typing import Any, List
import torch
from torch.testing._internal.jit_utils import JitTestCase, make_global
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_... | pytorch-master | test/jit/test_with.py |
# Owner(s): ["oncall: jit"]
from itertools import product
from typing import Tuple
from unittest.case import expectedFailure
import torch
from torch import complex32, float32, float64, int32, int64
from torch.jit._passes import _property_propagation
from torch.testing._internal.common_methods_invocations import (
... | pytorch-master | test/jit/test_dtype_analysis.py |
# Owner(s): ["oncall: jit"]
import io
import torch
import unittest
from torch.testing._internal.common_utils import IS_WINDOWS, TEST_MKL
from torch.testing._internal.jit_utils import JitTestCase
class TestSparse(JitTestCase):
def test_freeze_sparse_coo(self):
class SparseTensorModule(torch.nn.Module):
... | pytorch-master | test/jit/test_sparse.py |
# Owner(s): ["oncall: jit"]
from itertools import product
import unittest
import torch
from torch.testing._internal.common_utils import TEST_CUDA
from torch.testing._internal.jit_utils import JitTestCase
from torch.jit._passes._property_propagation import apply_input_props_using_example
try:
from torchvision imp... | pytorch-master | test/jit/test_device_analysis.py |
# Owner(s): ["oncall: jit"]
import io
import os
import sys
import torch
import torch.nn as nn
from typing import Any, Tuple
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_u... | pytorch-master | test/jit/test_async.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import io
import torch
import warnings
from contextlib import redirect_stderr
from torch.testing import FileCheck
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_d... | pytorch-master | test/jit/test_warn.py |
# Owner(s): ["oncall: jit"]
import os
import sys
from textwrap import dedent
import unittest
import torch
from torch.testing._internal import jit_utils
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from t... | pytorch-master | test/jit/test_jit_utils.py |
# Owner(s): ["oncall: jit"]
from itertools import product as product
import io
import os
import sys
import hypothesis.strategies as st
from hypothesis import example, settings, given
from typing import Union
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(o... | pytorch-master | test/jit/test_save_load_for_op_version.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
from torch.jit.frontend... | pytorch-master | test/jit/test_ignore_context_manager.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from typing import List
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ ==... | pytorch-master | test/jit/test_string_formatting.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing._internal.common_utils import IS_WINDOWS
from collections import namedtuple
from typing import List, Tuple, Optional, Dict
# Make the helper files in test/ importable
pytorch_tes... | pytorch-master | test/jit/test_typing.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from torch.testing._internal.jit_utils import JitTestCase, make_global
from torch.jit._monkeytype_config import _IS_MONKEYTYPE_INSTALLED
from typing import List, Dict, Tuple, Any, Optional, NamedTuple # noqa: F401
# Make the helper files in test/ importab... | pytorch-master | test/jit/test_pdt.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '__main__':
raise R... | pytorch-master | test/jit/test_tensor_creation_ops.py |
pytorch-master | test/jit/__init__.py | |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '__main... | pytorch-master | test/jit/test_custom_operators.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
from torch.testing._internal.common_utils import GRAPH_EXECUTOR, ProfilingMode, \
num_profiled_runs, enable_profiling_mode_for_profiling_tests
from torch.testing._internal.common_jit import check_against_reference
import torch
# Make the helper file... | pytorch-master | test/jit/test_autodiff_subgraph_slicing.py |
# Owner(s): ["oncall: jit"]
import unittest
import io
import os
import sys
import copy
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable, Function
from torch.testing import FileCheck
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os... | pytorch-master | test/jit/test_tracer.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
import torch
import torch.nn as nn
import torch.nn.parallel as dp
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal... | pytorch-master | test/jit/test_data_parallel.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import types
import typing
import typing_extensions
from typing import List, Dict, Optional, Tuple
import torch
import torch.nn as nn
from torch import Tensor
from torch.testing import FileCheck
from collections import OrderedDict
# Make the helper files in test/ impo... | pytorch-master | test/jit/test_recursive_script.py |
# Owner(s): ["oncall: jit"]
import torch
from torch import nn
import torch.nn.utils.parametrize as parametrize
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '__main__':
raise RuntimeError("This test file is not meant to be run directly, use:\n\n"
"\tpython test... | pytorch-master | test/jit/test_parametrization.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import warnings
import torch
from typing import List, Dict, Optional
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils im... | pytorch-master | test/jit/test_scriptmod_ann.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing import FileCheck
if... | pytorch-master | test/jit/test_tensor_methods.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing._internal.jit_utils import JitTestCase, RUN_CUDA, _inline_everything
from torch import nn
from torch.testing import FileCheck
from typing import Callable, List
import unittest
if __name__ == '__main__':
raise RuntimeError("This test file is not meant to... | pytorch-master | test/jit/test_peephole.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
import unittest
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '__main... | pytorch-master | test/jit/test_unsupported_ops.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from torch import nn
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '_... | pytorch-master | test/jit/test_script_profile.py |
# Owner(s): ["oncall: jit"]
import io
import os
import sys
import torch
from torch.testing import FileCheck
from enum import Enum
from textwrap import dedent
from typing import Dict, List, Optional, Tuple, Union
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.re... | pytorch-master | test/jit/test_union.py |
# Owner(s): ["oncall: jit"]
from typing import List, Any
import torch
import torch.nn as nn
import os
import sys
from torch import Tensor
from torch.testing._internal.jit_utils import JitTestCase, make_global
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpa... | pytorch-master | test/jit/test_module_interface.py |
# Owner(s): ["oncall: jit"]
import io
import os
import sys
import torch
import zipfile
from torch.testing import FileCheck
from typing import Union
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.t... | pytorch-master | test/jit/test_upgraders.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == "__main__":
raise R... | pytorch-master | test/jit/test_ivalue.py |
# Owner(s): ["oncall: jit"]
# flake8: noqa
from dataclasses import dataclass, field, InitVar
from hypothesis import given, settings, strategies as st
from torch.testing._internal.jit_utils import JitTestCase
from typing import List, Optional
import sys
import torch
import unittest
from enum import Enum
# Example jitt... | pytorch-master | test/jit/test_dataclasses.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
import torch
# as with test_jit tests, requires global dtype set
torch.set_default_dtype(torch.double)
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_... | pytorch-master | test/jit/test_complexity.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing._internal.common_utils import TestCase
class TestAtenPow(TestCase):
def test_aten_pow_zero_negative_exponent(self):
'''
1. Testing a = int, b = int
'''
@torch.jit.script
def fn_int_int(a: int, b: int):
... | pytorch-master | test/jit/test_aten_pow.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
from typing import Tuple
import torch
from jit.test_hooks_modules import (
ModuleDirectforwardSubmodCall, ModuleForwardSingleInput,
ModuleForwardTupleInput, create_forward_tuple_input,
create_module_forward_multiple_inputs, create_module_for... | pytorch-master | test/jit/test_hooks.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase, warmup_backward, FileCheck
if __name_... | pytorch-master | test/jit/test_profiler.py |
# Owner(s): ["oncall: jit"]
import io
import os
import pathlib
import sys
import unittest
from typing import NamedTuple, Optional
import torch
from torch import Tensor
from torch.testing._internal.common_utils import TemporaryFileName
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.... | pytorch-master | test/jit/test_save_load.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from torch.testing import FileCheck
from typing import List
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_util... | pytorch-master | test/jit/test_remove_mutation.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing import FileCheck
from torch.testing._internal.jit_utils import JitTestCase
if __name__ == '__main__':
raise RuntimeError("This test file is not meant to be run directly, use:\n\n"
"\tpython test/test_jit.py TESTNAME\n\n"
... | pytorch-master | test/jit/test_op_decompositions.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import gc
import unittest
import torch
from typing import NamedTuple
from torch.testing import FileCheck
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing._internal.common_utils import skipIfRocm, skipCUDANonDefaultStreamIf
# Make the helper... | pytorch-master | test/jit/test_cuda.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing._internal.jit_utils import JitTestCase
class TestFuserCommon(JitTestCase):
def test_autodiff_fallback(self):
for rq in [True, False]:
@torch.jit.script
def fn(x):
return torch.max(x**2.0, x**3.0)
... | pytorch-master | test/jit/test_fuser_common.py |
# Owner(s): ["oncall: jit"]
from torch.testing._internal.common_utils import TestCase
import torch
from torch import nn
r"""
Test TorchScript exception handling.
"""
class TestException(TestCase):
def test_pyop_exception_message(self):
class Foo(torch.jit.ScriptModule):
def __init__(self):
... | pytorch-master | test/jit/test_exception.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from typing import Tuple, List
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __n... | pytorch-master | test/jit/test_hash.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing._internal.jit_utils import JitTestCase
from typing import List
class TestAutodiffJit(JitTestCase):
def test_undefined_tensor_lists(self):
def fn(tensor_list: List[torch.Tensor], add_tensor):
cat = torch.cat(tensor_list, dim=1)
... | pytorch-master | test/jit/test_autodiff.py |
# Owner(s): ["oncall: jit"]
import os
import sys
from typing import Any, List, Tuple
from collections import OrderedDict
import torch
import torch.nn as nn
from torch.testing._internal.jit_utils import JitTestCase
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.... | pytorch-master | test/jit/test_module_containers.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import unittest
from torch.testing._internal.common_utils import enable_profiling_mode_for_profiling_tests, GRAPH_EXECUTOR, ProfilingMode
import torch
import torch.nn as nn
import torch.nn.functional as F
# Make the helper files in test/ importable
pytorch_test_dir = o... | pytorch-master | test/jit/test_models.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from torch._C import parse_ir
from torch.testing import FileCheck
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit... | pytorch-master | test/jit/test_ignorable_args.py |
# Owner(s): ["oncall: jit"]
import io
import unittest
from itertools import product
from typing import Any
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.jit._recursive import wrap_cpp_module
from torch.testing import FileCheck
from torch.testing._internal.common_quantization import ski... | pytorch-master | test/jit/test_freezing.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from typing import List
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch.testing._internal.jit_utils import JitTestCase
if __name__ ==... | pytorch-master | test/jit/test_slice.py |
# Owner(s): ["oncall: jit"]
import operator
import unittest
from textwrap import dedent
import torch
from torch import nn
from torch.testing import FileCheck
from torch.testing._internal.common_methods_invocations import sample_inputs_cat_concat
from torch.testing._internal.common_utils import make_tensor
from torch.... | pytorch-master | test/jit/test_symbolic_shape_analysis.py |
# Owner(s): ["oncall: jit"]
from torch.testing._internal.jit_utils import JitTestCase
import io
import os
import sys
import unittest
import torch
import torch._C
from torch.testing import FileCheck
from torch.jit.mobile import _load_for_lite_interpreter
from torch.testing._internal.common_utils import (
IS_FBCOD... | pytorch-master | test/jit/test_backends.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.