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

add is empty op #5639

Merged
merged 3 commits into from
Nov 16, 2017
Merged

Conversation

Superjomn
Copy link
Contributor

fixes: #5627

IsEmptyOpProtoMaker(framework::OpProto *proto,
framework::OpAttrChecker *op_checker)
: OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("X", "the tensor to check whether is empty");
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be good to adher to the naming convention for operators. https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/operators/name_convention.md

PADDLE_ENFORCE_NOT_NULL(out);
auto *out_tensor = out->GetMutable<framework::LoDTensor>();

out_tensor->Resize(framework::make_ddim(std::vector<int>({1})));
Copy link
Member

Choose a reason for hiding this comment

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

can use

out_tensor->Resize({1});

instead

IsEmptyOpProtoMaker(framework::OpProto *proto,
framework::OpAttrChecker *op_checker)
: OpProtoAndCheckerMaker(proto, op_checker) {
AddInput(kInput, "the tensor to check whether is empty");
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not being clear last time. I was referring to the Input and the Output comments. We can write this as
AddInput(kInput, "(Tensor) Tensor which is to be checked");
We can do similar for Output.

Sorry for not being clear last time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get

Copy link
Contributor

@abhinavarora abhinavarora left a comment

Choose a reason for hiding this comment

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

LGTM!

@Superjomn Superjomn merged commit 186581d into PaddlePaddle:develop Nov 16, 2017
@Superjomn Superjomn deleted the feature/is_empty_op branch November 16, 2017 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

need a is_tensor_empty operator to help beamsearch
4 participants