提交 eb442e35 编写于 作者: 刘琦

Merge branch 'master' into 'master'

Converter compatible for TF 1.6.0

See merge request !287
...@@ -158,9 +158,14 @@ class TFConverter(object): ...@@ -158,9 +158,14 @@ class TFConverter(object):
def add_output_shape(outputs, op): def add_output_shape(outputs, op):
output_shapes = [] output_shapes = []
for output in outputs: for output in outputs:
if output.shape.num_elements() is not None:
output_shape = mace_pb2.OutputShape() output_shape = mace_pb2.OutputShape()
if isinstance(output, list):
output_shape.dims.extend(output)
elif isinstance(output, tf.Tensor):
if output.shape.num_elements() is not None:
output_shape.dims.extend(output.shape.as_list()) output_shape.dims.extend(output.shape.as_list())
else:
raise ValueError('output type not supported: ', type(output))
output_shapes.append(output_shape) output_shapes.append(output_shape)
op.output_shape.extend(output_shapes) op.output_shape.extend(output_shapes)
...@@ -782,11 +787,11 @@ class TFConverter(object): ...@@ -782,11 +787,11 @@ class TFConverter(object):
self.unused_tensor.add(get_input_tensor(reshape_op, 1).name) self.unused_tensor.add(get_input_tensor(reshape_op, 1).name)
if reshape_op.outputs[0].shape.ndims == 2: if reshape_op.outputs[0].shape.ndims == 2:
shape = reshape_op.outputs[0].shape shape = [dim.value for dim in reshape_op.outputs[0].shape]
from tensorflow.python.framework.tensor_shape import as_shape if len(shape) == 2:
reshape_op.outputs[0]._shape = as_shape([1, 1, shape[0], shape[1]]) shape = [1, 1, shape[0], shape[1]]
op_def.output.extend([output.name for output in reshape_op.outputs]) op_def.output.extend([output.name for output in reshape_op.outputs])
self.add_output_shape(reshape_op.outputs, op_def) self.add_output_shape([shape], op_def)
self.resolved_ops[reshape_op.name] = 1 self.resolved_ops[reshape_op.name] = 1
def convert_normal_op(self, op): def convert_normal_op(self, op):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册