Skip to content

Commit 9b131b5

Browse files
committed
dnn(test): avoid calling of cv::setNumThreads() in tests directly
It is not necessary by default. Also it breaks test system command-line parameters: --perf_threads / --test_threads
1 parent 5232ea1 commit 9b131b5

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

modules/dnn/perf/opencl/perf_convolution.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ OCL_PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
7777
std::vector<Mat*> inpBlobs(1, &inpBlob);
7878
std::vector<Mat> outBlobs, internalBlobs;
7979

80-
cv::setNumThreads(cv::getNumberOfCPUs());
81-
8280
Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
8381
std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
8482
layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
@@ -99,7 +97,7 @@ OCL_PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
9997
Mat inpBlob2D = inpBlob.reshape(1, outCn);
10098
Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
10199
Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
102-
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D).tbb_threads(cv::getNumThreads());
100+
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D);
103101

104102
// warmup
105103
layer->forward(inpBlobs, outBlobs, internalBlobs);

modules/dnn/perf/perf_convolution.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
6060
std::vector<Mat*> inpBlobs(1, &inpBlob);
6161
std::vector<Mat> outBlobs, internalBlobs;
6262

63-
cv::setNumThreads(cv::getNumberOfCPUs());
64-
6563
Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
6664
std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
6765
layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
@@ -81,7 +79,7 @@ PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
8179
Mat inpBlob2D = inpBlob.reshape(1, outCn);
8280
Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
8381
Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
84-
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D).tbb_threads(cv::getNumThreads());
82+
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D);
8583

8684
layer->forward(inpBlobs, outBlobs, internalBlobs); /// warmup
8785

modules/dnn/test/test_layers.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ void testLayerUsingCaffeModels(String basename, int targetId = DNN_TARGET_CPU,
107107
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
108108
String outfile = _tf(basename + ".npy");
109109

110-
cv::setNumThreads(cv::getNumberOfCPUs());
111-
112110
Net net = readNetFromCaffe(prototxt, (useCaffeModel) ? caffemodel : String());
113111
ASSERT_FALSE(net.empty());
114112

@@ -536,8 +534,6 @@ void testLayerUsingDarknetModels(String basename, bool useDarknetModel = false,
536534
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
537535
String outfile = _tf(basename + ".npy");
538536

539-
cv::setNumThreads(cv::getNumberOfCPUs());
540-
541537
Net net = readNetFromDarknet(cfg, (useDarknetModel) ? weights : String());
542538
ASSERT_FALSE(net.empty());
543539

0 commit comments

Comments
 (0)