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

ENH: Refine Tensor and Add CopyFrom #3056

Merged
merged 3 commits into from
Jul 27, 2017
Merged

Conversation

gangliao
Copy link
Contributor

@gangliao gangliao commented Jul 25, 2017

Add both CPU and GPU CopyFrom Unit Test

@gangliao gangliao requested a review from JiayiFeng July 25, 2017 11:41
class PODDeleter {
static_assert(std::is_pod<T>::value, "T must be POD");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why shall we use static_assert instead of template parameter? Any benefit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. SFINAE is a versatile and powerful but potentially complicated.
  2. static_assert makes more verbatim and hence clearer code.
  3. static_assert has the benefit of a clearer compiler error message

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that in this case, where we don't have other templates for PODDeleter, static_assert is the right choice.

@gangliao gangliao changed the title ENH: Refine Tensor and And CopyFrom ENH: Refine Tensor and Add CopyFrom Jul 25, 2017
@gangliao gangliao requested a review from wangkuiyi July 26, 2017 08:56
Copy link
Collaborator

@wangkuiyi wangkuiyi left a comment

Choose a reason for hiding this comment

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

LGTM

class PODDeleter {
static_assert(std::is_pod<T>::value, "T must be POD");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that in this case, where we don't have other templates for PODDeleter, static_assert is the right choice.

@wangkuiyi wangkuiyi merged commit 1cfc8b6 into PaddlePaddle:develop Jul 27, 2017
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.

3 participants