Skip to content

Commit

Permalink
Drop unused imports from caffe2/python (pytorch#49980)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
r-barnes authored and facebook-github-bot committed Jan 5, 2021
1 parent eee849b commit 9945fd7
Show file tree
Hide file tree
Showing 96 changed files with 37 additions and 155 deletions.
10 changes: 0 additions & 10 deletions caffe2/python/_import_c_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
import sys
from caffe2.python import extension_loader

# NOTE: we have to import python protobuf here **before** we load cpp extension.
# Otherwise it breaks under certain build conditions if cpp implementation of
# protobuf is used. Presumably there's some registry in protobuf library and
# python side has to initialize the dictionary first, before static
# initialization in python extension does so. Otherwise, duplicated protobuf
# descriptors will be created and it can lead to obscure errors like
# "Parameter to MergeFrom() must be instance of same class:
# expected caffe2.NetDef got caffe2.NetDef."
import caffe2.proto

# We will first try to load the gpu-enabled caffe2. If it fails, we will then
# attempt to load the cpu version. The cpu backend is the minimum required, so
# if that still fails, we will exit loud.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, dyndep, workspace
from caffe2.python import core, workspace


def benchmark_sparse_lengths_sum(
Expand Down
3 changes: 0 additions & 3 deletions caffe2/python/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@



from caffe2.proto import caffe2_pb2, torch_pb2

import caffe2.python._import_c_extension as C
4 changes: 1 addition & 3 deletions caffe2/python/convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@



from caffe2.python import convert, workspace
from caffe2.proto import caffe2_pb2, torch_pb2
from caffe2.python import workspace
import unittest
import numpy as np

class TestOperator(unittest.TestCase):
def setUp(self):
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/core_gradients_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@



from future.utils import bytes_to_native_str
from hypothesis import given, settings
import hypothesis.strategies as st
import unittest
Expand Down
2 changes: 0 additions & 2 deletions caffe2/python/dataio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from caffe2.python.dataio import (
CompositeReader,
CompositeReaderBuilder,
Reader,
ReaderBuilder,
ReaderWithDelay,
ReaderWithLimit,
Expand All @@ -29,7 +28,6 @@
import shutil
import unittest
import tempfile
import time


def make_source_dataset(ws, size=100, offset=0, name=None):
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep/conv_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


import unittest
import sys
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
Expand Down
3 changes: 1 addition & 2 deletions caffe2/python/ideep/convfusion_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import copy
from hypothesis import given
import numpy as np
import math
from caffe2.proto import caffe2_pb2
Expand Down
2 changes: 0 additions & 2 deletions caffe2/python/ideep/dropout_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from hypothesis import given
import hypothesis.strategies as st
import numpy as np

from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep/order_switch_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import caffe2.python.ideep_test_util as mu

from hypothesis import given, settings
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace


Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep/shape_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
Expand Down
3 changes: 1 addition & 2 deletions caffe2/python/ideep/spatial_bn_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import hypothesis.strategies as st
import numpy as np
import unittest
from caffe2.python import brew, core, workspace
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
from caffe2.python.model_helper import ModelHelper
import caffe2.python.ideep_test_util as mu


Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep/test_ideep_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
import argparse
import time
import os.path


def GetArgumentParser():
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep/transform_ideep_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import argparse
import copy
import json
import os.path

import numpy as np

Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep/transpose_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/ideep_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import hypothesis.strategies as st

from caffe2.proto import caffe2_pb2
from caffe2.python import workspace
from caffe2.python import hypothesis_test_util as hu

cpu_do = hu.cpu_do
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/layer_model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from caffe2.python.optimizer import get_param_device, Optimizer
from caffe2.python.regularizer import Regularizer, RegularizationBy
from caffe2.python.layers import layers
from caffe2.proto import caffe2_pb2
from future.utils import viewitems, viewvalues

import logging
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_LRN_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
from hypothesis import given
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_LRN_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import cnn, core, workspace, test_util
from caffe2.python import core, workspace, test_util


@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_conv_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
from hypothesis import given
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_fc_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
from hypothesis import given
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_fc_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import cnn, core, workspace, test_util
from caffe2.python import core, workspace, test_util


@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")
Expand Down
3 changes: 1 addition & 2 deletions caffe2/python/mkl/mkl_fill_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from hypothesis import given
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.mkl_test_util as mu
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_pool_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import cnn, core, workspace, test_util
from caffe2.python import core, workspace, test_util


@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_sbn_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
from hypothesis import given
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_sbn_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import cnn, core, workspace, test_util
from caffe2.python import core, workspace, test_util


@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/mkl/mkl_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import cnn, core, workspace, test_util
from caffe2.python import core, workspace, test_util


@unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.")
Expand Down
1 change: 0 additions & 1 deletion caffe2/python/mkl/rewrite_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import copy
from caffe2.proto import caffe2_pb2
from caffe2.python import core
import caffe2.python._import_c_extension as C


def rewrite_init_net_simple(net):
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/nomnigraph_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@



from caffe2.python import core, workspace, test_util
from caffe2.python import core, test_util
from caffe2.proto import caffe2_pb2
import caffe2.python.nomnigraph as ng

Expand Down
12 changes: 1 addition & 11 deletions caffe2/python/onnx/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
To run this, you will need to have Caffe2 installed as well.
"""





import os
import collections
from subprocess import Popen, PIPE
import sys
import zipfile
import itertools
Expand All @@ -23,16 +16,14 @@
# importing onnx first, which will cause it to go out and pick up the
# system protobuf.
import onnx.backend

import caffe2
from caffe2.python import core, workspace, rnn_cell, gru_cell
from caffe2.python.compatibility import container_abcs
from caffe2.python.model_helper import ModelHelper
from caffe2.proto import caffe2_pb2
import caffe2.python.utils
import numpy as np
import onnx
from onnx import checker, GraphProto, TensorProto, AttributeProto, ModelProto
from onnx import TensorProto
import onnx.numpy_helper
import onnx.defs
import onnx.optimizer
Expand All @@ -42,7 +33,6 @@

from caffe2.python.onnx.workspace import Workspace
from caffe2.python.onnx.backend_rep import Caffe2Rep
from caffe2.python.onnx.backend_cpp_rep import Caffe2CppRep

import caffe2.python._import_c_extension as C

Expand Down
3 changes: 1 addition & 2 deletions caffe2/python/onnx/bin/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

from caffe2.proto import caffe2_pb2
import click
import numpy as np
from onnx import checker, ModelProto
from onnx import ModelProto

from caffe2.python.onnx.backend import Caffe2Backend as c2
import caffe2.python.onnx.frontend as c2_onnx
Expand Down
9 changes: 3 additions & 6 deletions caffe2/python/onnx/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@

from caffe2.python import core as caffe2_core
from caffe2.python.compatibility import container_abcs
from caffe2.proto import caffe2_legacy_pb2
from enum import Enum
from onnx import (defs, checker, helper, numpy_helper, mapping,
ModelProto, GraphProto, NodeProto, AttributeProto, TensorProto, OperatorSetIdProto)
from onnx.helper import make_tensor, make_tensor_value_info, make_attribute, make_model
from onnx import (checker, helper, numpy_helper, mapping,
GraphProto, NodeProto, TensorProto, OperatorSetIdProto)
from onnx.helper import make_tensor_value_info, make_model
import numpy as np

from caffe2.python.onnx.helper import c2_native_run_net
from caffe2.python.onnx.error import Unsupported

import caffe2.python._import_c_extension as C

Expand Down
3 changes: 0 additions & 3 deletions caffe2/python/onnx/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from onnx.backend.base import namedtupledict

from caffe2.python.onnx.workspace import Workspace
import caffe2.python._import_c_extension as C

import io
import logging
import time

Expand Down
2 changes: 0 additions & 2 deletions caffe2/python/onnx/onnxifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@


from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python._import_c_extension as C
import numpy as np


def onnxifi_caffe2_net(
Expand Down
4 changes: 1 addition & 3 deletions caffe2/python/onnx/test_onnxifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@



import json
import numpy as np
import os
import time
import unittest

import onnx
import onnx.defs
from onnx.backend.base import namedtupledict
from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
from onnx.helper import make_node, make_graph, make_tensor_value_info, make_model
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from caffe2.python.models.download import ModelDownloader
Expand Down
3 changes: 1 addition & 2 deletions caffe2/python/onnx/tests/c2_ref_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@



import json
import os
import unittest

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

from onnx import defs, mapping
from onnx import mapping
import caffe2.python.onnx.frontend as c2_onnx
import caffe2.python.onnx.backend as c2

Expand Down
Loading

0 comments on commit 9945fd7

Please sign in to comment.