Skip to content

Commit fbe6f42

Browse files
XuehaiPanpytorchmergebot
authored andcommitted
[BE][Easy][8/19] enforce style for empty lines in import segments in test/[k-p]*/ (pytorch#129759)
See pytorch#129751 (comment). 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: pytorch#129759 Approved by: https://github.com/justinchuby, https://github.com/ezyang
1 parent 9145775 commit fbe6f42

File tree

78 files changed

+69
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+69
-41
lines changed

test/lazy/test_debug_util.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import torch.nn as nn
1111
from torch.testing._internal.common_utils import IS_WINDOWS, run_tests, TestCase
1212

13+
1314
torch._lazy.ts_backend.init()
1415

1516

test/lazy/test_extract_compiled_graph.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from torch._lazy.ts_backend import init as init_ts_backend
66

7+
78
init_ts_backend()
89
import copy
910
import dis

test/lazy/test_functionalization.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import torch._lazy.ts_backend
88
from torch.testing._internal.common_utils import run_tests, TestCase
99

10+
1011
torch._lazy.ts_backend.init()
1112

1213
NODE_TYPE_PATTERN = re.compile(r", NodeType=[^\n]+")

test/lazy/test_generator.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import torch._lazy.ts_backend
66
from torch.testing._internal.common_utils import run_tests, skipIfTorchDynamo, TestCase
77

8+
89
torch._lazy.ts_backend.init()
910

1011

test/lazy/test_meta_kernel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import torch._lazy
55
import torch._lazy.ts_backend
66
from torch import float16, float32
7-
87
from torch.testing._internal.common_utils import TestCase
98

9+
1010
torch._lazy.ts_backend.init()
1111

1212

test/lazy/test_reuse_ir.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import torch._lazy.ts_backend
1212
from torch.testing._internal.common_utils import IS_WINDOWS, run_tests, TestCase
1313

14+
1415
torch._lazy.ts_backend.init()
1516
torch._lazy.config.set_reuse_ir(True)
1617

test/lazy/test_step_closures.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import torch._lazy.ts_backend
88
from torch.testing._internal.common_utils import run_tests, TestCase
99

10+
1011
torch._lazy.ts_backend.init()
1112

1213

test/mobile/custom_build/prepare_model.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import torch
1111

12+
1213
# Download and trace the model.
1314
model = models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1)
1415
model.eval()

test/mobile/lightweight_dispatch/tests_setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import functools
22
import os
33
import shutil
4-
54
import sys
65
from io import BytesIO
76

87
import torch
98
from torch.jit.mobile import _export_operator_list, _load_for_lite_interpreter
109

10+
1111
_OPERATORS = set()
1212
_FILENAMES = []
1313
_MODELS = []

