python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
# Owner(s): ["oncall: distributed"] from typing import Any, Callable import torch from torch.distributed.fsdp import FullyShardedDataParallel as FSDP from torch.distributed.fsdp._symbolic_trace import TracingConfig from torch.distributed.fsdp.fully_sharded_data_parallel import ShardingStrategy from torch.distributed....
pytorch-master
test/distributed/fsdp/test_fsdp_param_exec_order_wrap.py
# Owner(s): ["oncall: distributed"] import itertools import sys from contextlib import suppress from copy import deepcopy from functools import partial from typing import Any, Dict import torch import torch.nn as nn from torch import distributed as dist from torch.distributed.algorithms._checkpoint.checkpoint_wrapper...
pytorch-master
test/distributed/fsdp/test_fsdp_state_dict.py
# Owner(s): ["oncall: distributed"] import sys import time from statistics import mean from unittest.mock import patch import torch import torch.nn as nn from torch import distributed as dist from torch.cuda import Event from torch.distributed.fsdp import FullyShardedDataParallel as FSDP from torch.testing._internal....
pytorch-master
test/distributed/fsdp/test_fsdp_overlap.py
# Owner(s): ["oncall: distributed"] import contextlib from copy import deepcopy from functools import partial import torch import torch.nn as nn from torch.distributed.fsdp.fully_sharded_data_parallel import ( FullyShardedDataParallel as FSDP, CPUOffload, ) from torch.distributed.algorithms._checkpoint.checkp...
pytorch-master
test/distributed/fsdp/test_fsdp_checkpoint.py
# Owner(s): ["oncall: distributed"] import functools import os import tempfile import unittest from enum import Enum, auto import torch import torch.nn as nn import torch.nn.functional as F from torch.distributed.fsdp.fully_sharded_data_parallel import ( BackwardPrefetch, CPUOffload, ) from torch.distributed....
pytorch-master
test/distributed/fsdp/test_wrap.py
# Owner(s): ["oncall: distributed"] import sys from typing import Optional import torch import torch.nn as nn import torch.nn.functional as F from torch import distributed as dist from torch.distributed.algorithms._comm_hooks import default_hooks from torch.distributed.fsdp import FullyShardedDataParallel as FSDP fro...
pytorch-master
test/distributed/fsdp/test_fsdp_comm_hooks.py
# Owner(s): ["oncall: distributed"] import sys import torch import torch.distributed as dist from torch.distributed._shard.partial_tensor import ( _PartialTensor, ) from torch.distributed._shard.sharding_spec import ( ChunkShardingSpec, EnumerableShardingSpec, ShardMetadata, ) from torch.testing._inte...
pytorch-master
test/distributed/_shard/test_partial_tensor.py
# Owner(s): ["oncall: distributed"] import io import torch import torch.distributed._shard.sharded_tensor as sharded_tensor import torch.distributed as dist from torch.nn.parallel import DistributedDataParallel as DDP from torch.distributed._shard import _shard_tensor from torch.distributed._shard.replicated_tensor ...
pytorch-master
test/distributed/_shard/test_replicated_tensor.py
# Owner(s): ["oncall: distributed"] import sys import copy import torch import torch.nn as nn from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.distributed._shard import shard_module from torch.distributed._shard.sharding_plan import ShardingPlan from torch...
pytorch-master
test/distributed/_shard/test_sharder.py
# Owner(s): ["oncall: distributed"] import sys import torch from torch.distributed._shard.sharded_tensor import ( Shard, ShardMetadata, ShardedTensor, ShardedTensorMetadata, ) from torch.distributed._shard.sharded_tensor.metadata import TensorProperties from torch.testing._internal.common_utils impo...
pytorch-master
test/distributed/_shard/checkpoint/test_utils.py
# Owner(s): ["oncall: distributed"] import sys import os import shutil import tempfile from typing import Dict import torch import torch.distributed as dist from torch.distributed._shard import sharded_tensor from torch.distributed._shard.sharded_tensor import ShardedTensor, state_dict_hook from torch.distributed._sh...
pytorch-master
test/distributed/_shard/checkpoint/test_file_system_checkpoint_cpu.py
# Owner(s): ["oncall: distributed"] import sys import os import shutil import tempfile from typing import Dict import torch import torch.distributed as dist from torch.distributed._shard import sharded_tensor from torch.distributed._shard.sharded_tensor import ShardedTensor, state_dict_hook from torch.distributed._sh...
pytorch-master
test/distributed/_shard/checkpoint/test_file_system_checkpoint.py
# Owner(s): ["oncall: distributed"] import random import sys from typing import Optional, List, Union, cast from torch.distributed._shard.checkpoint import ( StorageReader, StorageWriter, CheckpointException, load_state_dict, save_state_dict, ) import torch import torch.distributed as dist import ...
pytorch-master
test/distributed/_shard/checkpoint/test_checkpoint.py
# Owner(s): ["oncall: distributed"] import sys from itertools import product import torch from torch.distributed._shard import ( sharded_tensor, _shard_tensor, ) from torch.distributed._shard.sharding_spec import ( EnumerableShardingSpec, ShardMetadata, ) from torch.testing._internal.common_distribute...
pytorch-master
test/distributed/_shard/sharded_tensor/test_sharded_tensor_reshard.py
# Owner(s): ["oncall: distributed"] import copy import math import io import itertools import pickle import sys import torch import torch.distributed as dist from torch.distributed import rpc from torch.distributed import distributed_c10d from torch.distributed._shard import sharded_tensor from torch.distributed._shar...
pytorch-master
test/distributed/_shard/sharded_tensor/test_sharded_tensor.py
# Owner(s): ["oncall: distributed"] import copy import sys import torch import torch.distributed as dist from torch.distributed._shard.sharded_optim import ( ShardedOptimizer, ) from torch.distributed._shard.api import ( shard_parameter, _reshard_output, _collect_local_shard ) from torch.testing._inte...
pytorch-master
test/distributed/_shard/sharded_tensor/test_megatron_prototype.py
# Owner(s): ["oncall: distributed"] import sys import torch from torch.distributed._shard import sharded_tensor, _shard_tensor from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.testing._internal.common_utils import ( TEST_WITH_DEV_DBG_ASAN, run_test...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_elementwise_ops.py
# Owner(s): ["oncall: distributed"] import copy import itertools import sys import torch from torch.distributed._shard import sharded_tensor, _shard_tensor from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.testing._internal.common_utils import ( TEST_WI...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_matrix_ops.py
# Owner(s): ["oncall: distributed"] import sys import torch import torch.distributed as dist from torch.distributed._shard import ( shard_parameter, ) from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.testing._internal.common_utils import ( TEST_WIT...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_embedding_bag.py
# Owner(s): ["oncall: distributed"] import copy import torch import torch.distributed._shard.sharded_tensor as sharded_tensor from torch.distributed._shard.sharding_spec import ( ChunkShardingSpec, ) from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.t...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_tensor_ops.py
# Owner(s): ["oncall: distributed"] import sys import torch import torch.distributed as dist from torch.distributed._shard import ( shard_parameter, ) from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.testing._internal.common_utils import ( TEST_WIT...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_embedding.py
# Owner(s): ["oncall: distributed"] import sys import torch import torch.distributed as dist from torch.distributed._shard import sharded_tensor from torch.distributed.distributed_c10d import _get_default_group from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from t...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_binary_cmp.py
# Owner(s): ["oncall: distributed"] import copy import sys import torch import torch.distributed as dist from torch.distributed._shard.api import ( shard_parameter, _collect_local_shard, _reshard_output, ) from torch.distributed._shard.sharded_optim import ( ShardedOptimizer, ) from torch.distributed....
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_linear.py
# Owner(s): ["oncall: distributed"] import sys import torch from torch.testing._internal.common_utils import ( TEST_WITH_DEV_DBG_ASAN, run_tests, ) from torch.testing._internal.distributed._shard.sharded_tensor import ( TEST_GPU_NUM, ShardedTensorTestBase, with_comms, ) from torch.testing._internal...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_softmax.py
# Owner(s): ["oncall: distributed"] import sys import torch from torch.distributed._shard import sharded_tensor from torch.distributed._shard.sharding_spec import ( ChunkShardingSpec, ) from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.testing._internal...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_init.py
# Owner(s): ["oncall: distributed"] import torch from torch.distributed._shard import _shard_tensor import torch.distributed._shard.sharded_tensor as sharded_tensor import torch.distributed as dist from torch.distributed._shard.sharding_spec import ( ChunkShardingSpec, EnumerableShardingSpec, ShardMetadat...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_math_ops.py
# Owner(s): ["oncall: distributed"] import sys import torch from torch.distributed._shard import sharded_tensor, _shard_tensor from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.testing._internal.common_utils import ( TEST_WITH_DEV_DBG_ASAN, run_test...
pytorch-master
test/distributed/_shard/sharded_tensor/ops/test_chunk.py
# Owner(s): ["oncall: distributed"] import sys import copy import torch import torch.nn as nn import torch.distributed as dist from torch.distributed._shard.sharded_optim import ( ShardedOptimizer, ) from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.dis...
pytorch-master
test/distributed/_shard/sharding_plan/test_sharding_plan.py
# Owner(s): ["oncall: distributed"] from typing import List, Union from dataclasses import dataclass import copy import torch from torch.testing._internal.common_utils import TestCase from torch.testing._internal.common_distributed import ( requires_nccl, skip_if_lt_x_gpu, ) from torch.distributed._shard impor...
pytorch-master
test/distributed/_shard/sharding_spec/test_sharding_spec.py
# Owner(s): ["oncall: distributed"] import torch import torch.optim as optim from torch.distributed._shard import ( sharded_tensor, shard_parameter ) from copy import deepcopy from torch.distributed._shard.sharding_spec import ( ChunkShardingSpec, ) from torch.distributed._shard.sharded_optim import ( ...
pytorch-master
test/distributed/_shard/sharded_optim/test_sharded_optim.py
#!/usr/bin/env python3 # Owner(s): ["oncall: distributed"] import sys 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_utils import IS_CI, run_tests from torch.testing...
pytorch-master
test/distributed/rpc/test_tensorpipe_agent.py
#!/usr/bin/env python3 # Owner(s): ["oncall: distributed"] import torch import torch.distributed as dist if not dist.is_available(): print("Distributed not available, skipping tests", file=sys.stderr) sys.exit(0) import copyreg import os import contextlib from torch import multiprocessing import torch.multi...
pytorch-master
test/distributed/rpc/test_share_memory.py
#!/usr/bin/env python3 # Owner(s): ["oncall: distributed"] import sys 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_utils import IS_CI, run_tests from torch.testing...
pytorch-master
test/distributed/rpc/test_faulty_agent.py
#!/usr/bin/env python3 # Owner(s): ["oncall: distributed"] import sys 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_utils import run_tests from torch.testing._internal.distribut...
pytorch-master
test/distributed/rpc/cuda/test_tensorpipe_agent.py
# Owner(s): ["module: autograd"] import types import unittest import warnings import torch import torch.autograd.functional as autogradF from torch.testing._internal.common_cuda import TEST_CUDA from torch.testing._internal.common_utils import ( TestCase, run_tests, subtest, gradcheck, gradgradcheck, parametrize...
pytorch-master
test/autograd/test_functional.py
# Owner(s): ["module: autograd"] import torch from torch.testing._internal.common_utils import TestCase, run_tests, gradcheck class TestAutogradComplex(TestCase): def test_view_func_for_complex_views(self): # case 1: both parent and child have view_func x = torch.randn(2, 2, 2, dtype=torch.doubl...
pytorch-master
test/autograd/test_complex.py
# Owner(s): ["oncall: fx"] import torch from torch.testing._internal.common_utils import ( TestCase, run_tests) from torch.fx.experimental.proxy_tensor import make_fx from torch.fx.passes.dialect.common.cse_pass import CSEPass, get_CSE_banned_ops from torch.fx import symbolic_trace import random banned_ops = g...
pytorch-master
test/fx/test_cse_pass.py
# Owner(s): ["oncall: fx"] import torch from torch.testing._internal.common_utils import ( TestCase, parametrize, instantiate_parametrized_tests, run_tests) from torch.fx.experimental.proxy_tensor import make_fx from torch.fx.passes.dialect.common.cse_pass import CSEPass from torch.fx.graph_module import GraphMod...
pytorch-master
test/fx/test_common_passes.py
# Owner(s): ["module: fx"] import operator import unittest from torch.fx import GraphModule, symbolic_trace from torch.fx.experimental.meta_tracer import symbolic_trace as meta_symbolic_trace from torch.fx.experimental.migrate_gradual_types.constraint import BinConstraintT, DVar, TVar, T from torch.fx.experimental.migr...
pytorch-master
test/fx/test_z3_gradual_types.py
# Owner(s): ["module: fx"] import os import sys import torch from torch.fx import symbolic_trace, subgraph_rewriter from torch.fx.annotate import annotate # Make the helper files in test/ importable from torch.fx.experimental.rewriter import RewritingTracer pytorch_test_dir = os.path.dirname(os.path.dirname(os.path....
pytorch-master
test/fx/test_subgraph_rewriter.py
# Owner(s): ["module: fx"] from __future__ import annotations # type: ignore[attr-defined] import torch import typing from torch.fx import symbolic_trace class A: def __call__(self, x: torch.Tensor): return torch.add(x, x) # No forward references class M1(torch.nn.Module): def forward(self, x: tor...
pytorch-master
test/fx/test_future.py
r''' **This file is EXPERIMENTAL and is mostly used for testing purposes! Do not rely on it for anything!** ''' from torch.fx import Graph, GraphModule from torch.fx.graph import map_arg from torch.fx.proxy import Proxy import sys import torch from torch.nn.utils import fuse_conv_bn_weights import operator # can be a ...
pytorch-master
test/fx/quantization.py
# Owner(s): ["module: fx"] import unittest import torch from torch.fx import symbolic_trace from torch.fx.experimental.unify_refinements import infer_symbolic_types from torch.fx.experimental.refinement_types import Equality from torch.fx.tensor_type import TensorType, Dyn, is_consistent, is_more_precise from torch.fx...
pytorch-master
test/fx/test_gradual_type.py
from typing import NamedTuple import torch class MyNamedTup(NamedTuple): i : torch.Tensor f : torch.Tensor
pytorch-master
test/fx/named_tup.py
# Owner(s): ["module: fx"] import unittest import torch import torch.fx from torch.testing._internal.common_utils import TestCase class MyModuleBase(torch.nn.Module): def forward(self, x): matrx = self.get_mul_matrix() if self.no_relu(): return torch.mm(x, matrx) else: ...
pytorch-master
test/fx/test_fx_param_shape_control_flow.py
# Owner(s): ["module: fx"] from typing import Set, Type import torch import torch.fx from torch.testing._internal.common_utils import TestCase class TestDCE(TestCase): def _has_nodes_without_users(self, m: torch.fx.GraphModule): for node in m.graph.nodes: if node.is_impure(): ...
pytorch-master
test/fx/test_dce_pass.py
# Owner(s): ["module: fx"] import operator import torch import torch.fx from torch.fx.experimental import const_fold from torch.fx.passes.shape_prop import _extract_tensor_metadata, ShapeProp from torch.testing._internal.common_utils import TestCase class TestConstFold(TestCase): def _get_attr(self, node): ...
pytorch-master
test/fx/test_fx_const_fold.py
# Owner(s): ["module: fx"] import torch import torch.fx as fx from torch.testing._internal.common_utils import TestCase from torch.fx.passes.infra.pass_base import PassResult from torch.fx.passes.infra.pass_manager import ( PassManager, this_before_that_pass_constraint, _topological_sort_passes, ) def re...
pytorch-master
test/fx/test_pass_infra.py
import argparse import torch def dump(filename): schemas = torch._C._jit_get_all_schemas() schemas += torch._C._jit_get_custom_class_schemas() with open(filename, 'w') as f: for s in schemas: f.write(str(s)) f.write('\n') if __name__ == '__main__': parser = argparse....
pytorch-master
test/forward_backward_compatibility/dump_all_function_schemas.py
import argparse import datetime import re import sys import warnings from collections import defaultdict import torch from torch._C import parse_schema # How to run this test locally: # 1 Have two virtual environments (eg conda env), one without PyTorch installed (venv_nightly) # one with your local changes (venv_...
pytorch-master
test/forward_backward_compatibility/check_forward_backward_compatibility.py
# Owner(s): ["module: intel"] from torch.testing._internal.common_utils import TestCase, run_tests, IS_LINUX import shutil import subprocess import tempfile import unittest @unittest.skipIf(not IS_LINUX, "Only works on linux") class TestTorchrun(TestCase): def setUp(self): self._test_dir = tempfile.mkdtem...
pytorch-master
test/backends/xeon/test_launch.py
# Owner(s): ["module: unknown"] import collections import json import os import re import textwrap import timeit from typing import Any, List, Tuple import unittest import torch import torch.utils.benchmark as benchmark_utils from torch.testing._internal.common_utils import TestCase, run_tests, IS_SANDCASTLE, IS_WIND...
pytorch-master
test/benchmark_utils/test_benchmark_utils.py
# Owner(s): ["module: unknown"] import os import tempfile import torch from backend import Model, to_custom_backend, get_custom_backend_library_path from torch.testing._internal.common_utils import TestCase, run_tests class TestCustomBackend(TestCase): def setUp(self): # Load the library containing the ...
pytorch-master
test/custom_backend/test_custom_backend.py
import argparse import os.path import sys import torch def get_custom_backend_library_path(): """ Get the path to the library containing the custom backend. Return: The path to the custom backend object, customized by platform. """ if sys.platform.startswith("win32"): library_file...
pytorch-master
test/custom_backend/backend.py
pytorch-master
test/quantization/__init__.py
# Owner(s): ["oncall: quantization"] import torch import math from typing import Tuple from torch.ao.quantization import ( FakeQuantize, MovingAverageMinMaxObserver, default_observer, default_fixed_qparams_range_0to1_fake_quant, ) from torch.ao.quantization._learnable_fake_quantize import _LearnableFa...
pytorch-master
test/quantization/core/test_workflow_ops.py
# Owner(s): ["oncall: quantization"] import torch import torch.nn.intrinsic as nni import torch.nn.qat as nnqat import torch.nn.quantized._reference as nnqr from torch.testing._internal.common_quantization import QuantizationTestCase from torch.ao.quantization.backend_config import ( BackendConfig, BackendPat...
pytorch-master
test/quantization/core/test_backend_config.py
# Owner(s): ["oncall: quantization"] import numpy as np import math import torch import io import unittest from copy import deepcopy from hypothesis import given from hypothesis import strategies as st from torch.testing._internal.common_utils import TemporaryFileName from torch.testing._internal.common_cuda import TE...
pytorch-master
test/quantization/core/test_quantized_tensor.py
# Owner(s): ["oncall: quantization"] import torch from torch.testing._internal.common_utils import TestCase from torch.ao.quantization.utils import get_fqn_to_example_inputs class TestUtils(TestCase): def _test_get_fqn_to_example_inputs(self, M, example_inputs, expected_fqn_to_dim): m = M().eval() ...
pytorch-master
test/quantization/core/test_utils.py
# Owner(s): ["oncall: quantization"] import torch import torch.nn as nn import torch.nn.intrinsic as nni import torch.nn.intrinsic.quantized as nniq import torch.nn.quantized as nnq import torch.nn.quantized.dynamic as nnqd import torch.nn.quantized._reference as nnqr import torch.ao.quantization from torch.ao.quanti...
pytorch-master
test/quantization/core/test_quantized_module.py
# Owner(s): ["oncall: quantization"] import re import contextlib from pathlib import Path import torch # import torch.nn.quantized as nnq from torch.testing._internal.common_quantization import ( QuantizationTestCase, SingleLayerLinearModel, ) from torch.testing._internal.common_quantized import override_qua...
pytorch-master
test/quantization/core/test_docs.py
pytorch-master
test/quantization/core/__init__.py
# Owner(s): ["oncall: quantization"] from builtins import round import copy import itertools import numpy as np import unittest import operator import random import torch from torch import _VF import torch.jit import torch.nn.functional as F from torch.nn.modules.utils import _single, _pair from hypothesis import s...
pytorch-master
test/quantization/core/test_quantized_op.py
# Owner(s): ["oncall: quantization"] # Torch import torch import torch.nn.functional as F import torch.nn.quantized.functional as qF # Standard library import numpy as np # Testing utils from hypothesis import assume, given from hypothesis import strategies as st from torch.testing._internal.common_quantization impo...
pytorch-master
test/quantization/core/test_quantized_functional.py
# Owner(s): ["oncall: quantization"] # Torch import torch from torch.ao.quantization import ( MinMaxObserver, PerChannelMinMaxObserver, MovingAverageMinMaxObserver, MovingAveragePerChannelMinMaxObserver, HistogramObserver, RecordingObserver, PlaceholderObserver, NoopObserver, FakeQu...
pytorch-master
test/quantization/core/test_workflow_module.py
# Owner(s): ["oncall: quantization"] from torch.ao.quantization.experimental.observer import APoTObserver import unittest import torch class TestNonUniformObserver(unittest.TestCase): """ Test case 1: calculate_qparams Test that error is thrown when k == 0 """ def test_calculate_qparams_in...
pytorch-master
test/quantization/core/experimental/test_nonuniform_observer.py
# Owner(s): ["oncall: quantization"] import torch import unittest from torch.ao.quantization.experimental.observer import APoTObserver from torch.ao.quantization.experimental.quantizer import quantize_APoT class TestQuantizedTensor(unittest.TestCase): r""" Tests int_repr on APoTQuantizer with random tensor2quanti...
pytorch-master
test/quantization/core/experimental/test_quantized_tensor.py
import torch import torchvision import torchvision.transforms.transforms as transforms import os import torch.quantization from torchvision.models.quantization.resnet import resnet18 from torch.autograd import Variable # Setup warnings import warnings warnings.filterwarnings( action='ignore', category=Deprecat...
pytorch-master
test/quantization/core/experimental/quantization_util.py
# Owner(s): ["oncall: quantization"] import torch import unittest from torch.ao.quantization.experimental.observer import APoTObserver from torch.ao.quantization.experimental.quantizer import quantize_APoT, dequantize_APoT from torch.ao.quantization.experimental.fake_quantize import APoTFakeQuantize from torch.ao.quan...
pytorch-master
test/quantization/core/experimental/test_fake_quantize.py
# Owner(s): ["oncall: quantization"] import torch from torch import quantize_per_tensor from torch.ao.quantization.observer import MinMaxObserver from torch.ao.quantization.experimental.observer import APoTObserver from torch.ao.quantization.experimental.quantizer import APoTQuantizer, quantize_APoT, dequantize_APoT i...
pytorch-master
test/quantization/core/experimental/test_quantizer.py
# Owner(s): ["oncall: quantization"] import torch from torch.ao.quantization.experimental.linear import LinearAPoT from torch.nn.modules.linear import Linear import unittest class TestNonUniformObserver(unittest.TestCase): """ Test linear_APoT_fn by comparing to uniform linear for 2d tensors with ...
pytorch-master
test/quantization/core/experimental/test_linear.py
from torchvision.models.quantization.resnet import resnet18 from torch.ao.quantization.experimental.quantization_helper import ( evaluate, prepare_data_loaders, training_loop ) # training and validation dataset: full ImageNet dataset data_path = '~/my_imagenet/' train_batch_size = 30 eval_batch_size = 50 ...
pytorch-master
test/quantization/core/experimental/apot_fx_graph_mode_qat.py
import torch import torch.nn as nn import torch.quantization from torchvision.models.quantization.resnet import resnet18 from torch.ao.quantization.experimental.quantization_helper import ( evaluate, prepare_data_loaders ) # validation dataset: full ImageNet dataset data_path = '~/my_imagenet/' data_loader, d...
pytorch-master
test/quantization/core/experimental/apot_fx_graph_mode_ptq.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: quantization"] import sys import os import unittest from typing import Set # torch import torch import torch.nn as nn import torch.nn.quantized as nnq import torch.nn.quantized.dynamic as nnqd import torch.nn.intrinsic.quantized as nniq from torch.fx import GraphModule #...
pytorch-master
test/quantization/bc/test_backward_compatibility.py
pytorch-master
test/quantization/bc/__init__.py
# Owner(s): ["oncall: quantization"] # Copied from pytorch/test/fx/test_subgraph_rewriter.py import os import sys import torch from torch.fx import symbolic_trace, subgraph_rewriter from torch.fx.annotate import annotate # Make the helper files in test/ importable from torch.fx.experimental.rewriter import RewritingT...
pytorch-master
test/quantization/fx/test_subgraph_rewriter.py
pytorch-master
test/quantization/fx/__init__.py
# Owner(s): ["oncall: quantization"] import copy import math import operator import unittest import torch import torch.nn as nn import torch.nn.functional as F from torch.ao.quantization import default_dynamic_qconfig import torch.nn.quantized as nnq toq = torch.ops.quantized from torch.ao.quantization.quantize_fx im...
pytorch-master
test/quantization/fx/test_numeric_suite_fx.py
# Owner(s): ["oncall: quantization"] from collections import OrderedDict import os import contextlib import torch import torch.nn.functional as F import torch.nn as nn import torch.nn.quantized as nnq import torch.nn.quantized._reference as nnqr import torch.nn.quantized.dynamic as nnqd import torch.nn.intrinsic as nn...
pytorch-master
test/quantization/fx/test_quantize_fx.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: quantization"] import torch import torch.nn as nn import torch.ao.quantization.quantize_fx as quantize_fx import torch.nn.functional as F from torch.ao.quantization import QConfig, QConfigMapping from torch.ao.quantization.fx._model_report.detector import ( DynamicStat...
pytorch-master
test/quantization/fx/test_model_report_fx.py
# Owner(s): ["oncall: quantization"] import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.intrinsic.quantized as nniq import torch.nn.quantized as nnq from torch.ao.quantization import default_qconfig from torch.ao.quantization.observer import MinMaxObserver, PerChannelMinMaxObserver from...
pytorch-master
test/quantization/fx/test_equalize_fx.py
pytorch-master
test/quantization/dbr/__init__.py
# Owner(s): ["oncall: quantization"] import collections import copy import math import tempfile import unittest import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.intrinsic as nni import torch.nn.quantized as nnq toq = torch.ops.quantized from torch.testing._internal.common_quantizatio...
pytorch-master
test/quantization/dbr/test_quantize_dbr.py
# Owner(s): ["oncall: quantization"] from .common import AOMigrationTestCase class TestAOMigrationQuantizationFx(AOMigrationTestCase): def test_package_import_quantize_fx(self): self._test_package_import('quantize_fx') def test_function_import_quantize_fx(self): function_list = [ ...
pytorch-master
test/quantization/ao_migration/test_quantization_fx.py
pytorch-master
test/quantization/ao_migration/__init__.py
# Owner(s): ["oncall: quantization"] from .common import AOMigrationTestCase class TestAOMigrationQuantization(AOMigrationTestCase): def test_package_import_quantize(self): self._test_package_import('quantize') def test_function_import_quantize(self): function_list = [ '_convert'...
pytorch-master
test/quantization/ao_migration/test_ao_migration.py
# Owner(s): ["oncall: quantization"] from .common import AOMigrationTestCase class TestAOMigrationQuantization(AOMigrationTestCase): r"""Modules and functions related to the `torch/quantization` migration to `torch/ao/quantization`. """ def test_package_import_quantize(self): self._test_packa...
pytorch-master
test/quantization/ao_migration/test_quantization.py
from torch.testing._internal.common_utils import TestCase import importlib from typing import List, Optional class AOMigrationTestCase(TestCase): def _test_package_import(self, package_name: str, base: Optional[str] = None): r"""Tests the module import by making sure that all the internals match (...
pytorch-master
test/quantization/ao_migration/common.py
# Owner(s): ["oncall: quantization"] import torch from torch.testing._internal.common_quantization import ( skipIfNoFBGEMM ) from torch.testing._internal.common_utils import suppress_warnings from torch.testing._internal.jit_utils import JitTestCase from typing import Tuple import copy class TestDeprecatedJitQua...
pytorch-master
test/quantization/jit/test_deprecated_jit_quant.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: quantization"] # torch import torch from torch.testing import FileCheck from torch.testing._internal.common_quantization import QuantizationTestCase class TestFusionPasses(QuantizationTestCase): def test_quantized_add_relu_fusion(self): class MAdd(torch.nn.Mod...
pytorch-master
test/quantization/jit/test_fusion_passes.py
# -*- coding: utf-8 -*- # Owner(s): ["oncall: quantization"] # torch import torch import torch.nn as nn import torch.nn.functional as F import torch.jit import torch.jit.quantized # torch.ao.quantization from torch.ao.quantization import ( QConfig, default_dynamic_qconfig, float16_dynamic_qconfig, def...
pytorch-master
test/quantization/jit/test_quantize_jit.py
pytorch-master
test/quantization/jit/__init__.py
# Owner(s): ["oncall: quantization"] import unittest import torch import torch.nn as nn import torch.nn.quantized as nnq from torch.ao.quantization import ( DeQuantStub, QuantStub, convert, default_qconfig, prepare, quantize, quantize_dynamic, ) from torch.ao.ns._numeric_suite import ( ...
pytorch-master
test/quantization/eager/test_numeric_suite_eager.py
# Owner(s): ["oncall: quantization"] import copy import math import torch import torch.nn as nn import torch.backends.mkldnn from torch.nn import Conv2d, BatchNorm2d, ReLU, init from torch.nn.intrinsic.qat import ConvBn2d, ConvBnReLU2d from torch.nn.modules.utils import _pair import torch.nn.quantized as nnq import to...
pytorch-master
test/quantization/eager/test_quantize_eager_qat.py
# Owner(s): ["oncall: quantization"] import torch import torch.nn as nn import torch.nn.quantized as nnq from torch.nn.utils.rnn import PackedSequence from torch.ao.quantization import ( quantize, prepare, convert, prepare_qat, quantize_dynamic, QuantWrapper, QuantStub, DeQuantStub, ...
pytorch-master
test/quantization/eager/test_quantize_eager_ptq.py
# Owner(s): ["oncall: quantization"] import torch import torch.nn as nn from torch.testing._internal.common_quantization import QuantizationTestCase from torch.ao.quantization.fuse_modules import fuse_modules import torch.ao.quantization._equalize as _equalize import copy class TestEqualizeEager(QuantizationTestCa...
pytorch-master
test/quantization/eager/test_equalize_eager.py
pytorch-master
test/quantization/eager/__init__.py
# Owner(s): ["oncall: quantization"] import torch from torch.testing._internal.common_quantization import ( QuantizationTestCase, ModelMultipleOps, ModelMultipleOpsNoAvgPool, ) from torch.testing._internal.common_quantized import ( override_quantized_engine, supported_qengines, ) class TestModelN...
pytorch-master
test/quantization/eager/test_model_numerics.py
# Owner(s): ["oncall: quantization"] import torch import torch.nn as nn from torch.testing._internal.common_quantization import QuantizationTestCase from torch.testing._internal.common_quantization import skipIfNoFBGEMM from torch.ao.quantization import default_qconfig from torch.ao.quantization import QuantWrapper i...
pytorch-master
test/quantization/eager/test_bias_correction_eager.py
# Owner(s): ["oncall: quantization"] import copy import torch import torch.nn as nn import torch.nn.quantized as nnq import torch.nn.intrinsic as nni import torch.nn.intrinsic.quantized as nniq import torch.nn.intrinsic.qat as nniqat from torch.ao.quantization import ( quantize, prepare, convert, prep...
pytorch-master
test/quantization/eager/test_fuse_eager.py