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.74] 为 Paddle-TRT 添加 grid_sampler 算子 #50934

Merged
merged 3 commits into from
Mar 2, 2023

Conversation

gzy19990617
Copy link
Contributor

@gzy19990617 gzy19990617 commented Feb 26, 2023

PR types

Others

PR changes

Others

Describe

grid_sampler之前采用通用plugin的方式convert到TRT,现在TRT8.5以上支持了的grid_sampler的layer,因此补充TRT的映射方式,如果用户安装TRT版本小于8.5,则依旧通过通用plugin的方式转换grid_sampler,python的单测已经通过。
下图为在本地TRT8.5下python单测的验证结果,"in in in"为grid_sampler.cc中的打印信息(该打印信息仅作为测试使用,提PR时已经删除),可见在TRT8.5中通过convert layer成功转换了grid_sampler算子(此时没有使用通用plugin)。
0b914f72b223e89c5169a51fc46306d5

另外TRT8.5中,gird_sampler layer只支持四维,在op_teller中加入了判断,如果input和grid不为四维,就return false,通过通用plugin的方式,通用plugin的grid_sampler中还有一个小bug,一起修改了。
image

@paddle-bot
Copy link

paddle-bot bot commented Feb 26, 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.

@gzy19990617 gzy19990617 changed the title hackathon_74 [Hackathon NO.74] 为 Paddle-TRT 添加 grid_sampler 算子 Feb 26, 2023
@zhangjun zhangjun self-requested a review February 27, 2023 11:03
@zhangjun zhangjun self-assigned this Feb 27, 2023
Comment on lines +34 to +35
class GridSamplerOpConverter : public OpConverter {
public:
Copy link
Contributor

Choose a reason for hiding this comment

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

这个类在trt 8.5以下会有编译问题,可以参考one_hot处理方式

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无法点击重新运行,应该怎么重新跑呢

Copy link
Contributor

Choose a reason for hiding this comment

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

PR-CI-Coverage,没有过,这个CI无法点击重新运行,应该怎么重新跑呢

这个ci Coverage问题,由于单测环境没有trt 8.5,可以在本地用trt8.5验证下python python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_grid_sampler.py。并附上正确结果截图

Copy link
Contributor Author

Choose a reason for hiding this comment

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

本地验证单测通过,"in in in"为grid_sampler.cc中的验证打印信息,可见成功进入grid_sampler.cc中进行TRT layer的转换,在PR describe中也补充了一下。
image

@PeterGss
Copy link

K2-F7 是在bd 科技园办公吗?加个vx: shaoshuai2100 一起组队? 我在K4

Comment on lines 38 to 43
desc = {
"mode": "bilinear",
"padding_mode": "border",
"align_corners": True,
}

Copy link
Contributor

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.

已补充,所有属性的四维和五维的单侧通过。
0b914f72b223e89c5169a51fc46306d5
另外TRT8.5中,gird_sampler layer只支持四维,在op_teller中加入了判断,如果input和grid不为四维,就return false,通过通用plugin的方式,通用plugin的grid_sampler中还有一个小bug,一起修改了。
image

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 luotao1 merged commit 8f156fd into PaddlePaddle:develop Mar 2, 2023
@gzy19990617 gzy19990617 deleted the hackthon_74 branch March 6, 2023 07:56
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