python_code stringlengths 0 1.02M | repo_name stringlengths 9 48 | file_path stringlengths 5 114 |
|---|---|---|
# Owner(s): ["oncall: jit"]
import io
import os
import sys
import copy
import unittest
import torch
from typing import 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.ji... | pytorch-master | test/jit/test_torchbind.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import inspect
import unittest
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
from textwrap import dedent
from collections import OrderedDict
from torch import Tensor
import torch
import torch.nn as nn
import types
from torch.testing import FileCheck
... | pytorch-master | test/jit/test_list_dict.py |
# Owner(s): ["oncall: jit"]
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase, execWrapper
from torch.testing._internal.common_utils import IS_MACOS
from typing import List, Dict
from itertools import product
from textwrap import dedent
import cmath
# Make the helper files in... | pytorch-master | test/jit/test_complex.py |
# Owner(s): ["oncall: jit"]
import torch
from torch.testing import FileCheck
from torch.testing._internal.jit_utils import JitTestCase, make_global
class TestDCE(JitTestCase):
def test_setattr_no_aliasdb(self):
class Net(torch.nn.Module):
def __init__(self):
super().__init__()... | pytorch-master | test/jit/test_dce.py |
# Owner(s): ["oncall: jit"]
import torch
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.")
class Test... | pytorch-master | test/jit/test_python_ir.py |
# Owner(s): ["oncall: jit"]
from torch.testing import FileCheck
from torch.testing._internal.jit_utils import JitTestCase
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_attr.py |
# Owner(s): ["oncall: jit"]
import os
import sys
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)
from torch.testing._internal.jit_utils import JitTestCase
if... | pytorch-master | test/jit/test_functional_blocks.py |
# Owner(s): ["oncall: jit"]
import torch
import os
import sys
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.realpath(__file__)))
sys.path.append(pytorch_test_dir)
if __name__ == '__main__':
raise Ru... | pytorch-master | test/jit/test_modules.py |
# Owner(s): ["oncall: jit"]
import os
import sys
from itertools import product
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.testing import FileCheck
import unittest
try:
import torchvision
HAS_TORCHVISION = True
except ImportError:
HAS_TORCHVISION = False
skipIfNoTorchVis... | pytorch-master | test/jit/test_convert_activation.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
import warnings
from typing import List, Any, Dict, Tuple, 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.... | pytorch-master | test/jit/test_isinstance.py |
# Owner(s): ["oncall: jit"]
import io
import os
import sys
import unittest
import torch
import torch.nn as nn
from torch.testing import FileCheck
from typing import Any
# 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_class_type.py |
# Owner(s): ["oncall: jit"]
from torch.testing._internal.jit_utils import JitTestCase
import torch
import torch._C
from torch.testing import FileCheck
class TestGraphRewritePasses(JitTestCase):
def test_fuse_linear(self):
class FunctionalLinear(torch.nn.Module):
def __init__(self, weight, bia... | pytorch-master | test/jit/test_graph_rewrite_passes.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 TestPythonBindings\n\n"
... | pytorch-master | test/jit/test_python_bindings.py |
# Owner(s): ["oncall: jit"]
from collections import namedtuple
from typing import Dict, List, Optional, Tuple
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing import FileCheck
from textwrap import dedent
from jit.test_module_interface import TestModuleInterface # noqa: F401
import inspect... | pytorch-master | test/jit/test_types.py |
# Owner(s): ["oncall: jit"]
import os
import sys
import torch
from torch.testing import FileCheck
from enum import Enum
from typing import 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)
from torch... | pytorch-master | test/jit/test_enum.py |
pytorch-master | test/jit/_imported_class_test/__init__.py | |
import torch
# This file contains definitions of script classes.
# They are used by test_jit.py to test ScriptClass imports
@torch.jit.script # noqa: B903
class FooSameName(object): # noqa: B903
def __init__(self, y):
self.y = y
| pytorch-master | test/jit/_imported_class_test/bar.py |
import torch
from . import bar
# This file contains definitions of script classes.
# They are used by test_jit.py to test ScriptClass imports
@torch.jit.script # noqa: B903
class FooSameName(object):
def __init__(self, x):
self.x = x
self.nested = bar.FooSameName(x)
| pytorch-master | test/jit/_imported_class_test/foo.py |
pytorch-master | test/jit/_imported_class_test/very/__init__.py | |
pytorch-master | test/jit/_imported_class_test/very/very/__init__.py | |
import torch
# This file contains definitions of script classes.
# They are used by test_jit.py to test ScriptClass imports
@torch.jit.script # noqa: B903
class FooUniqueName(object): # noqa: B903
def __init__(self, y):
self.y = y
| pytorch-master | test/jit/_imported_class_test/very/very/nested.py |
import torch
from typing import Union
class TestVersionedDivTensorExampleV7(torch.nn.Module):
def __init__(self):
super(TestVersionedDivTensorExampleV7, self).__init__()
def forward(self, a, b):
result_0 = a / b
result_1 = torch.div(a, b)
result_2 = a.div(b)
return resu... | pytorch-master | test/jit/fixtures_srcs/fixtures_src.py |
import io
import logging
import sys
import zipfile
from pathlib import Path
from typing import Set
import torch
# Use asterisk symbol so developer doesn't need to import here when they add tests for upgraders.
from test.jit.fixtures_srcs.fixtures_src import * # noqa: F403
from torch.jit.mobile import _load_for_lite_i... | pytorch-master | test/jit/fixtures_srcs/generate_models.py |
pytorch-master | test/jit/fixtures_srcs/__init__.py | |
# Owner(s): ["oncall: mobile"]
import torch
from test.jit.fixtures_srcs.generate_models import ALL_MODULES
from torch.testing._internal.common_utils import TestCase, run_tests
class TestUpgraderModelGeneration(TestCase):
def test_all_modules(self):
for a_module, expect_operator in ALL_MODULES.items():
... | pytorch-master | test/jit/fixtures_srcs/test_upgrader_models_generation.py |
import argparse
import os
import sys
import torch
# grab modules from test_jit_hooks.cpp
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from jit.test_hooks_modules import (
create_forward_tuple_input, create_module_forward_multiple_inputs,
crea... | pytorch-master | test/jit_hooks/model.py |
# this file contains a simple parser that parses report
# from cuda-memcheck
class ParseError(Exception):
"""Whenever the simple parser is unable to parse the report, this exception will be raised"""
pass
class Report:
"""A report is a container of errors, and a summary on how many errors are found"""
... | pytorch-master | test/scripts/cuda_memcheck_common.py |
#!/usr/bin/env python3
"""This script runs cuda-memcheck on the specified unit test. Each test case
is run in its isolated process with a timeout so that:
1) different test cases won't influence each other, and
2) in case of hang, the script would still finish in a finite amount of time.
The output will be written to ... | pytorch-master | test/scripts/run_cuda_memcheck.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import logging
import torch
import torch.ao.quantization as tq
from torch import nn
from torch.ao import sparsity
from torch.testing._internal.common_utils import TestCase
from torch.ao.quantization.quantize_fx import prepare_fx, convert_fx, convert_to_referenc... | pytorch-master | test/ao/sparsity/test_composability.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import copy
import logging
import torch
from torch import nn
from torch.ao.sparsity._experimental.pruner import BasePruner, PruningParametrization, ZeroesParametrization
from torch.nn.utils import parametrize
from torch.testing._internal.common_utils import Te... | pytorch-master | test/ao/sparsity/test_pruner.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import logging
import warnings
from torch.testing._internal.common_utils import TestCase
from torch import nn
import torch
from typing import Tuple
import copy
from torch.ao.sparsity._experimental.data_sparsifier import DataNormSparsifier
from torch.ao.sparsity.... | pytorch-master | test/ao/sparsity/test_data_scheduler.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import logging
from torch import nn
from torch.ao.sparsity.sparsifier import utils
from torch.nn.utils import parametrize
import torch
from torch.testing._internal.common_utils import TestCase
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s... | pytorch-master | test/ao/sparsity/test_parametrization.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
from torch import nn
from torch.ao.sparsity import WeightNormSparsifier
from torch.ao.sparsity import BaseScheduler, LambdaSL
from torch.testing._internal.common_utils import TestCase
import warnings
class ImplementedScheduler(BaseScheduler):
def get_sl(se... | pytorch-master | test/ao/sparsity/test_scheduler.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import logging
import torch
from torch.ao.sparsity.sparsifier.utils import (
fqn_to_module,
get_arg_info_from_tensor_fqn,
module_to_fqn,
)
from torch.testing._internal.common_quantization import (
ConvBnReLUModel,
ConvModel,
FunctionalL... | pytorch-master | test/ao/sparsity/test_sparsity_utils.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
from torch.testing._internal.common_utils import run_tests
import copy
import numpy as np
import io
import logging
from itertools import product
import torch
import torch.ao.quantization as tq
from torch import nn
from torch.ao.sparsity.sparsifier.utils import... | pytorch-master | test/ao/sparsity/test_kernels.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import copy
from torch.testing._internal.common_utils import TestCase, skipIfTorchDynamo
import logging
import torch
from torch.ao.sparsity._experimental.activation_sparsifier.activation_sparsifier import ActivationSparsifier
import torch.nn as nn
import torch.nn... | pytorch-master | test/ao/sparsity/test_activation_sparsifier.py |
#!/usr/bin/env python3
# Owner(s): ["oncall: mobile"]
import tempfile
import torch
from torch.ao.nn.sparse.quantized.dynamic.linear import Linear
from torch.testing._internal.common_quantized import (
qengine_is_qnnpack,
override_quantized_engine,
override_cpu_allocator_for_qnnpack
)
from torch.testing._in... | pytorch-master | test/ao/sparsity/test_qlinear_packed_params.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import itertools
import logging
import re
import torch
from torch import nn
from torch.ao.sparsity import BaseSparsifier, WeightNormSparsifier, FakeSparsity, NearlyDiagonalSparsifier
from torch.nn.utils.parametrize import is_parametrized
from torch.testing._int... | pytorch-master | test/ao/sparsity/test_sparsifier.py |
# -*- coding: utf-8 -*-
# Owner(s): ["module: unknown"]
import logging
import torch
from torch.nn.utils.parametrize import is_parametrized
import unittest
from torch.testing._internal.common_utils import TestCase, TEST_WITH_ASAN
from typing import Tuple
from torch import nn
import itertools
import math
import copy
f... | pytorch-master | test/ao/sparsity/test_data_sparsifier.py |
# Owner(s): ["oncall: jit"]
import unittest
from torch._lazy.ts_backend import init as init_ts_backend
init_ts_backend()
from torch._lazy import config
from torch._lazy.extract_compiled_graph import extract_compiled_graph
import torch
from torch import nn
import dis
import inspect
from torch import fx
import re
from ... | pytorch-master | test/lazy/test_extract_compiled_graph.py |
# Owner(s): ["oncall: jit"]
import torch
import torch._lazy
import torch._lazy.config
import torch._lazy.ir_cache
import torch._lazy.ts_backend
import torch._lazy.metrics as metrics
from torch.testing._internal.common_utils import IS_WINDOWS, run_tests, TestCase
import os
import unittest
torch._lazy.ts_backend.init()... | pytorch-master | test/lazy/test_reuse_ir.py |
pytorch-master | test/lazy/__init__.py | |
# Owner(s): ["oncall: jit"]
from typing import Sequence
import torch
import functools
from torch.testing._internal.common_utils import run_tests, TestCase
from torch.testing._internal.jit_utils import JitTestCase
from torch.testing._internal.common_methods_invocations import op_db
from torch.testing._internal.common_... | pytorch-master | test/lazy/test_ts_opinfo.py |
# Owner(s): ["oncall: jit"]
import torch._lazy.metrics
def test_metrics():
names = torch._lazy.metrics.counter_names()
assert len(names) == 0, f"Expected no counter names, but got {names}"
| pytorch-master | test/lazy/test_bindings.py |
# Owner(s): ["module: unknown"]
import torch
x = torch.ones((3, 3), requires_grad=True)
(3 * x).sum().backward()
| pytorch-master | test/bottleneck_test/test.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... | pytorch-master | test/bottleneck_test/test_args.py |
# Owner(s): ["module: unknown"]
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
def forward(self, input):
out = self.linear(input[:, 10:30])
return out.sum()
def main():
data = ... | pytorch-master | test/bottleneck_test/test_cuda.py |
# Owner(s): ["module: distributions"]
import pytest
import torch
from torch.distributions.utils import tril_matrix_to_vec, vec_to_tril_matrix
@pytest.mark.parametrize('shape', [
(2, 2),
(3, 3),
(2, 4, 4),
(2, 2, 4, 4),
])
def test_tril_matrix_to_vec(shape):
mat = torch.randn(shape)
n = mat.s... | pytorch-master | test/distributions/test_utils.py |
# Owner(s): ["module: distributions"]
import pytest
import torch
from torch.distributions import biject_to, constraints, transform_to
from torch.testing._internal.common_cuda import TEST_CUDA
EXAMPLES = [
(constraints.symmetric, False, [[2., 0], [2., 2]]),
(constraints.positive_semidefinite, False, [[2., 0]... | pytorch-master | test/distributions/test_constraints.py |
# Owner(s): ["module: distributions"]
"""
Note [Randomized statistical tests]
-----------------------------------
This note describes how to maintain tests in this file as random sources
change. This file contains two types of randomized tests:
1. The easier type of randomized test are tests that should always pass ... | pytorch-master | test/distributions/test_distributions.py |
# Owner(s): ["module: distributions"]
import io
from numbers import Number
import pytest
import torch
from torch.autograd.functional import jacobian
from torch.distributions import Dirichlet, Independent, Normal, TransformedDistribution, constraints
from torch.distributions.transforms import (AbsTransform, AffineTra... | pytorch-master | test/distributions/test_transforms.py |
# -*- coding: utf-8 -*-
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
from sys import version_info
from textwrap import dedent
from unittest import skipIf
from torch.package import PackageExporter, PackageImporter
from torch.testing._internal.common_utils import run_tests
try:
from .common import... | pytorch-master | test/package/test_resources.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
from textwrap import dedent
from unittest import skipIf
import torch
from torch.package import PackageExporter, PackageImporter, sys_importer
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
try:
from torchvision.mo... | pytorch-master | test/package/test_model.py |
# Owner(s): ["oncall: package/deploy"]
import importlib
from io import BytesIO
from sys import version_info
from textwrap import dedent
from unittest import skipIf
import torch.nn
from torch.package import EmptyMatchError, Importer, PackageExporter, PackageImporter
from torch.package.package_exporter import Packagin... | pytorch-master | test/package/test_dependency_api.py |
result = "module_a"
| pytorch-master | test/package/module_a.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
from torch.package import PackageExporter, PackageImporter
from torch.package._mangling import (
demangle,
get_mangle_prefix,
is_mangled,
PackageMangler,
)
from torch.testing._internal.common_utils import run_tests
try:
from .common im... | pytorch-master | test/package/test_mangling.py |
# -*- coding: utf-8 -*-
# Owner(s): ["oncall: package/deploy"]
import inspect
import platform
from io import BytesIO
from pathlib import Path
from textwrap import dedent
from unittest import skipIf
from torch.package import is_from_package, PackageExporter, PackageImporter
from torch.package.package_exporter import P... | pytorch-master | test/package/test_misc.py |
# -*- coding: utf-8 -*-
# Owner(s): ["oncall: package/deploy"]
import os
import zipfile
from sys import version_info
from tempfile import TemporaryDirectory
from textwrap import dedent
from unittest import skipIf
import torch
from torch.package import PackageExporter, PackageImporter
from torch.testing._internal.comm... | pytorch-master | test/package/test_directory_reader.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
import torch
from torch.package import (
Importer,
OrderedImporter,
PackageExporter,
PackageImporter,
sys_importer,
)
from torch.testing._internal.common_utils import run_tests
try:
from .common import PackageTestCase
except Import... | pytorch-master | test/package/test_importer.py |
pytorch-master | test/package/__init__.py | |
# Owner(s): ["oncall: package/deploy"]
from typing import Iterable
from torch.package import GlobGroup
from torch.testing._internal.common_utils import run_tests
try:
from .common import PackageTestCase
except ImportError:
# Support the case where we run this file directly.
from common import PackageTest... | pytorch-master | test/package/test_glob_group.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
from textwrap import dedent
from unittest import skipIf
import torch
from torch.package import PackageExporter, PackageImporter
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
try:
from .common import PackageTestCa... | pytorch-master | test/package/test_package_script.py |
# Owner(s): ["oncall: package/deploy"]
import pickle
from io import BytesIO
from textwrap import dedent
from unittest import skipIf
from torch.package import PackageExporter, PackageImporter, sys_importer
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
try:
from .common impor... | pytorch-master | test/package/test_save_load.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
from torch.package import PackageExporter, PackageImporter, sys_importer
from torch.testing._internal.common_utils import run_tests
try:
from .common import PackageTestCase
except ImportError:
# Support the case where we run this file directly.
... | pytorch-master | test/package/test_repackage.py |
import os
import sys
from tempfile import NamedTemporaryFile
import torch.package.package_exporter
from torch.testing._internal.common_utils import IS_WINDOWS, TestCase
class PackageTestCase(TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._temporary_files = ... | pytorch-master | test/package/common.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
import torch
from torch.fx import Graph, GraphModule, symbolic_trace
from torch.package import (
ObjMismatchError,
PackageExporter,
PackageImporter,
sys_importer,
)
from torch.testing._internal.common_utils import run_tests
try:
from .... | pytorch-master | test/package/test_package_fx.py |
# Owner(s): ["oncall: package/deploy"]
from io import BytesIO
from torch.package import PackageExporter
from torch.testing._internal.common_utils import run_tests
try:
from .common import PackageTestCase
except ImportError:
# Support the case where we run this file directly.
from common import PackageTes... | pytorch-master | test/package/test_dependency_hooks.py |
from pathlib import Path
import torch
from torch.fx import symbolic_trace
from torch.package import PackageExporter
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE
packaging_directory = f"{Path(__file__).parent}/package_bc"
torch.package.package_exporter._gate_torchscript_serialization = Fal... | pytorch-master | test/package/generate_bc_packages.py |
# Owner(s): ["oncall: package/deploy"]
from pathlib import Path
from unittest import skipIf
from torch.package import PackageImporter
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
try:
from .common import PackageTestCase
except ImportError:
# Support the case where we r... | pytorch-master | test/package/test_load_bc_packages.py |
# Owner(s): ["oncall: package/deploy"]
import torch
from torch.package import analyze
from torch.testing._internal.common_utils import run_tests
try:
from .common import PackageTestCase
except ImportError:
# Support the case where we run this file directly.
from common import PackageTestCase
class TestA... | pytorch-master | test/package/test_analyze.py |
# Owner(s): ["oncall: package/deploy"]
from torch.package._digraph import DiGraph
from torch.testing._internal.common_utils import run_tests
try:
from .common import PackageTestCase
except ImportError:
# Support the case where we run this file directly.
from common import PackageTestCase
class TestDiGra... | pytorch-master | test/package/test_digraph.py |
result = "subpackage_1"
class PackageBSubpackage1Object_0:
__slots__ = ["obj"]
def __init__(self, obj):
self.obj = obj
def return_result(self):
return result
| pytorch-master | test/package/package_b/subpackage_1.py |
__import__("subpackage_1", globals(), fromlist=["PackageBSubpackage1Object_0"], level=1)
__import__("subpackage_0.subsubpackage_0", globals(), fromlist=[""], level=1)
__import__("subpackage_2", globals=globals(), locals=locals(), fromlist=["*"], level=1)
result = "package_b"
class PackageBObject:
__slots__ = ["o... | pytorch-master | test/package/package_b/__init__.py |
__import__("math", fromlist=[])
__import__("xml.sax.xmlreader")
result = "subpackage_2"
class PackageBSubpackage2Object_0:
pass
def dynamic_import_test(name: str):
__import__(name)
| pytorch-master | test/package/package_b/subpackage_2.py |
result = "subpackage_0"
| pytorch-master | test/package/package_b/subpackage_0/__init__.py |
__import__("subpackage_1", globals(), locals(), ["PackageBSubpackage1Object_0"], 3)
result = "subsubpackage_0"
class PackageBSubsubpackage0Object_0:
pass
| pytorch-master | test/package/package_b/subpackage_0/subsubpackage_0/__init__.py |
import torch
import yaml
class SumMod(torch.nn.Module):
def forward(self, inp):
return torch.sum(inp)
| pytorch-master | test/package/test_trace_dep/__init__.py |
# Owner(s): ["oncall: package/deploy"]
import torch
try:
from torchvision.models import resnet18
class TorchVisionTest(torch.nn.Module):
def __init__(self):
super().__init__()
self.tvmod = resnet18()
def forward(self, x):
x = a_non_torch_leaf(x, x)
... | pytorch-master | test/package/package_c/test_module.py |
result = "package_c"
class PackageCObject:
__slots__ = ["obj"]
def __init__(self, obj):
self.obj = obj
def return_result(self):
return result
| pytorch-master | test/package/package_c/__init__.py |
import torch
from .subpackage_0 import important_string
class ImportsIndirectlyFromSubPackage(torch.nn.Module):
key = important_string
def forward(self, inp):
return torch.sum(inp)
| pytorch-master | test/package/package_d/imports_indirectly.py |
pytorch-master | test/package/package_d/__init__.py | |
import torch
from .subpackage_0.subsubpackage_0 import important_string
class ImportsDirectlyFromSubSubPackage(torch.nn.Module):
key = important_string
def forward(self, inp):
return torch.sum(inp)
| pytorch-master | test/package/package_d/imports_directly.py |
from .subsubpackage_0 import important_string
| pytorch-master | test/package/package_d/subpackage_0/__init__.py |
important_string = "subsubpackage_0"
| pytorch-master | test/package/package_d/subpackage_0/subsubpackage_0/__init__.py |
if "__torch_package__" in dir():
def is_from_package():
return True
else:
def is_from_package():
return False
| pytorch-master | test/package/package_a/use_dunder_package.py |
# Owner(s): ["oncall: package/deploy"]
import torch
from torch.fx import wrap
wrap("a_non_torch_leaf")
class ModWithSubmod(torch.nn.Module):
def __init__(self, script_mod):
super().__init__()
self.script_mod = script_mod
def forward(self, x):
return self.script_mod(x)
class ModWit... | pytorch-master | test/package/package_a/test_module.py |
# Owner(s): ["oncall: package/deploy"]
from torch.fx import Tracer
class TestAllLeafModulesTracer(Tracer):
def is_leaf_module(self, m, qualname):
return True
| pytorch-master | test/package/package_a/test_all_leaf_modules_tracer.py |
result = "package_a"
class PackageAObject:
__slots__ = ["obj"]
def __init__(self, obj):
self.obj = obj
def return_result(self):
return result
| pytorch-master | test/package/package_a/__init__.py |
import torch
from torch import Tensor
@torch.jit.interface
class ModuleInterface(torch.nn.Module):
def one(self, inp1: Tensor, inp2: Tensor) -> Tensor:
pass
class OrigModule(torch.nn.Module):
"""A module that implements ModuleInterface."""
def __init__(self):
super(OrigModule, self).__i... | pytorch-master | test/package/package_a/fake_interface.py |
from typing import Any
import torch
@torch.jit.script
class MyScriptClass:
"""Intended to be scripted."""
def __init__(self, x):
self.foo = x
def set_foo(self, x):
self.foo = x
@torch.jit.script
def uses_script_class(x):
"""Intended to be scripted."""
foo = MyScriptClass(x)
... | pytorch-master | test/package/package_a/fake_script_class.py |
try:
import torch_package_importer # noqa: F401
except ImportError:
pass
| pytorch-master | test/package/package_a/use_torch_package_importer.py |
import os # noqa: F401
import os.path # noqa: F401
import typing # noqa: F401
import typing.io # noqa: F401
import typing.re # noqa: F401
import torch
class Module(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self):
return os.path.abspath("test")
| pytorch-master | test/package/package_a/std_sys_module_hacks.py |
# Owner(s): ["oncall: package/deploy"]
import torch
class TestNnModule(torch.nn.Module):
def __init__(self, nz=6, ngf=9, nc=3):
super(TestNnModule, self).__init__()
self.main = torch.nn.Sequential(
# input is Z, going into a convolution
torch.nn.ConvTranspose2d(nz, ngf * 8... | pytorch-master | test/package/package_a/test_nn_module.py |
result = "package_a.subpackage"
class PackageASubpackageObject:
pass
def leaf_function(a, b):
return a + b
| pytorch-master | test/package/package_a/subpackage.py |
pytorch-master | test/expect/__init__.py | |
import warnings
from torch.onnx import _CAFFE2_ATEN_FALLBACK
if not _CAFFE2_ATEN_FALLBACK:
warnings.warn("Caffe2 support is not fully enabled in this PyTorch build. "
"Please enable Caffe2 by building PyTorch from source with `BUILD_CAFFE2=1` flag.")
| pytorch-master | caffe2/__init__.py |
pytorch-master | caffe2/core/__init__.py | |
pytorch-master | caffe2/core/nomnigraph/__init__.py | |
#!/usr/bin/env python3
import argparse
from textwrap import dedent
from subprocess import call
def parse_lines(lines):
# States
EMPTY = 0
OP = 1
MACRO = 2
parse_state = EMPTY
# Preprocess the macros
curr_macro = ""
macros = {}
index = 0
while index < len(lines):
... | pytorch-master | caffe2/core/nomnigraph/op_gen.py |
import warnings
# NOTE: we have to import python protobuf here **before** we load cpp extension.
# Otherwise it breaks under certain build conditions if cpp implementation of
# protobuf is used. Presumably there's some registry in protobuf library and
# python side has to initialize the dictionary first, before stati... | pytorch-master | caffe2/proto/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.