提交 3cf6f557 编写于 作者: S SunAhong1993

fix the pad

上级 8c13edc1
...@@ -643,12 +643,18 @@ class TFOpMapper(OpMapper): ...@@ -643,12 +643,18 @@ class TFOpMapper(OpMapper):
paddings = self.graph.get_input_node(node, 1) paddings = self.graph.get_input_node(node, 1)
assert paddings.layer_type == "Const", "Padding should be Const" assert paddings.layer_type == "Const", "Padding should be Const"
paddings = paddings.value.flatten().tolist() paddings = paddings.value.flatten().tolist()
constant_values = 0
if len(node.layer.input) > 2:
constant_values = self.graph.get_input_node(node, 2)
assert constant_values.layer_type == "Const", "Padding should be Const"
constant_values = constant_values.value
self.paddle_graph.add_layer( self.paddle_graph.add_layer(
kernel="paddle.nn.functional.pad", kernel="paddle.nn.functional.pad",
inputs={"x": input.name}, inputs={"x": input.name},
outputs=[node.name], outputs=[node.name],
pad=paddings) pad=paddings,
value=constant_values)
def MirrorPad(self, node): def MirrorPad(self, node):
self.Pad(node) self.Pad(node)
......
...@@ -631,12 +631,18 @@ class TFOpMapper(OpMapper): ...@@ -631,12 +631,18 @@ class TFOpMapper(OpMapper):
paddings = self.graph.get_input_node(node, 1) paddings = self.graph.get_input_node(node, 1)
assert paddings.layer_type == "Const", "Padding should be Const" assert paddings.layer_type == "Const", "Padding should be Const"
paddings = paddings.value.flatten().tolist() paddings = paddings.value.flatten().tolist()
constant_values = 0
if len(node.layer.input) > 2:
constant_values = self.graph.get_input_node(node, 2)
assert constant_values.layer_type == "Const", "Padding should be Const"
constant_values = constant_values.value
self.paddle_graph.add_layer( self.paddle_graph.add_layer(
kernel="paddle.nn.functional.pad", kernel="paddle.nn.functional.pad",
inputs={"x": input.name}, inputs={"x": input.name},
outputs=[node.name], outputs=[node.name],
pad=paddings) pad=paddings,
value=constant_values)
def MirrorPad(self, node): def MirrorPad(self, node):
self.Pad(node) self.Pad(node)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册