diff --git a/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py b/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py index b54ad0951e7c828f73ed9f5df1f4169e0c6fea25..fe940663f07e0ba2ba0f22e53c2e3e711ef8757d 100644 --- a/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py +++ b/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py @@ -676,8 +676,8 @@ class TFOpMapper(OpMapper): input = self.graph.get_input_node(node, 0) paddings = self.graph.get_input_node(node, 1) assert paddings.layer_type == "Const", "Padding should be Const" - paddings = numpy.flip(paddings.value, 0).flatten().tolist() - dim = int(len(paddings) / 2) + new_paddings = numpy.flip(paddings.value, 0).flatten().tolist() + dim = int(len(new_paddings) / 2) transpose_name = gen_name("pad", "transpose") self.paddle_graph.add_layer( kernel="paddle.transpose", @@ -688,7 +688,7 @@ class TFOpMapper(OpMapper): kernel="paddle.nn.Pad{}D".format(dim), inputs={"x": transpose_name}, outputs=layer_outputs, - pad=new_padding) + pad=new_paddings) self.paddle_graph.add_layer( kernel="paddle.transpose", inputs={"x": node.name}, diff --git a/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py b/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py index 0167e5685b6935457d06e64b1f77b8c7a181554c..20317792370bee14ba56691c531b0dc0d656c5ea 100644 --- a/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py +++ b/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py @@ -661,7 +661,7 @@ class TFOpMapper(OpMapper): input = self.graph.get_input_node(node, 0) paddings = self.graph.get_input_node(node, 1) assert paddings.layer_type == "Const", "Padding should be Const" - paddings = numpy.flip(paddings.value, 0).flatten().tolist() + new_paddings = numpy.flip(paddings.value, 0).flatten().tolist() transpose_name = gen_name("pad", "transpose") self.paddle_graph.add_layer( kernel="paddle.transpose", @@ -672,7 +672,7 @@ class TFOpMapper(OpMapper): kernel="paddle.nn.functional.pad".format(dim), inputs={"x": transpose_name}, outputs=[node.name], - pad=new_padding) + pad=new_paddings) self.paddle_graph.add_layer( kernel="paddle.transpose", inputs={"x": node.name},