diff --git a/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py b/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py index a326e8abf43df44c786d909f9480b7b920701514..f08c2fc5efd27fd63d4dfb8c14caf6d37fac60ab 100644 --- a/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py +++ b/x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py @@ -248,6 +248,15 @@ class TFOpMapper(OpMapper): inputs={"x": input.name}, outputs=[node.name], perm=perm) + + def Neg(self, node): + input = self.graph.get_input_node(node, 0) + + self.paddle_graph.add_layer( + "paddle.scale", + inputs={"x": input.name}, + outputs=[node.name], + scale=-1) def Fill(self, node): dims = self.graph.get_input_node(node, 0) diff --git a/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py b/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py index 851810e246ae2cbb476191e6ac06159eedc0a87f..037b68a8639e55d00fece74fdf68d18022f12706 100644 --- a/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py +++ b/x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py @@ -304,6 +304,15 @@ class TFOpMapper(OpMapper): inputs={"x": node.name}, outputs=[node.name], perm=[0, 2, 3, 1]) + + def Neg(self, node): + input = self.graph.get_input_node(node, 0) + + self.paddle_graph.add_layer( + "paddle.scale", + inputs={"x": input.name}, + outputs=[node.name], + scale=-1) def MaxPool(self, node): input = self.graph.get_node(node.layer.input[0])