Convolution layer performance issue
Hello
I have implemented Alexnet n/w using MKL-DNN library primitives.
1.During my profiling, I have noted that the convolution layer 1 of Alexnet using MKL-DNN primitives is taking almost double execution time, than the corresponding execution time using Intel Caffe Alexnet Convolution layer 1. Is this difference expected - if so, why?
2.Is there any way to enable Convolution layer in MKL-DNN to use SGEMM from MKL BLAS library
Thank you Kamrao
Hi Kamrao,
- Could you please run benchdnn to understand whether the problem is the code or in the running environment. Assuming you build MKL-DNN in RELEASE mode with binary MKL dependency and with Intel OpenMP please run:
$ export OMP_NUM_THREADS=${number_of_physical_cores}
$ export KMP_AFFINITY=granularity=fine,compact # if HT is off
$ export KMP_AFFINITY=granularity=fine,compact,1,0 # if HT is on
$ ./build/tests/benchdnn/benchdnn --conv --mode=PERF -v5 --match="alexnet:conv1"
You should get something like:
run: mb256ic3ih227oc96oh55kh11sh4n"alexnet:conv1"
mkldnn implementation: const char *mkldnn::impl::cpu::_jit_avx2_convolution_fwd_t<with_relu>::pd_t::name() const [with bool with_relu = false]
perf,"alexnet:conv1",mb256ic3ih227oc96oh55kh11sh4n"alexnet:conv1",53.9726,37.2512,1448.88,43.2356,1248.34
tests:1 passed:0 skipped:0 mistrusted:0 unimplemented:0 failed:0
The last but one number (43.2356) is ms spent in the convolution.
The last number (1248.34) is performance in gflops.
Does the time match what you see in your application?
- if yes -- something goes wrong with the environment you built or ran benchdnn/application
- if no -- need to understand what goes wrong with your application (maybe you measure the time for the first run only, or something else)
- MKL-DNN provides an API for primitive_descriptor_iterators that allows traversing different implementations. You can stop at gemm-based convolution and fetch it to use. Please see:
mkldnn_primitive_desc_iterator_create
mkldnn_primitive_desc_iterator_next
mkldnn_primitive_desc_iterator_fetch for implementation traversing
and
mkldnn_primitive_desc_query for querying the implementation name (using mkldnn_query_impl_info_str). You will for the implementation with gemm substring :)
Please reopen if you are able to reproduce the problem with benchdnn.