Skip to content

add some check to operator.run#4544

Merged
jacquesqiao merged 4 commits intoPaddlePaddle:developfrom
jacquesqiao:fix-con-op-test
Oct 1, 2017
Merged

add some check to operator.run#4544
jacquesqiao merged 4 commits intoPaddlePaddle:developfrom
jacquesqiao:fix-con-op-test

Conversation

@jacquesqiao
Copy link
Member

@jacquesqiao jacquesqiao commented Sep 30, 2017

fix: #4545

auto& opKernel = AllOpKernels().at(type_).at(
OpKernelKey(IndicateDataType(ctx), dev_ctx));
opKernel->Compute(ctx);
PADDLE_ENFORCE_GT(AllOpKernels().count(type_), 0, "op[%s] has no kernel",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not use count to check contains or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

use find instead, thanks for pointing out

DataType_descriptor();
std::string data_type_str =
descriptor->FindValueByNumber(data_type)->name();
PADDLE_THROW("op[%s] has no kernel with data_type[%s]", type_,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not use reflection here. Since #4542

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@jacquesqiao jacquesqiao changed the title fix cond_op_test and add some check to operator.run Sep 30, 2017
Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

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

Excellent

@jacquesqiao jacquesqiao merged commit 87efa60 into PaddlePaddle:develop Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants