repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
pytorch | pytorch-main/test/functorch/common_utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import torch
from functorch import vmap
import torch.utils._pytree as pytree
from functorch_addi... | 18,067 | 38.278261 | 124 | py |
pytorch | pytorch-main/test/functorch/functorch_additional_op_db.py | from functools import partial
import itertools
import unittest
import torch
from torch.testing._internal.common_dtype import floating_types, floating_types_and, all_types_and_complex_and
from torch.testing._internal.common_utils import make_tensor
from torch.testing._internal.common_methods_invocations import OpInfo,... | 25,776 | 44.064685 | 119 | py |
pytorch | pytorch-main/test/functorch/discover_coverage.py | import torch
import copy
from torch.testing._internal.common_methods_invocations import op_db
from functorch_additional_op_db import additional_op_db
from enum import Enum
import torch._functorch.top_operators_github_usage as top_ops
import pprint
import unittest
import enum
from torch.testing._internal.common_device_t... | 31,097 | 33.668896 | 100 | py |
pytorch | pytorch-main/test/functorch/test_ops.py | # Owner(s): ["module: functorch"]
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import unittest
from torch.testing._internal.common_utils im... | 108,113 | 47.02932 | 121 | py |
pytorch | pytorch-main/test/functorch/test_dims.py | # Owner(s): ["module: functorch"]
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from functorch.dim import Tensor, Dim, dims, dimlists, stack, DimensionBindErro... | 20,214 | 31.447833 | 130 | py |
pytorch | pytorch-main/test/functorch/test_control_flow.py | # Owner(s): ["module: functorch"]
import functools
import unittest
import torch
import torch.utils._pytree as pytree
from torch._functorch.aot_autograd import from_fun, to_fun
from functorch.experimental import control_flow
from functorch.experimental.control_flow import cond
from functorch.experimental.control_flow i... | 42,721 | 34.16214 | 124 | py |
pytorch | pytorch-main/test/functorch/attn_ft.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from functorch.dim import dims, dimlists, softmax, cat
import math
class Linea... | 7,480 | 52.056738 | 126 | py |
pytorch | pytorch-main/test/functorch/test_eager_transforms.py | # Owner(s): ["module: functorch"]
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import copy
from torch.testing._internal.common_utils import (
TestCase, r... | 169,155 | 33.863149 | 117 | py |
pytorch | pytorch-main/test/functorch/test_rearrange.py | # Owner(s): ["module: functorch"]
"""Adapted from https://github.com/arogozhnikov/einops/blob/230ac1526c1f42c9e1f7373912c7f8047496df11/tests/test_ops.py.
MIT License
Copyright (c) 2018 Alex Rogozhnikov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated docum... | 7,729 | 41.01087 | 119 | py |
pytorch | pytorch-main/test/functorch/test_vmap_registrations.py | # Owner(s): ["module: functorch"]
import typing
import unittest
from torch.testing._internal.common_utils import (
TestCase,
run_tests,
instantiate_parametrized_tests,
parametrize,
subtest
)
from torch._C import (
_dispatch_get_registrations_for_dispatch_key as get_registrations_for_dispatch_k... | 11,936 | 30.085938 | 102 | py |
pytorch | pytorch-main/test/inductor/test_max_autotune.py | # Owner(s): ["module: inductor"]
import torch
from torch import multiprocessing as mp
from torch._dynamo.test_case import run_tests, TestCase
from torch._inductor import config
from torch._inductor.graph import GraphLowering
from torch._inductor.ir import Buffer, FixedLayout
from torch._inductor.kernel.mm_plus_mm impo... | 6,351 | 36.364706 | 99 | py |
pytorch | pytorch-main/test/inductor/test_pattern_matcher.py | # Owner(s): ["module: inductor"]
import copy
import unittest
import torch
import torch._inductor.config as inductor_config
from torch._dynamo.test_case import run_tests, TestCase
from torch._dynamo.testing import expectedFailureDynamicWrapper
from torch._dynamo.utils import count_calls, counters
from torch._inductor.f... | 15,341 | 35.441805 | 94 | py |
pytorch | pytorch-main/test/inductor/test_profiler.py | # Owner(s): ["module: inductor"]
import json
import unittest
import torch
import torch._dynamo.test_case
import torch._inductor.utils
from torch.testing._internal.common_utils import TemporaryFileName, TEST_WITH_ROCM
HAS_TRITON = torch._inductor.utils.has_triton()
class DynamoProfilerTests(torch._dynamo.test_case.... | 1,584 | 28.90566 | 87 | py |
pytorch | pytorch-main/test/inductor/test_foreach.py | # Owner(s): ["module: inductor"]
import sys
import unittest
import torch
import torch._inductor
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
IS_FBCODE,
parametrize,
TEST_WITH_ROCM,
TestCase,
)
from torch.testing._internal.inductor_utils import HAS_CPU, HAS_... | 13,952 | 27.47551 | 87 | py |
pytorch | pytorch-main/test/inductor/test_split_cat_fx_passes.py | # Owner(s): ["module: inductor"]
import torch
from torch._dynamo.test_case import run_tests, TestCase
from torch._dynamo.utils import counters
from torch.testing._internal.common_utils import IS_LINUX
from torch.testing._internal.inductor_utils import HAS_CUDA
def patch(f):
f = torch._inductor.config.patch(split... | 30,726 | 33.877412 | 87 | py |
pytorch | pytorch-main/test/inductor/test_perf.py | # Owner(s): ["module: inductor"]
import contextlib
from unittest.mock import patch
import functorch
import torch
import torch._inductor.config as config
from torch._dynamo.backends.registry import register_backend
from torch._inductor import metrics
from torch._inductor.compile_fx import compile_fx, count_bytes_inner... | 14,123 | 26.319149 | 86 | py |
pytorch | pytorch-main/test/inductor/test_compiled_optimizers.py | # Owner(s): ["module: inductor"]
import sys
import unittest
from copy import deepcopy
import torch
import torch._inductor
from torch.testing._internal.common_utils import TEST_WITH_ROCM, TestCase
from torch.testing._internal.inductor_utils import HAS_CPU, HAS_CUDA
aten = torch.ops.aten
try:
try:
fro... | 3,186 | 30.245098 | 84 | py |
pytorch | pytorch-main/test/inductor/test_config.py | # Owner(s): ["module: inductor"]
import math
import unittest
import torch
from torch._dynamo.test_case import run_tests, TestCase
from torch._inductor import config
from torch.testing._internal.inductor_utils import HAS_CPU
def dummy_fn(x):
return torch.sigmoid(x + math.pi) / 10.0
class DummyModule(torch.nn.... | 9,643 | 33.077739 | 88 | py |
pytorch | pytorch-main/test/inductor/test_kernel_benchmark.py | # Owner(s): ["module: inductor"]
import contextlib
import subprocess
import sys
from unittest.mock import patch
import torch
from torch._dynamo.test_case import run_tests, TestCase
from torch._inductor import config
from torch._inductor.codecache import PyCodeCache
from torch.testing import FileCheck
from torch.testin... | 3,293 | 29.220183 | 84 | py |
pytorch | pytorch-main/test/inductor/test_minifier.py | # Owner(s): ["module: inductor"]
import functools
import unittest
from unittest.mock import patch
import torch
import torch._dynamo.config as dynamo_config
import torch._inductor.config as inductor_config
import torch._inductor.utils
from torch._dynamo.test_minifier_common import MinifierTestBase
from torch._inductor ... | 6,301 | 33.437158 | 94 | py |
pytorch | pytorch-main/test/inductor/test_mkldnn_pattern_matcher.py | # Owner(s): ["module: inductor"]
import contextlib
import itertools
import torch
from torch._dynamo import config as dynamo_config
from torch._dynamo.test_case import run_tests, TestCase
from torch._dynamo.utils import counters
from torch._inductor import config
from torch._inductor.utils import run_and_get_code
from... | 21,389 | 36.526316 | 89 | py |
pytorch | pytorch-main/test/inductor/test_torchinductor_dynamic_shapes.py | # Owner(s): ["module: inductor"]
import contextlib
import importlib
import math
import os
import sys
import unittest
from functools import partial
import torch
from torch._dynamo.testing import make_test_cls_with_patches
from torch.testing._internal.common_device_type import (
instantiate_device_type_tests,
on... | 6,992 | 29.142241 | 101 | py |
pytorch | pytorch-main/test/inductor/indirect_assert_helper.py | import sys
import torch
def first_arg(x, y):
return x[y]
def second_arg(x, y):
return x[:, y]
def same_pm_one(x, y):
return x[y + 1, y - 1]
def same_pp_one(x, y):
return x[y + 1, y + 1]
def store(x, y, z):
x[y + 1, y + 1] = z
if __name__ == "__main__":
_, fn_name, dims, dyn_shape, o... | 1,160 | 21.764706 | 88 | py |
pytorch | pytorch-main/test/inductor/test_group_batch_fusion.py | # Owner(s): ["module: inductor"]
import unittest
import torch
import torch._inductor
from torch._dynamo.test_case import run_tests, TestCase
from torch._dynamo.utils import counters
try:
# importing this will register fbgemm lowerings for inductor
import deeplearning.fbgemm.fbgemm_gpu.fb.inductor_lowerings ... | 5,774 | 31.26257 | 88 | py |
pytorch | pytorch-main/test/inductor/test_cpu_repro.py | # Owner(s): ["module: inductor"]
import contextlib
import itertools
import math
import sys
import unittest
from typing import Callable
from unittest.mock import patch
import numpy as np
import sympy
import torch
from torch._C import FileCheck
from torch._dynamo.testing import rand_strided
from torch._dynamo.utils impo... | 74,080 | 34.753378 | 105 | py |
pytorch | pytorch-main/test/inductor/test_triton_wrapper.py | # Owner(s): ["module: inductor"]
import subprocess
import sys
import torch
from torch._dynamo.test_case import run_tests, TestCase
from torch._inductor.codecache import PyCodeCache
from torch.testing._internal.inductor_utils import HAS_CUDA
class TestTritonWrapper(TestCase):
def get_compiled_module(self):
... | 1,529 | 27.333333 | 78 | py |
pytorch | pytorch-main/test/inductor/opinfo_harness.py | import os
import subprocess
from torch.testing._internal.common_methods_invocations import op_db
if __name__ == "__main__":
i = 0
while i < len(op_db):
start = i
end = i + 20
os.environ["PYTORCH_TEST_RANGE_START"] = f"{start}"
os.environ["PYTORCH_TEST_RANGE_END"] = f"{end}"
... | 799 | 29.769231 | 85 | py |
pytorch | pytorch-main/test/inductor/test_indexing.py | # Owner(s): ["module: inductor"]
import sympy
from torch._inductor.codegen.cpp import cexpr
from torch._inductor.codegen.triton import texpr
from torch._inductor.codegen.wrapper import pexpr
from torch._inductor.sizevars import SizeVarAllocator
from torch.testing._internal.common_utils import TestCase as TorchTestCas... | 10,865 | 40.473282 | 124 | py |
pytorch | pytorch-main/test/inductor/test_torchinductor_codegen_dynamic_shapes.py | # Owner(s): ["module: inductor"]
import importlib
import os
import re
import sys
import unittest
import torch
from torch._inductor.compile_fx import compile_fx
from torch.testing._internal.common_utils import (
IS_CI,
IS_WINDOWS,
TEST_WITH_ASAN,
TEST_WITH_ROCM,
TestCase,
)
from torch.testing._inter... | 14,515 | 40.593123 | 109 | py |
pytorch | pytorch-main/test/inductor/test_torchinductor.py | # Owner(s): ["module: inductor"]
import contextlib
import copy
import dataclasses
import functools
import importlib
import itertools
import math
import os
import random
import subprocess
import sys
import time
import typing
import unittest
import weakref
from typing import Tuple
from unittest.mock import patch
import ... | 226,080 | 30.356588 | 117 | py |
pytorch | pytorch-main/test/inductor/test_smoke.py | # Owner(s): ["module: inductor"]
import logging
import unittest
import torch
import torch._logging
from torch.testing._internal.common_utils import IS_LINUX, skipIfRocm, TestCase
from torch.testing._internal.inductor_utils import HAS_CUDA
class MLP(torch.nn.Module):
def __init__(self):
super().__init__(... | 1,757 | 24.852941 | 79 | py |
pytorch | pytorch-main/test/inductor/test_inductor_freezing.py | # Owner(s): ["module: inductor"]
import contextlib
import copy
import functools
import importlib
import itertools
import os
import sys
import unittest
import weakref
import torch
import torch._dynamo as torchdynamo
import torch.ao.quantization.pt2e.quantizer.x86_inductor_quantizer as xiq
from torch import nn
from tor... | 18,816 | 31.668403 | 92 | py |
pytorch | pytorch-main/test/inductor/test_cuda_repro.py | # Owner(s): ["module: inductor"]
import math
import sys
import unittest
import torch
import torch._dynamo.config as dynamo_config
from torch import nn
from torch._dynamo.debug_utils import same_two_models
from torch._dynamo.testing import rand_strided
from torch._dynamo.utils import same
from torch._inductor import co... | 34,092 | 35.346482 | 88 | py |
pytorch | pytorch-main/test/inductor/test_dependencies.py | # Owner(s): ["module: inductor"]
import contextlib
import unittest
import torch
from torch._inductor.graph import GraphLowering
from torch._inductor.ir import Buffer, FixedLayout, Pointwise
from torch._inductor.virtualized import ops, V
from torch.testing._internal.common_utils import TestCase as TorchTestCase
from ... | 1,872 | 27.815385 | 78 | py |
pytorch | pytorch-main/test/inductor/test_cudagraph_trees.py | # Owner(s): ["module: inductor"]
import contextlib
import functools
import gc
import importlib
import sys
import unittest
import warnings
import torch
import torch._dynamo.config as dynamo_config
import torch.nn as nn
from torch._inductor import config
from torch._inductor.compile_fx import compile_fx_inner
from torc... | 41,824 | 32.433253 | 88 | py |
pytorch | pytorch-main/test/inductor/test_coordinate_descent_tuner.py | # Owner(s): ["module: inductor"]
import sys
import unittest
from unittest import mock
import torch
from torch._dynamo.test_case import run_tests, TestCase
from torch.testing._internal.common_utils import IS_LINUX
from torch.testing._internal.inductor_utils import HAS_CUDA
try:
import triton
except ImportError:
... | 3,454 | 31.904762 | 86 | py |
pytorch | pytorch-main/test/inductor/minifier_smoke.py | # Owner(s): ["module: inductor"]
#
# This smoketest is referenced in the internal-only minifier runbook
# https://docs.google.com/document/d/18L9e7bZSBpJ7gGbwlUV13LasmjiEX2lree2pl-SdbCU/edit
import os
os.environ["TORCHDYNAMO_REPRO_AFTER"] = "dynamo"
import torch
import torch._dynamo as torchdynamo
import torch._induct... | 762 | 22.121212 | 86 | py |
pytorch | pytorch-main/test/inductor/test_select_algorithm.py | # Owner(s): ["module: inductor"]
import functools
from unittest.mock import patch
import torch
import torch._dynamo.config as dynamo_config
import torch._inductor.config as inductor_config
import torch._inductor.select_algorithm as select_algorithm
import torch.nn.functional as F
from torch._dynamo.test_case import ru... | 10,607 | 30.855856 | 84 | py |
pytorch | pytorch-main/test/inductor/test_cpp_wrapper.py | # Owner(s): ["module: inductor"]
import sys
import unittest
from typing import NamedTuple
import torch
from torch._inductor import config
from torch.testing._internal.common_utils import (
IS_MACOS,
slowTest,
TEST_WITH_ASAN,
TEST_WITH_ROCM,
TestCase as TorchTestCase,
)
from torch.testing._internal.... | 10,226 | 30.959375 | 98 | py |
pytorch | pytorch-main/test/inductor/test_fused_attention.py | # Owner(s): ["module: inductor"]
import itertools
import math
import torch
import torch._inductor.config
from torch._dynamo.test_case import run_tests, TestCase
from torch._dynamo.utils import counters
from torch._inductor import config
from torch._inductor.utils import run_and_get_code
from torch.testing._internal.co... | 13,681 | 36.587912 | 94 | py |
pytorch | pytorch-main/test/inductor/test_standalone_compile.py | # Owner(s): ["module: inductor"]
import torch
from torch import _dynamo as dynamo, _inductor as inductor
from torch._dynamo.test_case import run_tests, TestCase
from torch._inductor.utils import gen_gm_and_inputs
from torch.fx import symbolic_trace
from torch.fx.experimental.proxy_tensor import make_fx
from torch.testi... | 3,637 | 30.362069 | 78 | py |
pytorch | pytorch-main/test/inductor/test_fx_fusion.py | # Owner(s): ["module: inductor"]
from typing import Any, Callable
import torch
from torch._inductor.fx_passes.pre_grad import (
linear_permute_fusion,
linear_transpose,
permute_linear_fusion,
permute_matmul_fusion,
sink_cat_after_pointwise,
transpose_linear,
transpose_matmul,
)
from torch.f... | 5,987 | 36.898734 | 88 | py |
pytorch | pytorch-main/test/inductor/test_layout_optim.py | # Owner(s): ["module: inductor"]
import copy
import os
import random
import torch
from torch import nn
from torch._dynamo.test_case import run_tests, TestCase
from torch._dynamo.utils import same
from torch._inductor import config
from torch.testing._internal.inductor_utils import HAS_CUDA
USE_DDP_WRAPPER = os.enviro... | 9,287 | 31.027586 | 85 | py |
pytorch | pytorch-main/test/inductor/test_minifier_isolate.py | # Owner(s): ["module: inductor"]
import functools
import unittest
import torch
import torch._dynamo
import torch._inductor.config as inductor_config
import torch._inductor.utils
from torch._dynamo.test_minifier_common import MinifierTestBase
from torch.testing._internal.common_utils import (
IS_JETSON,
IS_MACO... | 1,907 | 31.338983 | 94 | py |
pytorch | pytorch-main/test/inductor/test_torchinductor_opinfo.py | # Owner(s): ["module: inductor"]
import atexit
import os
import sys
import unittest
from collections import defaultdict
from enum import Enum
from functools import partial
from unittest.mock import patch
import torch
from torch._dynamo.test_case import run_tests
from torch.testing._internal.common_cuda import SM80OrL... | 24,168 | 35.181138 | 110 | py |
pytorch | pytorch-main/test/onnx_caffe2/test_verify.py | # Owner(s): ["module: onnx"]
import caffe2.python.onnx.backend as backend
import torch
from torch.autograd import Function
from torch.nn import Module, Parameter
from torch.testing._internal import common_utils
from verify import verify
class TestVerify(common_utils.TestCase):
maxDiff = None
def assertVerif... | 3,318 | 30.311321 | 77 | py |
pytorch | pytorch-main/test/onnx_caffe2/test_custom_ops.py | # Owner(s): ["module: onnx"]
import caffe2.python.onnx.backend as c2
import numpy as np
import onnx
import pytorch_test_common
import torch
import torch.utils.cpp_extension
from test_pytorch_onnx_caffe2 import do_export
from torch.testing._internal import common_utils
class TestCaffe2CustomOps(pytorch_test_common.Ex... | 1,917 | 30.966667 | 80 | py |
pytorch | pytorch-main/test/onnx_caffe2/export_onnx_tests_generator.py | import io
import os
import shutil
import traceback
import onnx
import onnx_test_common
import torch
from onnx import numpy_helper
from test_nn import new_module_tests
from torch.autograd import Variable
from torch.testing._internal.common_nn import module_tests
# Take a test case (a dict) as input, return the test ... | 5,391 | 32.079755 | 88 | py |
pytorch | pytorch-main/test/onnx_caffe2/test_pytorch_onnx_caffe2_quantized.py | # Owner(s): ["module: unknown"]
import io
import caffe2.python.onnx.backend as c2
import numpy as np
import onnx
import pytorch_test_common
import torch.ao.nn.quantized as nnq
import torch.nn as nn
import torch.onnx
from torch.testing._internal import common_utils
class TestQuantizedOps(pytorch_test_common.ExportT... | 14,199 | 36.075718 | 86 | py |
pytorch | pytorch-main/test/onnx_caffe2/test_pytorch_helper.py | # Owner(s): ["module: onnx"]
# Some standard imports
import unittest
import numpy as np
import pytorch_test_common
import torch.nn.init as init
import torch.onnx
from caffe2.python.core import workspace
from caffe2.python.model_helper import ModelHelper
from pytorch_helper import PyTorchModule
from torch import nn
f... | 2,731 | 36.424658 | 87 | py |
pytorch | pytorch-main/test/onnx_caffe2/export_onnx_tests_filter.py | import argparse
import glob
import os
import shutil
import traceback
import google.protobuf.text_format
import onnx.backend.test
import onnx_test_common
from test_caffe2_common import run_generated_test
from torch.testing._internal.common_device_type import get_all_device_types
_fail_test_dir = os.path.join(
os.... | 3,560 | 33.572816 | 87 | py |
pytorch | pytorch-main/test/onnx_caffe2/test_pytorch_onnx_caffe2.py | # Owner(s): ["module: onnx"]
import io
import itertools
import sys
import unittest
from typing import Tuple
import caffe2.python.onnx.backend as c2
import model_defs.dcgan as dcgan
import model_defs.word_language_model as word_language_model
import numpy as np
import onnx
import pytorch_test_common
import torch.onnx... | 109,304 | 33.612096 | 116 | py |
pytorch | pytorch-main/test/onnx_caffe2/test_caffe2_common.py | # Owner(s): ["module: onnx"]
import glob
import os
import caffe2.python.onnx.backend as c2
import numpy as np
import onnx.backend.test
from onnx import numpy_helper
def load_tensor_as_numpy_array(f):
tensor = onnx.TensorProto()
with open(f, "rb") as file:
tensor.ParseFromString(file.read())
ret... | 1,298 | 26.638298 | 84 | py |
pytorch | pytorch-main/test/profiler/test_profiler.py | # Owner(s): ["oncall: profiler"]
import collections
import gc
import io
import json
import os
import re
import tempfile
import textwrap
import threading
import unittest
from unittest.mock import patch
import weakref
from dataclasses import dataclass, field
from typing import List, Optional
import expecttest
import sub... | 116,399 | 37.239159 | 130 | py |
pytorch | pytorch-main/test/profiler/test_memory_profiler.py | # Owner(s): ["oncall: profiler"]
import functools
import gc
import itertools as it
import textwrap
from typing import Callable, Dict, Iterator, List, Optional, Tuple
import torch
from torch._C._profiler import _EventType, _TensorMetadata
from torch.profiler import _memory_profiler, _utils
from torch.testing._internal.... | 79,055 | 48.164179 | 122 | py |
pytorch | pytorch-main/test/profiler/test_profiler_tree.py | # Owner(s): ["oncall: profiler"]
import functools
import os
import re
import textwrap
import traceback
import unittest
import expecttest
import torch
from torch._C._profiler import _ExtraFields_PyCall, _ExtraFields_PyCCall
from torch.testing._internal.common_utils import (
TestCase, run_tests, IS_WINDOWS, TEST_W... | 45,256 | 41.614878 | 112 | py |
pytorch | pytorch-main/test/quantization/pt2e/test_x86inductor_quantizer.py | # Owner(s): ["oncall: quantization"]
import copy
import torch
import torch._dynamo as torchdynamo
import torch.nn as nn
from torch.ao.quantization.pt2e.quantizer import (
X86InductorQuantizer,
)
from torch.ao.quantization.quantize_pt2e import (
convert_pt2e,
prepare_pt2e_quantizer,
)
from torch.testing._int... | 18,197 | 43.82266 | 129 | py |
pytorch | pytorch-main/test/quantization/pt2e/test_quantize_pt2e.py | # Owner(s): ["oncall: quantization"]
import copy
import operator
from typing import Any, List, Optional, Tuple, Dict
import torch
import torch._dynamo as torchdynamo
from torch import Tensor
from torch.ao.ns.fx.utils import compute_sqnr
from torch.ao.quantization import (
FusedMovingAvgObsFakeQuantize,
MovingA... | 83,362 | 39.724475 | 129 | py |
pytorch | pytorch-main/test/quantization/pt2e/test_graph_utils.py | # Owner(s): ["oncall: quantization"]
import copy
import unittest
import torch
import torch._dynamo as torchdynamo
from torch.ao.quantization.pt2e.graph_utils import (
find_sequential_partitions,
get_equivalent_types,
update_equivalent_types_dict,
)
from torch.testing._internal.common_utils import (
IS... | 4,190 | 31.488372 | 87 | py |
pytorch | pytorch-main/test/quantization/pt2e/test_quantize_pt2e_fx.py | # Owner(s): ["oncall: quantization"]
import copy
import itertools
import torch
import torch._dynamo as torchdynamo
import torch.nn as nn
from torch._inductor.compile_fx import compile_fx
from torch.ao.ns.fx.utils import compute_sqnr
from torch.ao.quantization import (
get_default_qconfig,
observer,
QConfig... | 24,369 | 41.754386 | 104 | py |
pytorch | pytorch-main/test/quantization/core/test_docs.py | # Owner(s): ["oncall: quantization"]
import re
import contextlib
from pathlib import Path
import torch
# import torch.ao.nn.quantized as nnq
from torch.testing._internal.common_quantization import (
QuantizationTestCase,
SingleLayerLinearModel,
)
from torch.testing._internal.common_quantized import override_... | 5,906 | 39.183673 | 95 | py |
pytorch | pytorch-main/test/quantization/core/test_workflow_ops.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... | 59,193 | 45.173167 | 131 | py |
pytorch | pytorch-main/test/quantization/core/test_workflow_module.py | # Owner(s): ["oncall: quantization"]
# Torch
import torch
from torch.ao.quantization import (
MinMaxObserver,
PerChannelMinMaxObserver,
MovingAverageMinMaxObserver,
MovingAveragePerChannelMinMaxObserver,
HistogramObserver,
RecordingObserver,
PlaceholderObserver,
NoopObserver,
FakeQu... | 56,375 | 41.709091 | 132 | py |
pytorch | pytorch-main/test/quantization/core/test_quantized_op.py | # Owner(s): ["oncall: quantization"]
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 settings, HealthCheck
from h... | 321,195 | 45.016619 | 132 | py |
pytorch | pytorch-main/test/quantization/core/test_quantized_functional.py | # Owner(s): ["oncall: quantization"]
# Torch
import torch
import torch.ao.nn.quantized.functional as qF
import torch.nn.functional as F
# 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 i... | 10,443 | 42.3361 | 123 | py |
pytorch | pytorch-main/test/quantization/core/test_quantized_tensor.py | # Owner(s): ["oncall: quantization"]
import numpy as np
import math
import random
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_... | 75,492 | 47.023537 | 131 | py |
pytorch | pytorch-main/test/quantization/core/test_backend_config.py | # Owner(s): ["oncall: quantization"]
import torch
import torch.ao.nn.intrinsic as nni
import torch.ao.nn.qat as nnqat
import torch.ao.nn.quantized.reference as nnqr
from torch.testing._internal.common_quantization import QuantizationTestCase
from torch.ao.quantization.backend_config import (
BackendConfig,
Ba... | 14,490 | 42.779456 | 111 | py |
pytorch | pytorch-main/test/quantization/core/test_top_level_apis.py | # Owner(s): ["oncall: quantization"]
import torch
import torch.ao.quantization
from torch.testing._internal.common_utils import TestCase
class TestDefaultObservers(TestCase):
observers = [
"default_affine_fixed_qparams_observer",
"default_debug_observer",
"default_dynamic_quant_observer",... | 3,499 | 36.234043 | 109 | py |
pytorch | pytorch-main/test/quantization/core/test_quantized_module.py | # Owner(s): ["oncall: quantization"]
import torch
import torch.nn as nn
import torch.ao.nn.intrinsic as nni
import torch.ao.nn.intrinsic.quantized as nniq
import torch.ao.nn.quantized.reference as nnqr
import torch.ao.quantization
import torch.ao.nn.quantized as nnq
import torch.ao.nn.quantized.dynamic as nnqd
from t... | 88,525 | 41.235687 | 131 | py |
pytorch | pytorch-main/test/quantization/core/test_utils.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
from torch.ao.nn.quantized.modules.utils import _quantize_weight
from torch.ao.quantization import MovingAverageMinMaxObserver, MovingAveragePerC... | 7,250 | 36.376289 | 110 | py |
pytorch | pytorch-main/test/quantization/core/experimental/apot_fx_graph_mode_qat.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
... | 2,818 | 28.673684 | 110 | py |
pytorch | pytorch-main/test/quantization/core/experimental/test_quantizer.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... | 9,213 | 39.06087 | 104 | py |
pytorch | pytorch-main/test/quantization/core/experimental/test_fake_quantize.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... | 3,800 | 39.870968 | 124 | py |
pytorch | pytorch-main/test/quantization/core/experimental/quantization_util.py | import torch
import torchvision
import torchvision.transforms.transforms as transforms
import os
import torch.ao.quantization
from torchvision.models.quantization.resnet import resnet18
from torch.autograd import Variable
# Setup warnings
import warnings
warnings.filterwarnings(
action='ignore',
category=Depre... | 5,030 | 32.765101 | 108 | py |
pytorch | pytorch-main/test/quantization/core/experimental/apot_fx_graph_mode_ptq.py | import torch
import torch.nn as nn
import torch.ao.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... | 4,104 | 30.098485 | 114 | py |
pytorch | pytorch-main/test/quantization/core/experimental/test_quantized_tensor.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... | 1,546 | 35.833333 | 95 | py |
pytorch | pytorch-main/test/quantization/core/experimental/test_linear.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 ... | 2,344 | 34.530303 | 89 | py |
pytorch | pytorch-main/test/quantization/core/experimental/test_bits.py | # Owner(s): ["oncall: quantization"]
import torch
from torch.testing._internal.common_utils import run_tests, TestCase
from torch.utils._mode_utils import no_dispatch
from torch.utils._pytree import tree_map
class Int16Tensor(torch.Tensor):
def __new__(cls, elem):
assert elem.dtype == torch.bits16
... | 1,812 | 29.728814 | 93 | py |
pytorch | pytorch-main/test/quantization/core/experimental/test_nonuniform_observer.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... | 7,335 | 32.497717 | 98 | py |
pytorch | pytorch-main/test/quantization/ao_migration/test_quantization.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_function_import_quantize(self):
function_list =... | 7,818 | 34.06278 | 74 | py |
pytorch | pytorch-main/test/quantization/ao_migration/test_quantization_fx.py | # Owner(s): ["oncall: quantization"]
from .common import AOMigrationTestCase
class TestAOMigrationQuantizationFx(AOMigrationTestCase):
def test_function_import_quantize_fx(self):
function_list = [
'_check_is_graph_module',
'_swap_ff_with_fxff',
'_fuse_fx',
'... | 5,635 | 33.365854 | 75 | py |
pytorch | pytorch-main/test/quantization/ao_migration/test_ao_migration.py | # Owner(s): ["oncall: quantization"]
from .common import AOMigrationTestCase
class TestAOMigrationNNQuantized(AOMigrationTestCase):
def test_functional_import(self):
r"""Tests the migration of the torch.nn.quantized.functional"""
function_list = [
'avg_pool2d',
'avg_pool3d... | 10,551 | 29.062678 | 92 | py |
pytorch | pytorch-main/test/quantization/ao_migration/common.py | from torch.testing._internal.common_utils import TestCase
import importlib
from typing import List, Optional
class AOMigrationTestCase(TestCase):
def _test_function_import(self, package_name: str, function_list: List[str],
base: Optional[str] = None, new_package_name: Optional[str] =... | 2,133 | 48.627907 | 102 | py |
pytorch | pytorch-main/test/quantization/jit/test_fusion_passes.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... | 4,585 | 40.690909 | 77 | py |
pytorch | pytorch-main/test/quantization/jit/test_ondevice_quantization.py | # -*- coding: utf-8 -*-
# Owner(s): ["oncall: quantization"]
import torch
import torch._C
from torch.ao.quantization import (
default_dynamic_qconfig,
per_channel_dynamic_qconfig,
)
from torch.ao.quantization.quantize_jit import (
prepare_dynamic_jit,
convert_dynamic_jit,
_prepare_ondevice_dynami... | 21,982 | 40.477358 | 128 | py |
pytorch | pytorch-main/test/quantization/jit/test_deprecated_jit_quant.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... | 12,500 | 40.809365 | 115 | py |
pytorch | pytorch-main/test/quantization/jit/test_quantize_jit.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... | 143,858 | 36.124903 | 97 | py |
pytorch | pytorch-main/test/quantization/bc/test_backward_compatibility.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.ao.nn.quantized as nnq
import torch.ao.nn.quantized.dynamic as nnqd
import torch.ao.nn.intrinsic.quantized as nniq
from torch.fx import Graph... | 16,660 | 42.501305 | 123 | py |
pytorch | pytorch-main/test/quantization/eager/test_quantize_eager_ptq.py | # Owner(s): ["oncall: quantization"]
import torch
import torch.nn as nn
import torch.ao.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,
... | 60,941 | 39.466135 | 132 | py |
pytorch | pytorch-main/test/quantization/eager/test_numeric_suite_eager.py | # Owner(s): ["oncall: quantization"]
import unittest
import torch
import torch.nn as nn
import torch.ao.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 (
... | 24,440 | 40.566327 | 131 | py |
pytorch | pytorch-main/test/quantization/eager/test_equalize_eager.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... | 7,845 | 40.078534 | 118 | py |
pytorch | pytorch-main/test/quantization/eager/test_quantize_eager_qat.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.ao.nn.intrinsic.qat import ConvBn2d, ConvBnReLU2d
from torch.nn.modules.utils import _pair
import torch.ao.nn.quantized as nnq
imp... | 45,913 | 40.513562 | 125 | py |
pytorch | pytorch-main/test/quantization/eager/test_bias_correction_eager.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... | 4,141 | 38.826923 | 113 | py |
pytorch | pytorch-main/test/quantization/eager/test_fuse_eager.py | # Owner(s): ["oncall: quantization"]
import copy
import torch
import torch.nn as nn
import torch.ao.nn.quantized as nnq
import torch.ao.nn.intrinsic as nni
import torch.ao.nn.intrinsic.quantized as nniq
import torch.ao.nn.intrinsic.qat as nniqat
from torch.ao.quantization import (
quantize,
prepare,
conve... | 21,548 | 45.341935 | 132 | py |
pytorch | pytorch-main/test/quantization/eager/test_model_numerics.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... | 6,922 | 54.384 | 118 | py |
pytorch | pytorch-main/test/quantization/fx/test_equalize_fx.py | # Owner(s): ["oncall: quantization"]
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.ao.nn.intrinsic.quantized as nniq
import torch.ao.nn.quantized as nnq
from torch.ao.quantization import default_qconfig
from torch.ao.quantization.observer import MinMaxObserver, PerChannelMinMaxObserve... | 38,451 | 41.867336 | 118 | py |
pytorch | pytorch-main/test/quantization/fx/test_model_report_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... | 83,869 | 41.81266 | 128 | py |
pytorch | pytorch-main/test/quantization/fx/test_numeric_suite_fx.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,
QConfigMapping,
get_default_qconfig_mapping,
)
import torch.ao.nn.quantized as nnq
to... | 115,463 | 38.66472 | 131 | py |
pytorch | pytorch-main/test/quantization/fx/test_subgraph_rewriter.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... | 15,868 | 31.385714 | 121 | py |
pytorch | pytorch-main/test/quantization/fx/test_quantize_fx.py | # Owner(s): ["oncall: quantization"]
from collections import OrderedDict
import contextlib
import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.ao.nn.quantized as nnq
import torch.ao.nn.quantized.reference as nnqr
import torch.ao.nn.quantized.dynamic as nnqd
import torch.ao.nn.intrinsic as n... | 397,325 | 39.864548 | 132 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.