Skip to content

Commit 9945fd7

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Drop unused imports from caffe2/python (pytorch#49980)
Summary: Pull Request resolved: pytorch#49980 From ``` ./python/libcst/libcst codemod remove_unused_imports.RemoveUnusedImportsWithGlean --no-format caffe2/ ``` Test Plan: Standard sandcastle tests Reviewed By: xush6528 Differential Revision: D25727359 fbshipit-source-id: c4f60005b10546423dc093d31d46deb418352286
1 parent eee849b commit 9945fd7

File tree

96 files changed

+37
-155
lines changed

Some content is hidden

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

96 files changed

+37
-155
lines changed

caffe2/python/_import_c_extension.py

-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
import sys
66
from caffe2.python import extension_loader
77

8-
# NOTE: we have to import python protobuf here **before** we load cpp extension.
9-
# Otherwise it breaks under certain build conditions if cpp implementation of
10-
# protobuf is used. Presumably there's some registry in protobuf library and
11-
# python side has to initialize the dictionary first, before static
12-
# initialization in python extension does so. Otherwise, duplicated protobuf
13-
# descriptors will be created and it can lead to obscure errors like
14-
# "Parameter to MergeFrom() must be instance of same class:
15-
# expected caffe2.NetDef got caffe2.NetDef."
16-
import caffe2.proto
17-
188
# We will first try to load the gpu-enabled caffe2. If it fails, we will then
199
# attempt to load the cpu version. The cpu backend is the minimum required, so
2010
# if that still fails, we will exit loud.

caffe2/python/benchmarks/sparse_lengths_sum_nbit_benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import hypothesis.strategies as st
77
import numpy as np
8-
from caffe2.python import core, dyndep, workspace
8+
from caffe2.python import core, workspace
99

1010

1111
def benchmark_sparse_lengths_sum(

caffe2/python/convert.py

-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@
55

66

77

8-
from caffe2.proto import caffe2_pb2, torch_pb2
9-
10-
import caffe2.python._import_c_extension as C

caffe2/python/convert_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44

55

6-
from caffe2.python import convert, workspace
7-
from caffe2.proto import caffe2_pb2, torch_pb2
6+
from caffe2.python import workspace
87
import unittest
9-
import numpy as np
108

119
class TestOperator(unittest.TestCase):
1210
def setUp(self):

caffe2/python/core_gradients_test.py

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

44

55

6-
from future.utils import bytes_to_native_str
76
from hypothesis import given, settings
87
import hypothesis.strategies as st
98
import unittest

caffe2/python/dataio_test.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from caffe2.python.dataio import (
77
CompositeReader,
88
CompositeReaderBuilder,
9-
Reader,
109
ReaderBuilder,
1110
ReaderWithDelay,
1211
ReaderWithLimit,
@@ -29,7 +28,6 @@
2928
import shutil
3029
import unittest
3130
import tempfile
32-
import time
3331

3432

3533
def make_source_dataset(ws, size=100, offset=0, name=None):

caffe2/python/ideep/conv_op_test.py

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

55

66
import unittest
7-
import sys
87
import hypothesis.strategies as st
98
from hypothesis import given, settings
109
import numpy as np

caffe2/python/ideep/convfusion_op_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import unittest
77
import hypothesis.strategies as st
8-
from hypothesis import given, settings
9-
import copy
8+
from hypothesis import given
109
import numpy as np
1110
import math
1211
from caffe2.proto import caffe2_pb2

caffe2/python/ideep/dropout_op_test.py

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from hypothesis import given
88
import hypothesis.strategies as st
99
import numpy as np
10-
11-
from caffe2.proto import caffe2_pb2
1210
from caffe2.python import core, workspace
1311
import caffe2.python.hypothesis_test_util as hu
1412
import caffe2.python.ideep_test_util as mu

caffe2/python/ideep/order_switch_op_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import caffe2.python.ideep_test_util as mu
1111

1212
from hypothesis import given, settings
13-
from caffe2.proto import caffe2_pb2
1413
from caffe2.python import core, workspace
1514

1615

caffe2/python/ideep/shape_op_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import hypothesis.strategies as st
88
from hypothesis import given, settings
99
import numpy as np
10-
from caffe2.proto import caffe2_pb2
1110
from caffe2.python import core, workspace
1211
import caffe2.python.hypothesis_test_util as hu
1312
import caffe2.python.ideep_test_util as mu

caffe2/python/ideep/spatial_bn_op_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import hypothesis.strategies as st
88
import numpy as np
99
import unittest
10-
from caffe2.python import brew, core, workspace
10+
from caffe2.python import core, workspace
1111
import caffe2.python.hypothesis_test_util as hu
12-
from caffe2.python.model_helper import ModelHelper
1312
import caffe2.python.ideep_test_util as mu
1413

1514

caffe2/python/ideep/test_ideep_net.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import numpy as np
1010
import argparse
1111
import time
12-
import os.path
1312

1413

1514
def GetArgumentParser():

caffe2/python/ideep/transform_ideep_net.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import argparse
77
import copy
88
import json
9-
import os.path
109

1110
import numpy as np
1211

caffe2/python/ideep/transpose_op_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import hypothesis.strategies as st
88
from hypothesis import given, settings
99
import numpy as np
10-
from caffe2.proto import caffe2_pb2
1110
from caffe2.python import core, workspace
1211
import caffe2.python.hypothesis_test_util as hu
1312
import caffe2.python.ideep_test_util as mu

caffe2/python/ideep_test_util.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import hypothesis.strategies as st
1515

1616
from caffe2.proto import caffe2_pb2
17-
from caffe2.python import workspace
1817
from caffe2.python import hypothesis_test_util as hu
1918

2019
cpu_do = hu.cpu_do

caffe2/python/layer_model_helper.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from caffe2.python.optimizer import get_param_device, Optimizer
1818
from caffe2.python.regularizer import Regularizer, RegularizationBy
1919
from caffe2.python.layers import layers
20-
from caffe2.proto import caffe2_pb2
2120
from future.utils import viewitems, viewvalues
2221

2322
import logging

caffe2/python/mkl/mkl_LRN_op_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import unittest
77
import hypothesis.strategies as st
8-
from hypothesis import given, settings
8+
from hypothesis import given
99
import numpy as np
1010
from caffe2.python import core, workspace
1111
import caffe2.python.hypothesis_test_util as hu

caffe2/python/mkl/mkl_LRN_speed_test.py

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

77
import numpy as np
88
from caffe2.proto import caffe2_pb2
9-
from caffe2.python import cnn, core, workspace, test_util
9+
from caffe2.python import core, workspace, test_util
1010

1111

1212
@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")

caffe2/python/mkl/mkl_conv_op_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import unittest
77
import hypothesis.strategies as st
8-
from hypothesis import given, settings
8+
from hypothesis import given
99
import numpy as np
1010
from caffe2.python import core, workspace
1111
import caffe2.python.hypothesis_test_util as hu

caffe2/python/mkl/mkl_fc_op_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import unittest
77
import hypothesis.strategies as st
8-
from hypothesis import given, settings
8+
from hypothesis import given
99
import numpy as np
1010
from caffe2.python import core, workspace
1111
import caffe2.python.hypothesis_test_util as hu

caffe2/python/mkl/mkl_fc_speed_test.py

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

77
import numpy as np
88
from caffe2.proto import caffe2_pb2
9-
from caffe2.python import cnn, core, workspace, test_util
9+
from caffe2.python import core, workspace, test_util
1010

1111

1212
@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")

caffe2/python/mkl/mkl_fill_op_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import unittest
77
import hypothesis.strategies as st
8-
from hypothesis import given, settings
9-
import numpy as np
8+
from hypothesis import given
109
from caffe2.python import core, workspace
1110
import caffe2.python.hypothesis_test_util as hu
1211
import caffe2.python.mkl_test_util as mu

caffe2/python/mkl/mkl_pool_speed_test.py

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

77
import numpy as np
88
from caffe2.proto import caffe2_pb2
9-
from caffe2.python import cnn, core, workspace, test_util
9+
from caffe2.python import core, workspace, test_util
1010

1111

1212
@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")

caffe2/python/mkl/mkl_sbn_op_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import unittest
77
import hypothesis.strategies as st
8-
from hypothesis import given, settings
8+
from hypothesis import given
99
import numpy as np
1010
from caffe2.python import core, workspace
1111
import caffe2.python.hypothesis_test_util as hu

caffe2/python/mkl/mkl_sbn_speed_test.py

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

77
import numpy as np
88
from caffe2.proto import caffe2_pb2
9-
from caffe2.python import cnn, core, workspace, test_util
9+
from caffe2.python import core, workspace, test_util
1010

1111

1212
@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")

caffe2/python/mkl/mkl_speed_test.py

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

77
import numpy as np
88
from caffe2.proto import caffe2_pb2
9-
from caffe2.python import cnn, core, workspace, test_util
9+
from caffe2.python import core, workspace, test_util
1010

1111

1212
@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")

caffe2/python/mkl/rewrite_graph.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import copy
77
from caffe2.proto import caffe2_pb2
88
from caffe2.python import core
9-
import caffe2.python._import_c_extension as C
109

1110

1211
def rewrite_init_net_simple(net):

caffe2/python/nomnigraph_test.py

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

44

55

6-
from caffe2.python import core, workspace, test_util
6+
from caffe2.python import core, test_util
77
from caffe2.proto import caffe2_pb2
88
import caffe2.python.nomnigraph as ng
99

caffe2/python/onnx/backend.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
66
To run this, you will need to have Caffe2 installed as well.
77
"""
8-
9-
10-
11-
12-
13-
import os
148
import collections
15-
from subprocess import Popen, PIPE
169
import sys
1710
import zipfile
1811
import itertools
@@ -23,16 +16,14 @@
2316
# importing onnx first, which will cause it to go out and pick up the
2417
# system protobuf.
2518
import onnx.backend
26-
27-
import caffe2
2819
from caffe2.python import core, workspace, rnn_cell, gru_cell
2920
from caffe2.python.compatibility import container_abcs
3021
from caffe2.python.model_helper import ModelHelper
3122
from caffe2.proto import caffe2_pb2
3223
import caffe2.python.utils
3324
import numpy as np
3425
import onnx
35-
from onnx import checker, GraphProto, TensorProto, AttributeProto, ModelProto
26+
from onnx import TensorProto
3627
import onnx.numpy_helper
3728
import onnx.defs
3829
import onnx.optimizer
@@ -42,7 +33,6 @@
4233

4334
from caffe2.python.onnx.workspace import Workspace
4435
from caffe2.python.onnx.backend_rep import Caffe2Rep
45-
from caffe2.python.onnx.backend_cpp_rep import Caffe2CppRep
4636

4737
import caffe2.python._import_c_extension as C
4838

caffe2/python/onnx/bin/conversion.py

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

1010
from caffe2.proto import caffe2_pb2
1111
import click
12-
import numpy as np
13-
from onnx import checker, ModelProto
12+
from onnx import ModelProto
1413

1514
from caffe2.python.onnx.backend import Caffe2Backend as c2
1615
import caffe2.python.onnx.frontend as c2_onnx

caffe2/python/onnx/frontend.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717

1818
from caffe2.python import core as caffe2_core
1919
from caffe2.python.compatibility import container_abcs
20-
from caffe2.proto import caffe2_legacy_pb2
21-
from enum import Enum
22-
from onnx import (defs, checker, helper, numpy_helper, mapping,
23-
ModelProto, GraphProto, NodeProto, AttributeProto, TensorProto, OperatorSetIdProto)
24-
from onnx.helper import make_tensor, make_tensor_value_info, make_attribute, make_model
20+
from onnx import (checker, helper, numpy_helper, mapping,
21+
GraphProto, NodeProto, TensorProto, OperatorSetIdProto)
22+
from onnx.helper import make_tensor_value_info, make_model
2523
import numpy as np
2624

2725
from caffe2.python.onnx.helper import c2_native_run_net
28-
from caffe2.python.onnx.error import Unsupported
2926

3027
import caffe2.python._import_c_extension as C
3128

caffe2/python/onnx/helper.py

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
from onnx.backend.base import namedtupledict
1010

1111
from caffe2.python.onnx.workspace import Workspace
12-
import caffe2.python._import_c_extension as C
13-
14-
import io
1512
import logging
1613
import time
1714

caffe2/python/onnx/onnxifi.py

-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212

1313
from caffe2.proto import caffe2_pb2
14-
from caffe2.python import core, workspace
1514
import caffe2.python._import_c_extension as C
16-
import numpy as np
1715

1816

1917
def onnxifi_caffe2_net(

caffe2/python/onnx/test_onnxifi.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33

44

55

6-
import json
76
import numpy as np
8-
import os
97
import time
108
import unittest
119

1210
import onnx
1311
import onnx.defs
1412
from onnx.backend.base import namedtupledict
15-
from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
13+
from onnx.helper import make_node, make_graph, make_tensor_value_info, make_model
1614
from caffe2.proto import caffe2_pb2
1715
from caffe2.python import core, workspace
1816
from caffe2.python.models.download import ModelDownloader

caffe2/python/onnx/tests/c2_ref_test.py

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

77

88

9-
import json
109
import os
1110
import unittest
1211

@@ -17,7 +16,7 @@
1716
from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
1817
from caffe2.python.onnx.helper import c2_native_run_net, c2_native_run_op
1918

20-
from onnx import defs, mapping
19+
from onnx import mapping
2120
import caffe2.python.onnx.frontend as c2_onnx
2221
import caffe2.python.onnx.backend as c2
2322

0 commit comments

Comments
 (0)