test/mobile/model_test/gen_test_model.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@
2929
NNUtilsModule,
3030
NNVisionModule,
3131
)
32-
from quantization_ops import (
33-
FusedQuantModule,
34-
GeneralQuantModule,
35-
# DynamicQuantModule,
36-
StaticQuantModule,
37-
)
32+
from quantization_ops import FusedQuantModule, GeneralQuantModule, StaticQuantModule
3833
from sampling_ops import SamplingOpsModule
3934
from tensor_ops import (
4035
TensorCreationOpsModule,
@@ -52,6 +47,7 @@
5247
import torch
5348
from torch.jit.mobile import _load_for_lite_interpreter
5449

50+
5551
test_path_ios = "ios/TestApp/models/"
5652
test_path_android = "android/pytorch_android/src/androidTest/assets/"
5753

test/mobile/model_test/update_production_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import yaml
99

10+
1011
root_operators = {}
1112
traced_operators = {}
1213
kernel_metadata = {}

test/mobile/test_bytecode.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121
from torch.testing._internal.common_utils import run_tests, TestCase
2222

23+
2324
pytorch_test_dir = Path(__file__).resolve().parents[1]
2425

2526
# script_module_v4.ptl and script_module_v5.ptl source code

test/mobile/test_lite_script_module.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import torch
99
import torch.utils.bundled_inputs
10-
1110
from torch.jit.mobile import _export_operator_list, _load_for_lite_interpreter
1211
from torch.testing import FileCheck
1312
from torch.testing._internal.common_quantization import (

test/mobile/test_lite_script_type.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import torch
99
import torch.utils.bundled_inputs
10-
1110
from torch.jit.mobile import _load_for_lite_interpreter
1211
from torch.testing._internal.common_utils import run_tests, TestCase
1312

test/mobile/test_upgrader_codegen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
from torch.jit.generate_bytecode import generate_upgraders_bytecode
88
from torch.testing._internal.common_utils import run_tests, TestCase
9-
109
from torchgen.operator_versions.gen_mobile_upgraders import sort_upgrader, write_cpp
1110

11+
1212
pytorch_caffe2_dir = Path(__file__).resolve().parents[2]
1313

1414

test/mobile/test_upgraders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
import torch
88
import torch.utils.bundled_inputs
9-
109
from torch.jit.mobile import _load_for_lite_interpreter
1110
from torch.testing._internal.common_utils import run_tests, TestCase
1211

12+
1313
pytorch_test_dir = Path(__file__).resolve().parents[1]
1414

1515

test/nn/test_convolution.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
from itertools import product
77

88
import torch
9-
109
import torch.autograd.forward_ad as fwAD
1110
import torch.backends.cudnn as cudnn
1211
import torch.nn as nn
1312
import torch.nn.functional as F
14-
1513
from torch.testing import make_tensor
1614
from torch.testing._internal.common_cuda import (
1715
TEST_CUDA,
@@ -62,6 +60,7 @@
6260
TEST_WITH_ROCM,
6361
)
6462

63+
6564
AMPERE_OR_ROCM = TEST_WITH_ROCM or tf32_is_not_fp32()
6665

6766

test/nn/test_embedding.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
skipMeta,
2020
TEST_WITH_ROCM,
2121
)
22-
2322
from torch.testing._internal.common_nn import NNTestCase
2423
from torch.testing._internal.common_utils import (
2524
_assertGradAndGradgradChecks,

test/nn/test_init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import torch
1010
import torch.nn.functional as F
1111
import torch.nn.init as init
12-
1312
from torch.testing._internal.common_utils import (
1413
run_tests,
1514
skipIfNoLapack,
@@ -19,6 +18,7 @@
1918
TestCase,
2019
)
2120

21+
2222
if TEST_SCIPY:
2323
from scipy import stats
2424

test/nn/test_load_state_dict.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
)
2020
from torch.utils._pytree import tree_map
2121

22+
2223
if TEST_NUMPY:
2324
import numpy as np
2425

test/nn/test_module_hooks.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import weakref
88
from collections import namedtuple, OrderedDict
99
from copy import deepcopy
10-
1110
from functools import partial
1211
from tempfile import NamedTemporaryFile
1312
from typing import Any, Dict, List, Tuple

test/nn/test_multihead_attention.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import torch
88
import torch.nn as nn
9-
109
from torch.nn import MultiheadAttention
1110
from torch.testing._internal.common_device_type import (
1211
dtypes,
@@ -22,6 +21,7 @@
2221
TEST_WITH_CROSSREF,
2322
)
2423

24+
2525
if TEST_NUMPY:
2626
import numpy as np
2727

test/nn/test_parametrization.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from itertools import product
55

66
import torch
7-
87
import torch.nn as nn
98
import torch.nn.functional as F
109
import torch.nn.init as init

test/nn/test_pooling.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import torch
1414
import torch.nn as nn
1515
import torch.nn.functional as F
16-
1716
from torch import inf, nan
1817
from torch.autograd import gradcheck, gradgradcheck
1918
from torch.testing import make_tensor

test/nn/test_pruning.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import unittest.mock as mock
55

66
import torch
7-
87
import torch.nn as nn
98
import torch.nn.utils.prune as prune
109
from torch.testing._internal.common_nn import NNTestCase

test/onnx/dynamo/test_dynamo_with_onnxruntime_backend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
_OrtBackendOptions as OrtBackendOptions,
2121
ExportOptions,
2222
)
23-
2423
from torch.testing._internal import common_utils
2524
from torch.testing._internal.common_utils import skipIfNNModuleInlined
2625

