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

[Hackathon NO.75] 为 Paddle-TRT 添加 expend_as_v2 算子 #51028

Merged
merged 7 commits into from
Apr 13, 2023

Conversation

gzy19990617
Copy link
Contributor

@gzy19990617 gzy19990617 commented Feb 28, 2023

PR types

Others

PR changes

Others

Describe

expend_v2目前已经实现,因为expend_as_v2与expend_as_v2的input、attrs有些不同,expend_as_v2算子会调用expand_kernal.cu。

因此在expend_v2基础上完成了expend_as_v2,同时在op_converter.h中利用shuffle增加了ITensor Reshape的api,方便以后对ITensor进行reshape操作。

python测试了两种情况,一种是属性中有"target_shape",一种是输入含有Y(此时会优化用Y的shape去expand),输入的维度和shape的维度均进行了测试,覆盖多种情况,全部通过。
Pasted Graphic 1

@paddle-bot
Copy link

paddle-bot bot commented Feb 28, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

}
} else if (op_type_ == "expand_as_v2") {
if (inputs.find("Y") != inputs.end()) {
shape_tensor = engine_->GetITensor(op_desc.Input("Shape")[0]);
Copy link
Contributor

@zhangjun zhangjun Mar 6, 2023

Choose a reason for hiding this comment

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

这里是不是Y? 另外这个ci未覆盖

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,已修改

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR-CI-Coverage这个CI还是没有过,这是什么原因呢

ops_config = [
{
"op_type": "expand_as_v2",
"op_inputs": dics_intput[0],
Copy link
Contributor

Choose a reason for hiding this comment

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

这里只设置了一个输入,应该是两个

Comment on lines 241 to 249
self.dynamic_shape.min_input_shape = {
"expand_v2_input": [1, 8, 1, 32]
}
self.dynamic_shape.max_input_shape = {
"expand_v2_input": [10, 8, 1, 32]
}
self.dynamic_shape.opt_input_shape = {
"expand_v2_input": [1, 8, 1, 32]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

expand_shape也需要设置动态shape值

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expand_as_v2这个算子原生GPU部分貌似不支持shape中有-1的值,当shape中有两个-1的时候,代码报错,应该是GPU原生推理部分和TRT的推理结果无法匹配导致的。
image

zhangjun
zhangjun previously approved these changes Apr 11, 2023
Copy link
Contributor

@zhangjun zhangjun left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1
Copy link
Contributor

luotao1 commented Apr 12, 2023

@gzy19990617 解决下冲突

@luotao1 luotao1 merged commit 94cc1d6 into PaddlePaddle:develop Apr 13, 2023
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.

4 participants