From 55ac8ad6b1b06b99d5143b7177ab5fd2a897ce06 Mon Sep 17 00:00:00 2001 From: yeliang2258 <1047690002@qq.com> Date: Mon, 10 Jan 2022 12:59:52 +0000 Subject: [PATCH] fix neg --- .../op_mapper/onnx2paddle/opset9/opset.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/x2paddle/op_mapper/onnx2paddle/opset9/opset.py b/x2paddle/op_mapper/onnx2paddle/opset9/opset.py index 85cde5e..d923272 100755 --- a/x2paddle/op_mapper/onnx2paddle/opset9/opset.py +++ b/x2paddle/op_mapper/onnx2paddle/opset9/opset.py @@ -2000,8 +2000,25 @@ class OpSet9(): @print_mapping_info def Neg(self, node): val_x = self.graph.get_input_node(node, idx=0, copy=True) - self.paddle_graph.add_layer( - "paddle.neg", inputs={'x': val_x.name}, outputs=[node.name]) + v0, v1, v2 = paddle.__version__.split('.') + if int(v0) >= 2 and int(v1) >= 2: + self.paddle_graph.add_layer( + "paddle.neg", inputs={'x': val_x.name}, outputs=[node.name]) + else: + val_y = node.name + "_y" + dtype = np.dtype(val_x.dtype) + self.paddle_graph.add_layer( + "paddle.full", + inputs={}, + outputs=[val_y], + dtype=string(dtype), + shape=[1], + fill_value=-1) + self.paddle_graph.add_layer( + "paddle.multiply", + inputs={'x': val_x.name, + 'y': val_y}, + outputs=[node.name]) @print_mapping_info def SpaceToDepth(self, node): -- GitLab