-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix/copyfrom context #6954
Fix/copyfrom context #6954
Conversation
paddle/framework/tensor_util.h
Outdated
/** | ||
* @brief CopyFrom support CPU <-> CPU | ||
*/ | ||
|
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.
Delete the redundant black line.
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.
Done.
paddle/framework/tensor_util.h
Outdated
|
||
auto size = src.numel() * SizeOfType(src.type()); | ||
|
||
if (platform::is_cpu_place(src_place) && platform::is_cpu_place(dst_place)) { |
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.
How about use PADDLE_ENFORCE
to checkt the place?
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.
Done.
dst->Resize({static_cast<int64_t>(src.size())}); | ||
auto dst_ptr = static_cast<void*>(dst->mutable_data<T>(dst_place)); | ||
auto size = src.size() * sizeof(T); | ||
|
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.
Add place checker.
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.
CopyToVector create a cpu_place inside. No need to check it.
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++
fix #6948