-
Notifications
You must be signed in to change notification settings - Fork 160
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
base: develop
Are you sure you want to change the base?
Fix resize and gemm #847
Conversation
idx) | ||
node.which_child[new_child_name] = idx | ||
else: | ||
node.which_child[nd.name] = idx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一部分如果跟此PR一样:#842
则需要去掉,无需提交重复代码
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val_scales_values
若没用到则去掉
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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呢?
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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
Create A Good Pull Request
Please check the follow step before merging this pull request
If this PR add new model support, please update
model_zoo.md
and add model to out test model zoos(@wjj19950828)主要修改
1 gemm节点input只有两个有效值,没有val_c。进行了修改。
2 Resize节点无法转换,在paddle的interpolate,当mode为nearest时,不支持3d的输入tensor。通过unsqueeze+interpolate+squeeze解决。