未验证 提交 3a769b9b 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #12100 from sfraczek/sfraczek/top-k-reserve

reserve vector space before loop in top-k
...@@ -60,6 +60,7 @@ class TopkKernel : public framework::OpKernel<T> { ...@@ -60,6 +60,7 @@ class TopkKernel : public framework::OpKernel<T> {
#endif #endif
for (size_t i = 0; i < row; i++) { for (size_t i = 0; i < row; i++) {
std::vector<std::pair<T, size_t>> vec; std::vector<std::pair<T, size_t>> vec;
vec.reserve(col);
for (size_t j = 0; j < col; j++) { for (size_t j = 0; j < col; j++) {
vec.push_back(std::pair<T, size_t>(eg_input(i, j), j)); vec.push_back(std::pair<T, size_t>(eg_input(i, j), j));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册