-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Topkv2op optimize #30403
Merged
Merged
Topkv2op optimize #30403
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update Paddle to newest version
Merge newest Paddle code
merge newest Paddle code
Thanks for your contribution! |
wzzju
approved these changes
Feb 26, 2021
… topkv2op-optimize
Xreki
approved these changes
Mar 1, 2021
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.
LGTM for op benchmark CI.
op benchmark CI的错误为:
2021-02-26 20:08:43 [/workspace/Paddle/tools/test_op_benchmark.sh:126] [INFO] Load op: "top_k_v2".
2021-02-26 20:08:43 [/workspace/Paddle/tools/test_op_benchmark.sh:261] [ERROR] Missing test script of "top_k_v2"(paddle/fluid/operators/top_k_v2_op.cu) in benchmark.
2021-02-26 20:08:43 [/workspace/Paddle/tools/test_op_benchmark.sh:265] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.
是top_k_v2到topk测试脚本的映射规则匹配失败,后续@Avin0323 来跟进和解决一下这个问题吧。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Performance optimization
PR changes
OPs
Describe
问题起因:
maskrcnn模型在topk处耗时特别高,cub库的
DeviceSegmentedRadixSortKernel
这个kernel耗时占比超过35.8%。问题分析:
在
top_k_v2_op.cu#L112
处有个判断:当axis
不等于最后一个维度时需要对矩阵进行转置操作,这是为了保证kernel在读取数据时保持global memory coalesce
。但这存在一个问题,当input_shape = (20, 242991), axis = 0
时,转置后的矩阵大小就变成了trans_dim = (242991, 24)
,而在top_k_v2_op.cu#L153
处又有一个判断,当input_width <= 1024
时会走cub的SortTopk
函数,很不巧的是,SortTopk
对于处理这种行数非常大的矩阵很不在行,因此导致了速度非常慢。优化方案:
修改
top_k_v2_op.cu#L153
处的条件来严格限制SortTopk
的进入条件:将原有的
input_width <= 1024
条件增加限制为(input_width <= 1024 && input_height <= 2048)
优化成果:
测试基于
mask_rcnn_r50_fpn_1x_coco
模型 + coco17数据集 + 取前18条ips平均值:SortTopk
逻辑