未验证 提交 ec92a600 编写于 作者: J Jason 提交者: GitHub

Merge pull request #438 from SunAhong1993/develop

fix the slice
...@@ -882,7 +882,7 @@ class TFOpMapper(OpMapper): ...@@ -882,7 +882,7 @@ class TFOpMapper(OpMapper):
begin = self.graph.get_node(node.layer.input[1]) begin = self.graph.get_node(node.layer.input[1])
size = self.graph.get_node(node.layer.input[2]) size = self.graph.get_node(node.layer.input[2])
inputs = {"input": input.name} inputs = {"x": input.name}
attrs = {} attrs = {}
if begin.layer_type == "Const": if begin.layer_type == "Const":
begin = begin.value.tolist() begin = begin.value.tolist()
...@@ -890,7 +890,7 @@ class TFOpMapper(OpMapper): ...@@ -890,7 +890,7 @@ class TFOpMapper(OpMapper):
else: else:
# shape = begin.out_shapes[0] # shape = begin.out_shapes[0]
# reshape_name = gen_name("slice", "reshape") # reshape_name = gen_name("slice", "reshape")
# program.add_layer( # self.paddle_graph.add_layer(
# kernel="fluid.layers.reshape", # kernel="fluid.layers.reshape",
# inputs={"x": begin.name}, # inputs={"x": begin.name},
# outputs=[reshape_name], # outputs=[reshape_name],
...@@ -901,30 +901,20 @@ class TFOpMapper(OpMapper): ...@@ -901,30 +901,20 @@ class TFOpMapper(OpMapper):
if size.layer_type == "Const": if size.layer_type == "Const":
size = size.value.tolist() size = size.value.tolist()
attrs['shape'] = size attrs['shape'] = size
shape = size
else: else:
shape = size.out_shapes[0] shape = size.out_shapes[0]
# reshape_name = gen_name("slice", "reshape") reshape_name = gen_name("slice", "reshape")
# program.add_layer( self.paddle_graph.add_layer(
# kernel="fluid.layers.reshape", kernel="fluid.layers.reshape",
# inputs={"x": size.name}, inputs={"x": size.name},
# outputs=[reshape_name], outputs=[reshape_name],
# shape=shape) shape=shape)
# inputs['shape'] = reshape_name inputs['shape'] = reshape_name
self.paddle_graph.add_layer(
# inputs.pop('shape') kernel="fluid.layers.crop_tensor",
program.add_layer(
kernel="fluid.layers.slice",
inputs=inputs, inputs=inputs,
outputs=[node.name], outputs=[node.name],
axes=list(range(len(attrs['offsets']))), **attrs)
starts=attrs['offsets'],
ends=[attrs['offsets'][i] + shape[i] for i in range(len(shape))])
# program.add_layer(
# kernel="fluid.layers.crop_tensor",
# inputs=inputs,
# outputs=[node.name],
# **attrs)
def ResizeNearestNeighbor(self, node): def ResizeNearestNeighbor(self, node):
input = self.graph.get_node(node.layer.input[0]) input = self.graph.get_node(node.layer.input[0])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册