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

[phi] move is_empty to phi #39919

Merged
merged 13 commits into from
Mar 7, 2022
Merged

[phi] move is_empty to phi #39919

merged 13 commits into from
Mar 7, 2022

Conversation

wjj19950828
Copy link
Contributor

PR types

Function optimization

PR changes

OPs

Describe

move is_empty to phi

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@@ -1,11 +1,8 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.

Copy link
Contributor

Choose a reason for hiding this comment

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

licence里的这些空行是固定格式,不用删,可参考其他文件

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// Note: is_empty is always executed on CPU and the output data should
// always be allocated for CPUPlace. We reigister CUDA kernel for this op to
// avoid the unnecessary data transform.
out->mutable_data<bool>(phi::CPUPlace())[0] = phi::product(x.dims()) == 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以使用dev_ctx.template HostAlloc<T>()接口替换mutable_data

Copy link
Contributor

Choose a reason for hiding this comment

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

看注释,这里应该是改为: phi::CPUPlace().HostAlloc() 吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

具体应该怎么改呢,改成下面这样吗

out->mutable_data(phi::CPUPlace().HostAlloc())[0] = phi::product(x.dims()) == 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

YuanRisheng
YuanRisheng previously approved these changes Mar 1, 2022
double,
int,
int64_t) {}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

这里有个warning,后边可以添加换行

zyfncg
zyfncg previously approved these changes Mar 1, 2022
Copy link
Contributor

@zyfncg zyfncg left a comment

Choose a reason for hiding this comment

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

LGTM

@wjj19950828 wjj19950828 dismissed stale reviews from zyfncg and YuanRisheng via 312ef41 March 6, 2022 09:29
@chenwhql chenwhql merged commit 7296433 into PaddlePaddle:develop Mar 7, 2022
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.

5 participants