[BE][Easy][9/19] enforce style for empty lines in import segments in test/[e-h]*/ (#129760)

See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501. Most changes are auto-generated by linter.

You can review these PRs via:

```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129760
Approved by: https://github.com/ezyang
This commit is contained in:
Xuehai Pan
2024-07-17 14:52:30 +08:00
committed by PyTorch MergeBot
parent cbf274d4a7
commit 76169cf691
50 changed files with 35 additions and 46 deletions

View File

@ -12,6 +12,7 @@ from torch.testing._internal.common_methods_invocations import op_db
from torch.testing._internal.common_utils import TestCase
from torch.utils._pytree import tree_map
# Simplified naming for C++ classes
SchemaArgument = torch._C._SchemaArgument
SchemaArgType = torch._C._SchemaArgType

View File

@ -5,14 +5,13 @@ from collections import OrderedDict
from typing import Dict, List, Tuple, Union
import torch
import torch.utils._pytree as pytree
from torch._dynamo.test_case import TestCase
from torch._export.converter import TS2EPConverter
from torch.export import ExportedProgram
from torch.testing._internal.common_utils import run_tests
requires_cuda = unittest.skipUnless(torch.cuda.is_available(), "requires cuda")

View File

@ -1,18 +1,15 @@
# Owner(s): ["oncall: export"]
# flake8: noqa
import unittest
from typing import Dict, List, Tuple
import torch
import torch._dynamo
from torch._dynamo.test_case import run_tests, TestCase
from torch._export.wrappers import _mark_strict_experimental
from torch._functorch.aot_autograd import aot_export_module
from torch.export._trace import _convert_ts_to_export_experimental
from torch.export.experimental import _export_forward_backward
from torch.testing import FileCheck

View File

@ -16,7 +16,6 @@ from typing import Dict, List
import torch
import torch._dynamo as torchdynamo
import torch.nn.functional as F
from functorch.experimental.control_flow import cond, map
from torch import Tensor
from torch._dynamo.test_case import TestCase
@ -61,6 +60,7 @@ from torch.utils._pytree import (
treespec_loads,
)
try:
from torchrec.sparse.jagged_tensor import KeyedJaggedTensor

View File

@ -5,8 +5,10 @@ try:
except ImportError:
import test_export
import testing
from torch.export import export
test_classes = {}

View File

@ -5,8 +5,10 @@ try:
except ImportError:
import test_export
import testing
from torch.export._trace import _export_for_training
test_classes = {}

View File

@ -24,6 +24,7 @@ from torch.testing._internal.hop_db import (
hop_that_doesnt_have_opinfo_test_allowlist,
)
hop_tests = []
for op_info in hop_db:

View File

@ -16,7 +16,6 @@ from torch.export.exported_program import (
OutputSpec,
TensorArgument,
)
from torch.export.graph_signature import CustomObjArgument
from torch.testing._internal.common_utils import (
find_library_location,

View File

@ -3,7 +3,6 @@ import copy
import unittest
import torch
from functorch.experimental import control_flow
from torch._dynamo.eval_frame import is_dynamo_supported
from torch._export.pass_base import _ExportPassBaseDeprecatedDoNotUse

View File

@ -11,7 +11,6 @@ from re import escape
from typing import List, Set
import torch
from functorch.experimental.control_flow import cond
from torch._dynamo.eval_frame import is_dynamo_supported
from torch._export.non_strict_utils import (

View File

@ -5,8 +5,10 @@ try:
except ImportError:
import test_export
import testing
from torch.export import export
test_classes = {}

View File

@ -6,7 +6,6 @@ from torch._export.serde.schema_check import (
SchemaUpdateError,
update_schema,
)
from torch.testing._internal.common_utils import IS_FBCODE, run_tests, TestCase

View File

@ -2,6 +2,7 @@
import io
try:
from . import test_export, testing
except ImportError:
@ -10,6 +11,7 @@ except ImportError:
from torch.export import export, load, save
test_classes = {}

View File

@ -7,7 +7,6 @@ import sys
import unittest
import torch
from torch._subclasses.fake_tensor import FakeTensor
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
@ -17,6 +16,7 @@ from torch.testing._internal.common_utils import (
TestCase,
)
# Various data types (preserved over operations).
DTYPES = [
torch.int64,

View File

@ -3,9 +3,9 @@
import torch
from torch._dynamo.test_case import TestCase
from torch._export.tools import report_exportability
from torch.testing._internal.common_utils import run_tests
torch.library.define(
"testlib::op_missing_meta",
"(Tensor(a!) x, Tensor(b!) z) -> Tensor",

View File

@ -8,7 +8,6 @@ import torch.utils._pytree as pytree
from torch._dynamo.testing import EagerAndRecordGraphs
from torch._functorch.aot_autograd import aot_export_module
from torch._higher_order_ops.torchbind import enable_torchbind_tracing
from torch._higher_order_ops.wrap import wrap
from torch._library.fake_class_registry import FakeScriptObject
from torch.export import export

View File

@ -3,7 +3,6 @@ from collections import OrderedDict
import torch
from torch._dynamo.test_case import TestCase
from torch.export._tree_utils import is_equivalent, reorder_kwargs
from torch.testing._internal.common_utils import run_tests
from torch.utils._pytree import tree_structure

View File

@ -10,7 +10,6 @@ from typing import Any, List
import torch
import torch._dynamo as torchdynamo
from functorch.experimental.control_flow import cond, map
from torch import Tensor
from torch._export.utils import (
@ -42,7 +41,6 @@ from torch.testing._internal.common_utils import (
skipIfTorchDynamo,
TestCase,
)
from torch.testing._internal.torchbind_impls import init_torchbind_implementations
from torch.utils._pytree import (
LeafSpec,

View File

@ -2,11 +2,9 @@
import unittest
import torch
from functorch.experimental import control_flow
from torch import Tensor
from torch._dynamo.eval_frame import is_dynamo_supported
from torch._export.verifier import SpecViolationError, Verifier
from torch.export import export
from torch.export.exported_program import InputKind, InputSpec, TensorArgument

View File

@ -4,6 +4,7 @@ from unittest.mock import patch
import torch
aten = torch.ops.aten
# This list is not meant to be comprehensive

View File

@ -6,7 +6,6 @@
import math
import torch
from functorch.dim import cat, dimlists, dims, softmax
from torch import nn

View File

@ -13,13 +13,13 @@ from functorch_additional_op_db import additional_op_db
import torch
import torch.utils._pytree as pytree
from functorch import vmap
from torch.testing._internal.autograd_function_db import autograd_function_db
from torch.testing._internal.common_device_type import toleranceOverride
from torch.testing._internal.common_methods_invocations import DecorateInfo, op_db
from torch.testing._internal.common_modules import module_db
IS_FBCODE = os.getenv("FUNCTORCH_TEST_FBCODE") == "1"

View File

@ -6,6 +6,7 @@ from enum import Enum
# Importing these files make modifications to the op_db that we need
import test_ops # noqa: F401
import test_vmap # noqa: F401
from functorch_additional_op_db import additional_op_db
@ -14,6 +15,7 @@ import torch._functorch.top_operators_github_usage as top_ops
from torch.testing._internal.common_device_type import toleranceOverride
from torch.testing._internal.common_methods_invocations import op_db
all_overridable = list(torch.overrides.get_testing_overrides().keys())
public_docs = [

View File

@ -3,7 +3,6 @@ import unittest
from functools import partial
import torch
from torch.testing._internal.common_dtype import (
all_types_and_complex_and,
floating_types,
@ -16,6 +15,7 @@ from torch.testing._internal.common_methods_invocations import (
)
from torch.testing._internal.common_utils import make_tensor
# List of OpInfos that aren't in PyTorch Core yet.
# They are here because we wanted a fast way of writing OpInfos and may not be
# 100% correct (w.r.t. to dtypes and other options).

View File

@ -80,6 +80,7 @@ from torch.testing._internal.optests import (
)
from torch.testing._internal.two_tensor import TwoTensor, TwoTensorMode
USE_TORCHVISION = False
try:
import torchvision

View File

@ -5,7 +5,6 @@ import unittest
import torch
import torch.utils._pytree as pytree
from functorch.experimental import control_flow
from functorch.experimental.control_flow import cond, UnsupportedAliasMutationException
from torch._higher_order_ops.while_loop import while_loop
@ -17,7 +16,6 @@ from torch._subclasses.functional_tensor import (
)
from torch.fx.experimental.proxy_tensor import make_fx
from torch.testing._internal.common_quantization import skipIfNoDynamoSupport
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
IS_WINDOWS,

View File

@ -6,14 +6,12 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import gc
from unittest import skip, skipIf
from attn_ft import BertSelfAttention as BertSelfAttentionA, Linear
from attn_positional import BertSelfAttention as BertSelfAttentionB
import torch
from functorch._C import dim as _C
from functorch.dim import (
Dim,
@ -24,7 +22,6 @@ from functorch.dim import (
stack,
Tensor,
)
from torch.testing._internal.common_utils import (
run_tests,
skipIfTorchDynamo,
@ -32,6 +29,7 @@ from torch.testing._internal.common_utils import (
TestCase,
)
try:
from torchvision.models import resnet18
except ImportError:
@ -46,6 +44,7 @@ _test_c, _parse_test, _set_pointwise_optimize = (
from contextlib import contextmanager
from time import perf_counter
measure_perf = False
if measure_perf:
from torchdim.magic_trace import magic_trace

View File

@ -79,9 +79,9 @@ from torch.testing._internal.common_utils import (
TestCase,
xfailIfTorchDynamo,
)
from torch.utils._pytree import tree_flatten, tree_map, tree_unflatten
USE_TORCHVISION = False
try:
import torchvision # noqa: F401

View File

@ -8,13 +8,13 @@ from typing import Callable
import torch
import torch.fx as fx
import torch.nn as nn
from functorch import make_fx
from functorch.compile import memory_efficient_fusion
from torch._functorch.compile_utils import fx_graph_cse
from torch.nn import functional as F
from torch.testing._internal.common_utils import run_tests, TestCase
HAS_CUDA = torch.cuda.is_available()

View File

@ -1,7 +1,6 @@
# Owner(s): ["module: functorch"]
import torch
from functorch import make_fx
from functorch.compile import minifier
from torch._functorch.compile_utils import get_outputs, get_placeholders

View File

@ -31,7 +31,6 @@ from functorch_additional_op_db import additional_op_db
import torch
import torch.autograd.forward_ad as fwAD
from functorch import grad, jacfwd, jacrev, vjp, vmap
from torch import Tensor
from torch._functorch.eager_transforms import _as_tuple, jvp
@ -44,7 +43,6 @@ from torch.testing._internal.common_device_type import (
toleranceOverride,
)
from torch.testing._internal.common_methods_invocations import op_db
from torch.testing._internal.common_utils import (
is_iterable_of_tensors,
IS_MACOS,
@ -59,11 +57,11 @@ from torch.testing._internal.common_utils import (
TestCase,
unMarkDynamoStrictTest,
)
from torch.testing._internal.opinfo.core import SampleInput
from torch.utils import _pytree as pytree
from torch.utils._pytree import tree_flatten, tree_map, tree_unflatten
aten = torch.ops.aten

View File

@ -34,9 +34,9 @@ from functorch.einops._parsing import (
ParsedExpression,
validate_rearrange_expressions,
)
from torch.testing._internal.common_utils import run_tests, TestCase
mock_anonymous_axis_eq: Callable[[AnonymousAxis, object], bool] = (
lambda self, other: isinstance(other, AnonymousAxis) and self.value == other.value
)

View File

@ -30,10 +30,10 @@ from typing import List, Tuple
import numpy as np
import torch
from functorch.einops import rearrange
from torch.testing._internal.common_utils import run_tests, TestCase
identity_patterns: List[str] = [
"...->...",
"a b c d e-> a b c d e",

View File

@ -36,7 +36,6 @@ from common_utils import (
from functorch_additional_op_db import additional_op_db
import functorch
import torch
import torch.nn.functional as F
from functorch import grad, grad_and_value, jacfwd, jvp, vjp, vmap
@ -71,6 +70,7 @@ from torch.testing._internal.common_utils import (
)
from torch.utils import _pytree as pytree
FALLBACK_REGEX = "There is a performance drop"

View File

@ -5,7 +5,6 @@ import unittest
from torch._C import (
_dispatch_get_registrations_for_dispatch_key as get_registrations_for_dispatch_key,
)
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
parametrize,
@ -14,6 +13,7 @@ from torch.testing._internal.common_utils import (
TestCase,
)
xfail_functorch_batched = {
"aten::is_nonzero",
"aten::item",

View File

@ -2,6 +2,7 @@ import re
import torch
"""
Instructions:

View File

@ -12,6 +12,7 @@ from torch.fx.graph import map_arg
from torch.fx.proxy import Proxy
from torch.nn.utils import fuse_conv_bn_weights
# can be a
# module type, a builtin function, or a string to match target

View File

@ -6,7 +6,6 @@ import torch
from torch.fx.experimental.proxy_tensor import make_fx
from torch.fx.graph_module import GraphModule
from torch.fx.passes.dialect.common.cse_pass import CSEPass
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
parametrize,

View File

@ -6,7 +6,6 @@ import torch
from torch.fx import symbolic_trace
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.testing._internal.common_utils import run_tests, TestCase

View File

@ -5,7 +5,6 @@ from typing import Set, Type
import torch
import torch.fx
from torch.testing._internal.common_utils import TestCase

View File

@ -4,7 +4,6 @@ import unittest
import torch
import torch.fx
from torch.testing._internal.common_utils import TestCase

View File

@ -5,7 +5,6 @@ from typing import Dict, List, Tuple
import torch
from torch.fx.passes.split_utils import split_by_tags
from torch.testing._internal.common_utils import TestCase

View File

@ -6,7 +6,6 @@ import tempfile
import torch
from torch.fx import subgraph_rewriter, symbolic_trace
from torch.fx.passes.graph_transform_observer import GraphTransformObserver
from torch.testing._internal.common_utils import TestCase

View File

@ -9,6 +9,7 @@ import torch.nn.functional as F
from torch.fx import symbolic_trace
from torch.fx.experimental.proxy_tensor import make_fx
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
import unittest

View File

@ -1,7 +1,6 @@
# Owner(s): ["module: fx"]
import unittest
from typing import Mapping
import torch

View File

@ -9,7 +9,6 @@ from torch.fx.passes.infra.pass_manager import (
PassManager,
this_before_that_pass_constraint,
)
from torch.testing._internal.common_utils import TestCase

View File

@ -6,6 +6,7 @@ import unittest
import torch
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
from torch._dynamo.eval_frame import is_dynamo_supported

View File

@ -10,10 +10,12 @@ 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.realpath(__file__)))
sys.path.append(pytorch_test_dir)
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"

View File

@ -23,7 +23,6 @@ from torch.testing._internal.common_utils import (
TEST_WITH_ROCM,
TestCase,
)
from torch.testing._internal.torchbind_impls import init_torchbind_implementations
from torch.utils.hooks import RemovableHandle # noqa: TCH001

View File

@ -45,7 +45,6 @@ ISORT_WHITELIST = re.compile(
# test/dy*/**
"test/dy*/**",
# test/[e-h]*/**
"test/[e-h]*/**",
# test/i*/**
"test/i*/**",
# test/j*/**