Why is opencv dnn slower if I use Halide?

I test the performance of some samples in the opencv source tree depending on whether the halogen is used or not.

Surprisingly, performance is worse if halogen is used for calculation:

  • squeezenet_halide: ~ 24 ms with halide and ~ 16 ms without halide.
  • resnet_ssd_face: ~ 84 ms with halide and ~ 36 ms without halide.

I compiled halide and opencv following the instructions in this tutorial . The opencv code was downloaded from the main branch of the opencv git repository .

I tested performance using the sample resnet_ssd_face.cpp and 'squeezenet_halide.cpp files. In both cases, I turn on one of these lines of code before calling forward to activate or deactivate the halide:

net.setPreferableBackend(DNN_BACKEND_HALIDE);  // use Halide

net.setPreferableBackend(DNN_BACKEND_DEFAULT);   // NOT use Halide

Time is measured using this code immediately after calling the "forward" function:

std::vector<double> layersTimings;
double freq = cv::getTickFrequency() / 1000;
double time = net.getPerfProfile(layersTimings) / freq;
std::cout << "Time: " << time << " ms" << std::endl;

Is there anything in the textbook? Should Halide be generated with various parameters?

My setup:

OS: Linux (Ubuntu 16.04)
CPU: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
GPU: nVidia GeForce GT 730 (Driver Version: 384.90)
Cuda: CUDA Version 9.0.176
+4
source share
1 answer

Given Dmitry Kurtaev’s comment and looking at the wiki in the OpenCV GitHub account, I found a page that shows a comparative test comparing different approaches (I skipped the links in the tutorial).

In addition, there is a merge request where a similar reference is included.

In both of them, time measurement shows that performance using Halide is worse than using the original C ++ approach.

, . , Zalman Stern, Halide - , dnn opencv , Halide.

, OpenCV, .

+2

Source: https://habr.com/ru/post/1689006/


All Articles