code coverage & REGISTER_OP_KERNEL(grad)
Created by: pawelpiotrowicz
@luotao1 @kbinias According to https://github.com/PaddlePaddle/Paddle/issues/15615#issuecomment-474815683 and code coverage tests, we have an issue with REGISTER_OP_KERNEL macro. Unfortunately is one of the most popular macros in unit tests so the issue is global. I will try to explain step by step what I did and what kind of conclusion I have inferred.
-
I focused on softmax_mkldnn_op.cc test.
-
I unwrapped macro REGISTER_OP_KERNEL by means of g++ pre-processor to full version.
REGISTER_OP_KERNEL(softmax_grad, MKLDNN, ::paddle::platform::CPUPlace, ops::SoftmaxMKLDNNGradKernel<float>);
- So I got
struct __test_global_namespace___reg_op_kernel_softmax_grad_MKLDNN_DEFAULT_TYPE____ {};
static_assert(std::is_same<::__test_global_namespace___reg_op_kernel_softmax_grad_MKLDNN_DEFAULT_TYPE____, __test_global_namespace___reg_op_kernel_softmax_grad_MKLDNN_DEFAULT_TYPE____>::value, "REGISTER_OP_KERNEL must be called in " "global namespace");
static ::paddle::framework::OpKernelRegistrar< ::paddle::platform::CPUPlace, ops::SoftmaxMKLDNNGradKernel<float> > __op_kernel_registrar_softmax_grad_MKLDNN_DEFAULT_TYPE__( "softmax_grad", "MKLDNN", ::paddle::framework::OpKernelType::kDefaultCustomizedTypeValue);
int TouchOpKernelRegistrar_softmax_grad_MKLDNN_DEFAULT_TYPE()
{
__op_kernel_registrar_softmax_grad_MKLDNN_DEFAULT_TYPE__ .Touch();
return 0;
}
-
I ran ResNet -Training and Unit tests.
-
Final conclusion : TouchOpKernelRegistrar_softmax_grad_MKLDNN_DEFAULT_TYPE() is never executed no matter if it’s a training or test, each test has the same issue, so code coverage can’t cover this line.