26+
2727
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2828
import onnx_test_common
2929

test/onnx/dynamo/test_exporter_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
ProtobufONNXProgramSerializer,
1414
ResolvedExportOptions,
1515
)
16-
1716
from torch.testing._internal import common_utils
1817

1918

test/onnx/dynamo/test_registry_dispatcher.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from torch.testing._internal import common_utils
2323

24+
2425
# TODO: this can only be global. https://github.com/microsoft/onnxscript/issues/805
2526
TCustomFloat = TypeVar("TCustomFloat", bound=Union[FLOAT16, FLOAT, DOUBLE, BFLOAT16])
2627

test/onnx/error_reproduction.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import torch
1919

20+
2021
_MISMATCH_MARKDOWN_TEMPLATE = """\
2122
### Summary
2223

test/onnx/internal/test_diagnostics.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from torch.onnx._internal.fx import diagnostics as fx_diagnostics
1717
from torch.testing._internal import common_utils, logging_utils
1818

19+
1920
if typing.TYPE_CHECKING:
2021
import unittest
2122

test/onnx/model_defs/dcgan.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import torch
22
import torch.nn as nn
33

4+
45
# configurable
56
bsz = 64
67
imgsz = 64

test/onnx/onnx_test_common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
import contextlib
6-
76
import copy
87
import dataclasses
98
import io
@@ -26,7 +25,6 @@
2625
)
2726

2827
import numpy as np
29-
3028
import onnxruntime
3129
import pytest
3230
import pytorch_test_common
@@ -39,6 +37,7 @@
3937
from torch.testing._internal.opinfo import core as opinfo_core
4038
from torch.types import Number
4139

40+
4241
_NumericType = Union[Number, torch.Tensor, np.ndarray]
4342
_ModelType = Union[torch.nn.Module, Callable, torch_export.ExportedProgram]
4443
_InputArgsType = Optional[

test/onnx/pytorch_test_common.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from torch.onnx._internal import diagnostics
1919
from torch.testing._internal import common_utils
2020

21+
2122
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
2223
sys.path.insert(-1, pytorch_test_dir)
2324

test/onnx/test_export_modes.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from torch.autograd import Variable
1212
from torch.onnx import OperatorExportTypes
1313

14+
1415
# Make the helper files in test/ importable
1516
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
1617
sys.path.append(pytorch_test_dir)

test/onnx/test_fx_op_consistency.py

-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@
5050
)
5151

5252
import error_reproduction
53-
5453
import onnx_test_common
55-
5654
import parameterized
5755
import pytest
5856
import pytorch_test_common

test/onnx/test_fx_passes.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import torch
55
import torch._dynamo
66
import torch.fx
7-
87
from torch.onnx._internal.fx.passes import _utils as pass_utils
98
from torch.testing._internal import common_utils
109

test/onnx/test_fx_to_onnx.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
from __future__ import annotations
33

44
import logging
5-
65
import tempfile
7-
86
from typing import Mapping, Tuple
97

108
import onnx
119
import onnx.inliner
10+
1211
import pytorch_test_common
1312
import transformers # type: ignore[import]
1413

test/onnx/test_fx_to_onnx_decomp_skip.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import onnx
55
import onnx.inliner
6+
67
import pytorch_test_common
78

89
import torch

0 commit comments

Comments
 (0)