未验证 提交 ca95f0bc 编写于 作者: S SunAhong1993 提交者: GitHub

for release-1.1 (#569)

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update README.md

* fix the pad in tf  (#567)

* fix the convert.py args

* fix teh pad and add log_softmax

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md
Co-authored-by: NJason <jiangjiajun@baidu.com>
上级 2721c0a9
# Create A Good Pull Request
- [] Python code style verification
- [] All models(TensorFLow/Caffe/ONNX/PyTorch) testing passed
- [] Details about your pull request, releated issues
> 下面的文字请保留在PR说明的最后面,并在提完PR后,根据实际情况勾选确认以下情况
Please check the follow step before merging this pull request
- [ ] Python code style verification
- [ ] Review all the code diff by yourself
- [ ] All models(TensorFLow/Caffe/ONNX/PyTorch) testing passed
- [ ] Details about your pull request, releated issues
If this PR add new model support, please update `model_zoo.md` and add model to out test model zoos(@wjj19950828)
- [ ] New Model Supported
- [ ] No New Model Supported
......@@ -116,9 +116,9 @@ X2Paddle提供了工具解决如下问题,详见[tools/README.md](tools/README
1. 新增支持转换的模型:[SwinTransformer](https://github.com/microsoft/Swin-Transformer/)[BASNet](https://github.com/xuebinqin/BASNet)[DBFace](https://github.com/dlunion/DBFace)[EasyOCR](https://github.com/JaidedAI/EasyOCR)[CifarNet](https://github.com/tensorflow/models/blob/master/research/slim/nets/cifarnet.py)等。
2. 支持Windows上使用本工具。
3. 新增TensorFlow op映射(4个):SplitV、ReverseV2、BatchToSpaceND、SpaceToBatchND。
4. 新增PyTorch op映射(11个):aten::index、aten::roll、aten::adaptive_avg_pool1d、aten::reflection_pad2d、aten::reflection_pad1d、aten::instance_norm、aten::gru、aten::norm、aten::clamp_min、aten:prelu、aten:split_with_sizes。
4. 新增PyTorch op映射(11个):aten::index、aten::roll、aten::adaptive_avg_pool1d、aten::reflection_pad2d、aten::reflection_pad1d、aten::instance_norm、aten::gru、aten::norm、aten::clamp_min、aten::prelu、aten:split_with_sizes。
5. 新增ONNX op映射(1个):DepthToSpace。
6. 新增Caffe op映射(1个):op:MemoryData。
6. 新增Caffe op映射(1个):MemoryData。
## 贡献代码
......
......@@ -2962,6 +2962,51 @@ def aten_log(mapper, graph, node):
return current_inputs, current_outputs
def aten_log_softmax(mapper, graph, node):
""" 构造log_softmax的PaddleLayer。
TorchScript示例:
%4 = aten::log_softmax(%input, %2, %3)
参数含义:
%4 (Tensor): 输出的Tensor。
%input (Tensor): 输入的Tensor。
%2 (int): 指定对输入进行运算的轴。
%3 (int): 输入Tensor的数据类型。
"""
scope_name = mapper.normalize_scope_name(node)
output_name = mapper._get_outputs_name(node)[0]
layer_outputs = [output_name]
layer_inputs = {}
layer_attrs = {}
inputs_name, inputs_node = mapper._get_inputs_name(node)
# 获取当前节点输出的list
current_outputs = [output_name]
current_inputs = []
# 处理输入0,即%input
mapper._check_input(graph, inputs_node[0], inputs_name[0], current_outputs,
scope_name)
layer_inputs["x"] = inputs_name[0]
# 处理输入1,即%2,代表dtype
if inputs_name[1] in mapper.attrs:
layer_attrs["axis"] = mapper.attrs[inputs_name[1]]
else:
mapper._check_input(graph, inputs_node[1], inputs_name[1],
current_outputs, scope_name)
layer_inputs["axis"] = inputs_name[1]
# 处理输入2,即%3,代表dtype
if mapper.attrs[inputs_name[2]] is not None:
layer_attrs["dtype"] = dtype_dict[mapper.attrs[inputs_name[2]]]
# 获取当前节点输入的list
current_inputs = list(layer_inputs.values())
graph.add_layer(
"paddle.nn.functional.log_softmax",
inputs=layer_inputs,
outputs=layer_outputs,
scope_name=scope_name,
**layer_attrs)
return current_inputs, current_outputs
def aten_lstm(mapper, graph, node):
""" 构造长短期记忆网络(LSTM)的PaddleLayer。
TorchScript示例:
......
......@@ -649,18 +649,30 @@ class TFOpMapper(OpMapper):
paddings = self.graph.get_input_node(node, 1)
assert paddings.layer_type == "Const", "Padding should be Const"
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(
kernel="paddle.nn.functional.pad",
inputs={"x": input.name},
outputs=[node.name],
pad=paddings,
value=constant_values)
if len(paddings) == 8 and sum(paddings[:2]) == 0 \
and sum(paddings[-2:]) == 0:
paddings = paddings[2: -2]
self.paddle_graph.add_layer(
kernel="paddle.nn.functional.pad",
inputs={"x": input.name},
outputs=[node.name],
pad=paddings,
value=constant_values,
data_format=string('NHWC'))
else:
self.paddle_graph.add_layer(
kernel="paddle.nn.functional.pad",
inputs={"x": input.name},
outputs=[node.name],
pad=paddings,
value=constant_values)
def MirrorPad(self, node):
self.Pad(node)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册