From 4eb7510d2a9eb2f5f33d22fac0469904fa024859 Mon Sep 17 00:00:00 2001 From: WJJ1995 Date: Wed, 11 May 2022 18:41:29 +0800 Subject: [PATCH] Support ONNX Roberta model (#793) * add replication pad * update op_list.md * re-lint * fixed aten::index * rm useless code * Support Wav2vec2 * Support onnx roberta * update op_list.md * deal with comments * deal with comments --- docs/inference_model_convertor/op_list.md | 1 + x2paddle/op_mapper/onnx2paddle/opset9/opset.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/inference_model_convertor/op_list.md b/docs/inference_model_convertor/op_list.md index 57d8a92..b8e89a8 100755 --- a/docs/inference_model_convertor/op_list.md +++ b/docs/inference_model_convertor/op_list.md @@ -76,6 +76,7 @@ | 81 | Add | 82 | Concat | 83 | Max | 84 | Min | | 85 | GreaterOrEqual | 86 | GatherND | 87 | And | 88 | cos | | 89 | Neg | 90 | SpaceToDepth | 91 | GatherElement | 92 | Sin | +| 93 | CumSum | | | | | | | ## PyTorch diff --git a/x2paddle/op_mapper/onnx2paddle/opset9/opset.py b/x2paddle/op_mapper/onnx2paddle/opset9/opset.py index 05acacd..a4b3a15 100755 --- a/x2paddle/op_mapper/onnx2paddle/opset9/opset.py +++ b/x2paddle/op_mapper/onnx2paddle/opset9/opset.py @@ -457,6 +457,19 @@ class OpSet9(): outputs=[node.name], **attrs) + @print_mapping_info + def CumSum(self, node): + val_x = self.graph.get_input_node(node, idx=0, copy=True) + axis = self.graph.get_input_node(node, idx=1, copy=True) + axis_values = _const_weight_or_none(axis) + assert axis_values is not None, 'Axis only support constant tensor!' + layer_attrs = {'axis': axis_values} + self.paddle_graph.add_layer( + 'paddle.cumsum', + inputs={"x": val_x.name}, + outputs=[node.name], + **layer_attrs) + @print_mapping_info def HardSigmoid(self, node): val_x = self.graph.get_input_node(node, idx=0, copy=True) -- GitLab