Add mkldnn related unit-tests
To improve the code (line+function) coverage, please add mkldnn related unit-tests: http://ce.paddlepaddle.org:8080/viewLog.html?buildId=21110&buildTypeId=PaddlePaddleFramework_TestCoverage_TestCoverage&tab=report_project15_C___Coverage
- framework/ir/mkldnn

- operators/elementwise/mkldnn

We reproduced your results with coverage testing tool.
- cmake .. -DWITH_GPU=OFF -DWITH_PROFILER=ON -DWITH_STYLE_CHECK=OFF -DWITH_MKLDNN=ON -DWITH_TESTING=ON -DWITH_COVERAGE=ON
- lcov --capture --directory . --output-file coverage.info
- genhtml coverage.info --output-directory out
We will add missing tests.

@luotao1 Whether it is possible to run more than 1 iteration in a single unit test for forward and backward phases ? We need to cover the part of the code responsible for reuse MKL-DNN primitives in backward (e.g. activation_mkldnn_op.cc::eltwise_grad function line 276-287). We have to run more than one iteration to enter this section of code.
Whether it is possible to run more than 1 iteration in a single unit test for forward and backward phases?
I think it's OK to run more than 1 iterations in elementwise_xxx_mkldnn unit-tests. However, if you add many more iterations, does the elasped time of unit-tests become larger?
Not many, 2 iterations will be enough. Is there any unit test in PaddlePaddle which more than 1 iteration is started ?
@kbinias There is no 2 iterations unitest using OpTest. Maybe you should implement yourselves, and refer to test_batch_norm_op.py.
@luotao1 Thanks for you answer. What do you think about creating new test based on test_imperative_resnet.py with use_mkldnn equals to True ? It will cover batch_norm, conv, pool and activations.
What do you think about creating a new test based on
test_imperative_resnet.pywith use_mkldnn equals to True?
@kbinias I think it's OK.
@luotao1 What do you think about closing this PR ? The problem with function coverage is IMO related to lcov tool.

The Functions coverage is less than 80% in operators/mkldnn. You can add the unit-tests for activation_mkldnn_op.cc, conv_mkldnn_op.cc and transpose_mkldnn_op.cc when you are convenient. @kbinias
@luotao1 Coverage feature in GCC doesn't support virtual destructors correctly. There is no way to cover tests in 100% if test uses Inheritance. You can find out more details below with good explanation: https://stackoverflow.com/questions/25662174/is-there-a-way-to-call-the-deleting-destructor-of-a-pure-virtual-class.
One of potential workaround might be post-processing and remove all destructors from tests, we could consider that it’s a noise. The destructors should not be a part of final calculation.
Got it. Both @tensor-tang and I think destructors are normal.
However, the current coverage by May 12th is http://ce.paddlepaddle.org:8080/viewLog.html?buildId=31464&buildTypeId=PaddlePaddleFramework_TestCoverage_TestCoverage&tab=report_project15_C___Coverage
Why the coverage of batch_norm_mkldnn_op and lrn_mkldnn_op cut down that before?
我们的结果完全不一样,lrn应该是100%的,您可以用下面的编译指令重新生成一下吗 @luotao1 谢谢 ⦁ cmake .. -DWITH_GPU=OFF -DWITH_PROFILER=ON -DWITH_STYLE_CHECK=OFF -DWITH_MKLDNN=ON -DWITH_TESTING=ON -DWITH_COVERAGE=ON ⦁ make -j 12 ⦁ ctest -R mkldnn ⦁ lcov --capture --directory . --output-file coverage.info ⦁ genhtml --demangle-cpp coverage.info --output-directory out
我是CI上的结果。
Could you please tell how to reproduce it with commands ? It seems we have different procedure... 请问怎么reproduce呢,可以有什么指令吗? 非常感谢!
We are checking build log, hope we could find something. Thanks. If you have any further information, please inform us. Thanks
Macro REGISTER_OP_KERNEL is not able to set correct handle for all grad functions such TouchOpKernelRegistrar_transpose_grad_MKLDNN_DEFAULT_TYPE(). Due to missed registration, we can’t cover all functions in tests. The issue is globally, moreover practical working example how to register kernel and enforce touchopkernelregistrar_grad correctly doesn’t exist. The open question is - do we really should care about it?
@luotao1 What do you think about above problem ?
do you mean paddle can't register some kernel or paddle can't select some registered kernels?
can you search REGISTER_OP_KERNEL_WITH_CUSTOM_TYPE and see if it works for you?
@shanyi15 Could you help to update How to add new op to introduce so many different REGISTER MACRO?
@luotao1 About batch_norm_mkldnn and lrn_mkldnn line coverages, I have some idea and made some fix locally. I could build and make with docker[latest-dev], but I don't know what is the building and testing script. Something like ./paddle_build_cov.sh. I also don't know what main cov means in the build log on TeamCity. Could you share build script with me? This will speed up the work. Thank you!