From 46a13e37d7fc670d76f3dd034efabaab5a4601a0 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Sat, 28 Oct 2017 15:57:19 -0700 Subject: [PATCH] Polish Accuracy Op (#5191) * Accuracy does not support float/double, only support integers * Polish error message when an operator does not support some device. --- paddle/framework/operator.cc | 5 +++-- paddle/operators/accuracy_op.cc | 4 +--- paddle/operators/accuracy_op.cu | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/paddle/framework/operator.cc b/paddle/framework/operator.cc index 9e1e955aaea..222a252dc40 100644 --- a/paddle/framework/operator.cc +++ b/paddle/framework/operator.cc @@ -390,7 +390,8 @@ void OperatorWithKernel::Run(const Scope& scope, auto& all_op_kernels = AllOpKernels(); auto kernels_iter = all_op_kernels.find(type_); if (kernels_iter == all_op_kernels.end()) { - PADDLE_THROW("op[%s] has no kernel", type_); + PADDLE_THROW( + "There are no kernels which are registered in the %s operator.", type_); } // check if op[type] have kernel for kernel_key @@ -399,7 +400,7 @@ void OperatorWithKernel::Run(const Scope& scope, auto kernel_iter = kernels.find(kernel_key); if (kernel_iter == kernels.end()) { - PADDLE_THROW("op[%s] has no kernel with kernel_key[%s]", type_, kernel_key); + PADDLE_THROW("The operator %s does not support %s", type_, kernel_key); } kernel_iter->second->Compute(ctx); diff --git a/paddle/operators/accuracy_op.cc b/paddle/operators/accuracy_op.cc index e0a00ecaf04..eb8bce8da70 100644 --- a/paddle/operators/accuracy_op.cc +++ b/paddle/operators/accuracy_op.cc @@ -70,7 +70,5 @@ information, or not. But the output only shares the LoD with input `Inference`. namespace ops = paddle::operators; REGISTER_OP_WITHOUT_GRADIENT(accuracy, ops::AccuracyOp, ops::AccuracyOpMaker); REGISTER_OP_CPU_KERNEL( - accuracy, ops::AccuracyKernel, - ops::AccuracyKernel, - ops::AccuracyKernel, + accuracy, ops::AccuracyKernel, ops::AccuracyKernel); diff --git a/paddle/operators/accuracy_op.cu b/paddle/operators/accuracy_op.cu index 54e6ab99dc8..be58dfbd030 100644 --- a/paddle/operators/accuracy_op.cu +++ b/paddle/operators/accuracy_op.cu @@ -81,7 +81,5 @@ class AccuracyOpCUDAKernel : public framework::OpKernel { } // namespace operators } // namespace paddle -REGISTER_OP_GPU_KERNEL(accuracy, paddle::operators::AccuracyOpCUDAKernel, - paddle::operators::AccuracyOpCUDAKernel, - paddle::operators::AccuracyOpCUDAKernel, +REGISTER_OP_GPU_KERNEL(accuracy, paddle::operators::AccuracyOpCUDAKernel, paddle::operators::AccuracyOpCUDAKernel); -- GitLab