Skip to content

Commit 46a13e3

Browse files
reyoungJiayiFeng
authored andcommitted
Polish Accuracy Op (#5191)
* Accuracy does not support float/double, only support integers * Polish error message when an operator does not support some device.
1 parent 008f40c commit 46a13e3

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

paddle/framework/operator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ void OperatorWithKernel::Run(const Scope& scope,
390390
auto& all_op_kernels = AllOpKernels();
391391
auto kernels_iter = all_op_kernels.find(type_);
392392
if (kernels_iter == all_op_kernels.end()) {
393-
PADDLE_THROW("op[%s] has no kernel", type_);
393+
PADDLE_THROW(
394+
"There are no kernels which are registered in the %s operator.", type_);
394395
}
395396

396397
// check if op[type] have kernel for kernel_key
@@ -399,7 +400,7 @@ void OperatorWithKernel::Run(const Scope& scope,
399400
auto kernel_iter = kernels.find(kernel_key);
400401

401402
if (kernel_iter == kernels.end()) {
402-
PADDLE_THROW("op[%s] has no kernel with kernel_key[%s]", type_, kernel_key);
403+
PADDLE_THROW("The operator %s does not support %s", type_, kernel_key);
403404
}
404405

405406
kernel_iter->second->Compute(ctx);

paddle/operators/accuracy_op.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,5 @@ information, or not. But the output only shares the LoD with input `Inference`.
7070
namespace ops = paddle::operators;
7171
REGISTER_OP_WITHOUT_GRADIENT(accuracy, ops::AccuracyOp, ops::AccuracyOpMaker);
7272
REGISTER_OP_CPU_KERNEL(
73-
accuracy, ops::AccuracyKernel<paddle::platform::CPUPlace, float>,
74-
ops::AccuracyKernel<paddle::platform::CPUPlace, int>,
75-
ops::AccuracyKernel<paddle::platform::CPUPlace, double>,
73+
accuracy, ops::AccuracyKernel<paddle::platform::CPUPlace, int>,
7674
ops::AccuracyKernel<paddle::platform::CPUPlace, int64_t>);

paddle/operators/accuracy_op.cu

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,5 @@ class AccuracyOpCUDAKernel : public framework::OpKernel<T> {
8181
} // namespace operators
8282
} // namespace paddle
8383

84-
REGISTER_OP_GPU_KERNEL(accuracy, paddle::operators::AccuracyOpCUDAKernel<float>,
85-
paddle::operators::AccuracyOpCUDAKernel<double>,
86-
paddle::operators::AccuracyOpCUDAKernel<int>,
84+
REGISTER_OP_GPU_KERNEL(accuracy, paddle::operators::AccuracyOpCUDAKernel<int>,
8785
paddle::operators::AccuracyOpCUDAKernel<int64_t>);

0 commit comments

Comments
 (0)