mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
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
This commit is contained in:
parent
5232ea1ee6
commit
9b131b5f7e
@ -77,8 +77,6 @@ OCL_PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
|
|||||||
std::vector<Mat*> inpBlobs(1, &inpBlob);
|
std::vector<Mat*> inpBlobs(1, &inpBlob);
|
||||||
std::vector<Mat> outBlobs, internalBlobs;
|
std::vector<Mat> outBlobs, internalBlobs;
|
||||||
|
|
||||||
cv::setNumThreads(cv::getNumberOfCPUs());
|
|
||||||
|
|
||||||
Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
|
Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
|
||||||
std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
|
std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
|
||||||
layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
|
layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
|
||||||
@ -99,7 +97,7 @@ OCL_PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
|
|||||||
Mat inpBlob2D = inpBlob.reshape(1, outCn);
|
Mat inpBlob2D = inpBlob.reshape(1, outCn);
|
||||||
Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
|
Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
|
||||||
Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
|
Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
|
||||||
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D).tbb_threads(cv::getNumThreads());
|
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D);
|
||||||
|
|
||||||
// warmup
|
// warmup
|
||||||
layer->forward(inpBlobs, outBlobs, internalBlobs);
|
layer->forward(inpBlobs, outBlobs, internalBlobs);
|
||||||
|
@ -60,8 +60,6 @@ PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
|
|||||||
std::vector<Mat*> inpBlobs(1, &inpBlob);
|
std::vector<Mat*> inpBlobs(1, &inpBlob);
|
||||||
std::vector<Mat> outBlobs, internalBlobs;
|
std::vector<Mat> outBlobs, internalBlobs;
|
||||||
|
|
||||||
cv::setNumThreads(cv::getNumberOfCPUs());
|
|
||||||
|
|
||||||
Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
|
Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
|
||||||
std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
|
std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
|
||||||
layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
|
layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
|
||||||
@ -81,7 +79,7 @@ PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
|
|||||||
Mat inpBlob2D = inpBlob.reshape(1, outCn);
|
Mat inpBlob2D = inpBlob.reshape(1, outCn);
|
||||||
Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
|
Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
|
||||||
Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
|
Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
|
||||||
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D).tbb_threads(cv::getNumThreads());
|
declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D);
|
||||||
|
|
||||||
layer->forward(inpBlobs, outBlobs, internalBlobs); /// warmup
|
layer->forward(inpBlobs, outBlobs, internalBlobs); /// warmup
|
||||||
|
|
||||||
|
@ -107,8 +107,6 @@ void testLayerUsingCaffeModels(String basename, int targetId = DNN_TARGET_CPU,
|
|||||||
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
|
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
|
||||||
String outfile = _tf(basename + ".npy");
|
String outfile = _tf(basename + ".npy");
|
||||||
|
|
||||||
cv::setNumThreads(cv::getNumberOfCPUs());
|
|
||||||
|
|
||||||
Net net = readNetFromCaffe(prototxt, (useCaffeModel) ? caffemodel : String());
|
Net net = readNetFromCaffe(prototxt, (useCaffeModel) ? caffemodel : String());
|
||||||
ASSERT_FALSE(net.empty());
|
ASSERT_FALSE(net.empty());
|
||||||
|
|
||||||
@ -536,8 +534,6 @@ void testLayerUsingDarknetModels(String basename, bool useDarknetModel = false,
|
|||||||
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
|
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
|
||||||
String outfile = _tf(basename + ".npy");
|
String outfile = _tf(basename + ".npy");
|
||||||
|
|
||||||
cv::setNumThreads(cv::getNumberOfCPUs());
|
|
||||||
|
|
||||||
Net net = readNetFromDarknet(cfg, (useDarknetModel) ? weights : String());
|
Net net = readNetFromDarknet(cfg, (useDarknetModel) ? weights : String());
|
||||||
ASSERT_FALSE(net.empty());
|
ASSERT_FALSE(net.empty());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user