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

remove vector::erase #5791

Merged
merged 2 commits into from
Nov 23, 2017
Merged

Conversation

chengduoZH
Copy link
Contributor

@chengduoZH chengduoZH commented Nov 21, 2017

fix #5792

col_shape_vec.insert(col_shape_vec.end(), filter_shape_vec.begin(),
std::vector<int64_t> col_shape_vec(filter_shape_vec.size() +
output_shape_vec.size() - 3);
col_shape_vec.assign(1, input->dims()[1] / groups);
Copy link
Contributor

Choose a reason for hiding this comment

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

col_shape_vec[0] = input->dims()[1] / groups should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't get what we want.

  std::vector<int> vec_i({ 501, 502, 503 });

  std::vector<int> vec (8);
  vec[0]  = 12;
  vec.insert(vec.begin()+1, vec_i.begin(), vec_i.end());

If we write it in this way, vec is {12 501 502 503 0 0 0 0 0 0 0}.
But if we write it in the other way, vec is {12 501 502 503}.

  std::vector<int> vec (8);
  vec.assign(1, 12);
  vec.insert(vec.begin()+1, vec_i.begin(), vec_i.end());

Copy link
Contributor

@typhoonzero typhoonzero left a comment

Choose a reason for hiding this comment

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

LGTM++

@chengduoZH chengduoZH merged commit e800c0d into PaddlePaddle:develop Nov 23, 2017
@chengduoZH chengduoZH deleted the fix_conv_op branch January 29, 2018 07:13
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.

vector::erase is generally an inefficient operation.
2 participants