diff --git a/x2paddle/core/fluid_code.py b/x2paddle/core/fluid_code.py index 42b51f117143cd7a3f7b3a579d2ba6c4e2f33a74..5619e087260397128de3e12563ed1cf9c776f945 100644 --- a/x2paddle/core/fluid_code.py +++ b/x2paddle/core/fluid_code.py @@ -13,8 +13,9 @@ # limitations under the License. from x2paddle.core.graph import GraphNode -import collections from x2paddle.core.util import * +import collections +import six class Layer(object): @@ -28,7 +29,7 @@ class Layer(object): def get_code(self): layer_code = "" if self.output is not None: - if isinstance(self.output, str): + if isinstance(self.output, six.string_types): layer_code = self.output + " = " else: layer_code = self.output.layer_name + " = " @@ -47,7 +48,7 @@ class Layer(object): "[{}]".format(input.index) + ", ") else: in_list += (input.layer_name + ", ") - elif isinstance(input, str): + elif isinstance(input, six.string_types): in_list += (input + ", ") else: raise Exception( @@ -72,7 +73,7 @@ class Layer(object): "[{}]".format(self.inputs.index) + ", ") else: layer_code += (self.inputs.layer_name + ", ") - elif isinstance(self.inputs, str): + elif isinstance(self.inputs, six.string_types): layer_code += (self.inputs + ", ") else: raise Exception("Unknown type of inputs.") @@ -119,6 +120,6 @@ class FluidCode(object): for layer in self.layers: if isinstance(layer, Layer): codes.append(layer.get_code()) - elif isinstance(layer, str): + elif isinstance(layer, six.string_types): codes.append(layer) return codes diff --git a/x2paddle/core/graph.py b/x2paddle/core/graph.py index 3165dcd1d9ea26ff39408c3628de8ba982c4657b..6ca6c47f5899233ba93953ba915e3c79a093c7c2 100644 --- a/x2paddle/core/graph.py +++ b/x2paddle/core/graph.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function +from __future__ import division import collections import copy as cp diff --git a/x2paddle/decoder/caffe_decoder.py b/x2paddle/decoder/caffe_decoder.py index 9573d10409064245fe33338d5ac8394604487ae1..ea9d3bc76c06f976b082838b1d794e95ac3488d0 100644 --- a/x2paddle/decoder/caffe_decoder.py +++ b/x2paddle/decoder/caffe_decoder.py @@ -236,11 +236,7 @@ class CaffeDecoder(object): data.MergeFromString(open(self.model_path, 'rb').read()) pair = lambda layer: (layer.name, self.normalize_pb_data(layer)) layers = data.layers or data.layer - import time - start = time.time() self.params = [pair(layer) for layer in layers if layer.blobs] - end = time.time() - print('cost:', str(end - start)) def normalize_pb_data(self, layer): transformed = [] diff --git a/x2paddle/op_mapper/onnx_op_mapper.py b/x2paddle/op_mapper/onnx_op_mapper.py index a2d8941a3276eb164bb496f6f0e7a6f4448265d3..4dcc922c15d21612d409dd2e568ca83335c7e194 100644 --- a/x2paddle/op_mapper/onnx_op_mapper.py +++ b/x2paddle/op_mapper/onnx_op_mapper.py @@ -94,7 +94,7 @@ class ONNXOpMapper(OpMapper): print(op) return False - def directly_map(self, node, *args, name='', **kwargs): + def directly_map(self, node, name='', *args, **kwargs): inputs = node.layer.input outputs = node.layer.output op_type = node.layer_type