Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resize and gemm #847

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

qqj1130247885
Copy link
Collaborator

@qqj1130247885 qqj1130247885 commented Jul 27, 2022

Create A Good Pull Request

下面的文字请保留在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

主要修改

1 gemm节点input只有两个有效值,没有val_c。进行了修改。
2 Resize节点无法转换,在paddle的interpolate,当mode为nearest时,不支持3d的输入tensor。通过unsqueeze+interpolate+squeeze解决。

@qqj1130247885 qqj1130247885 marked this pull request as draft July 27, 2022 06:50
@qqj1130247885 qqj1130247885 marked this pull request as ready for review July 27, 2022 06:50
idx)
node.which_child[new_child_name] = idx
else:
node.which_child[nd.name] = idx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一部分如果跟此PR一样:#842

则需要去掉,无需提交重复代码

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关掉#842,修改保留在这个PR里了。

if len(val_x_shape) == 3:
val_scales = self.graph.get_input_node(
node, idx=2, copy=True)
val_scales_values = _const_weight_or_none(val_scales)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val_scales_values若没用到则去掉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

scale=alpha)
else:
self.paddle_graph.add_layer(
"paddle.scale", inputs={"x": val_mm}, outputs=[node.name])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果paddle.scale中alpha值为1,则去掉scale op

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1657,6 +1705,12 @@ def Gemm(self, node):
add_inputs = {"x": val_mm, "y": var_beta}
self.paddle_graph.add_layer(
"paddle.add", inputs=add_inputs, outputs=[node.name])
else:
self.paddle_graph.add_layer(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里如果scale的alpha为1,是否能去掉scale op呢?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我尝试在 alpha!=1 的情况下增加scale op, 跑他们那个export_sim.onnx,会转换失败

else:
layer_attrs[pd_attr_name] = False
else:
layer_attrs[pd_attr_name] = onnx_attrs[onnx_attr_name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是Reduce操作吗, 在ONNX里面keep_dims如果为0,且是所有axis都reduce的情况下, 出来的shape是[]的一个scalar tensor, 而paddle是为[1]的tensor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants