Skip to content

Commit cf8f65d

Browse files
committed
Do not use size_t for nGraph layers
1 parent 3c3e131 commit cf8f65d

File tree

4 files changed

+46
-27
lines changed

4 files changed

+46
-27
lines changed

modules/dnn/src/layers/fully_connected_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ class FullyConnectedLayerImpl CV_FINAL : public InnerProductLayer
565565
}
566566
else
567567
{
568-
std::vector<size_t> data = {(size_t)ieInpNode->get_shape()[0], (size_t)blobs[0].size[1]};
568+
std::vector<int64_t> data = {(int64_t)ieInpNode->get_shape()[0], (int64_t)blobs[0].size[1]};
569569
auto new_shape = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, data.data());
570570
auto inp = std::make_shared<ngraph::op::v1::Reshape>(ieInpNode, new_shape, true);
571571

modules/dnn/src/layers/permute_layer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,9 @@ class PermuteLayerImpl CV_FINAL : public PermuteLayer
385385
const std::vector<Ptr<BackendNode> >& nodes) CV_OVERRIDE
386386
{
387387
auto& ieInpNode = nodes[0].dynamicCast<InfEngineNgraphNode>()->node;
388+
std::vector<int64_t> order(_order.begin(), _order.end());
388389
auto tr_axes = std::make_shared<ngraph::op::Constant>(ngraph::element::i64,
389-
ngraph::Shape({_order.size()}), _order.data());
390+
ngraph::Shape({order.size()}), order.data());
390391
auto transpose = std::make_shared<ngraph::op::Transpose>(ieInpNode, tr_axes);
391392
return Ptr<BackendNode>(new InfEngineNgraphNode(transpose));
392393
}

modules/dnn/test/test_layers.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,9 @@ TEST_P(Layer_Test_Convolution_DLDT, Accuracy)
11081108
const Backend backendId = get<0>(GetParam());
11091109
const Target targetId = get<1>(GetParam());
11101110

1111+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
1112+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1113+
11111114
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
11121115
throw SkipTestException("No support for async forward");
11131116

@@ -1118,9 +1121,8 @@ TEST_P(Layer_Test_Convolution_DLDT, Accuracy)
11181121
else
11191122
FAIL() << "Unknown backendId";
11201123

1121-
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
11221124
Net netDefault = readNet(_tf("layer_convolution.caffemodel"), _tf("layer_convolution.prototxt"));
1123-
Net net = readNet(_tf("layer_convolution" + suffix + ".xml"), _tf("layer_convolution" + suffix + ".bin"));
1125+
Net net = readNet(_tf("layer_convolution.xml"), _tf("layer_convolution.bin"));
11241126

11251127
Mat inp = blobFromNPY(_tf("blob.npy"));
11261128

@@ -1140,14 +1142,20 @@ TEST_P(Layer_Test_Convolution_DLDT, Accuracy)
11401142

11411143
std::vector<int> outLayers = net.getUnconnectedOutLayers();
11421144
ASSERT_EQ(net.getLayer(outLayers[0])->name, "output");
1143-
ASSERT_EQ(net.getLayer(outLayers[0])->type, "Convolution");
1145+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1146+
ASSERT_EQ(net.getLayer(outLayers[0])->type, "Convolution");
1147+
else
1148+
ASSERT_EQ(net.getLayer(outLayers[0])->type, "Add");
11441149
}
11451150

11461151
TEST_P(Layer_Test_Convolution_DLDT, setInput_uint8)
11471152
{
11481153
const Backend backendId = get<0>(GetParam());
11491154
const Target targetId = get<1>(GetParam());
11501155

1156+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
1157+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1158+
11511159
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
11521160
throw SkipTestException("No support for async forward");
11531161

@@ -1164,12 +1172,10 @@ TEST_P(Layer_Test_Convolution_DLDT, setInput_uint8)
11641172
randu(inputs[0], 0, 255);
11651173
inputs[0].convertTo(inputs[1], CV_32F);
11661174

1167-
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
1168-
11691175
Mat outs[2];
11701176
for (int i = 0; i < 2; ++i)
11711177
{
1172-
Net net = readNet(_tf("layer_convolution" + suffix + ".xml"), _tf("layer_convolution" + suffix + ".bin"));
1178+
Net net = readNet(_tf("layer_convolution.xml"), _tf("layer_convolution.bin"));
11731179
net.setPreferableBackend(backendId);
11741180
net.setPreferableTarget(targetId);
11751181
net.setInput(inputs[i]);
@@ -1185,6 +1191,9 @@ TEST_P(Layer_Test_Convolution_DLDT, multithreading)
11851191
const Backend backendId = get<0>(GetParam());
11861192
const Target targetId = get<1>(GetParam());
11871193

1194+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
1195+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1196+
11881197
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
11891198
throw SkipTestException("No support for async forward");
11901199

@@ -1195,9 +1204,8 @@ TEST_P(Layer_Test_Convolution_DLDT, multithreading)
11951204
else
11961205
FAIL() << "Unknown backendId";
11971206

1198-
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
1199-
std::string xmlPath = _tf("layer_convolution" + suffix + ".xml");
1200-
std::string binPath = _tf("layer_convolution" + suffix + ".bin");
1207+
std::string xmlPath = _tf("layer_convolution.xml");
1208+
std::string binPath = _tf("layer_convolution.bin");
12011209
Net firstNet = readNet(xmlPath, binPath);
12021210
Net secondNet = readNet(xmlPath, binPath);
12031211
Mat inp = blobFromNPY(_tf("blob.npy"));
@@ -1256,8 +1264,7 @@ TEST_P(Test_DLDT_two_inputs_3dim, as_IR)
12561264
int secondInpType = get<1>(GetParam());
12571265
Target targetId = get<2>(GetParam());
12581266

1259-
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
1260-
Net net = readNet(_tf("net_two_inputs" + suffix + ".xml"), _tf("net_two_inputs.bin"));
1267+
Net net = readNet(_tf("net_two_inputs.xml"), _tf("net_two_inputs.bin"));
12611268
std::vector<int> inpSize = get<3>(GetParam());
12621269
Mat firstInp(3, inpSize.data(), firstInpType);
12631270
Mat secondInp(3, inpSize.data(), secondInpType);

modules/dnn/test/test_misc.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,14 @@ TEST_P(Async, model_optimizer_pipeline_set_and_forward_single)
440440
const Backend backendId = get<0>(get<1>(GetParam()));
441441
const Target targetId = get<1>(get<1>(GetParam()));
442442

443+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
444+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
445+
443446
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
444447
throw SkipTestException("No support for async forward");
445448

446-
const std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
447-
const std::string& model = findDataFile("dnn/layers/layer_convolution" + suffix + ".bin");
448-
const std::string& proto = findDataFile("dnn/layers/layer_convolution" + suffix + ".xml");
449+
const std::string& model = findDataFile("dnn/layers/layer_convolution.bin");
450+
const std::string& proto = findDataFile("dnn/layers/layer_convolution.xml");
449451

450452
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
451453
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);
@@ -499,12 +501,14 @@ TEST_P(Async, model_optimizer_pipeline_set_and_forward_all)
499501
const Backend backendId = get<0>(get<1>(GetParam()));
500502
const Target targetId = get<1>(get<1>(GetParam()));
501503

504+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
505+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
506+
502507
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
503508
throw SkipTestException("No support for async forward");
504509

505-
const std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
506-
const std::string& model = findDataFile("dnn/layers/layer_convolution" + suffix + ".bin");
507-
const std::string& proto = findDataFile("dnn/layers/layer_convolution" + suffix + ".xml");
510+
const std::string& model = findDataFile("dnn/layers/layer_convolution.bin");
511+
const std::string& proto = findDataFile("dnn/layers/layer_convolution.xml");
508512

509513
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
510514
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);
@@ -673,9 +677,11 @@ TEST_P(Test_Model_Optimizer, forward_two_nets)
673677
const Backend backendId = get<0>(GetParam());
674678
const Target targetId = get<1>(GetParam());
675679

676-
const std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
677-
const std::string& model = findDataFile("dnn/layers/layer_convolution" + suffix + ".bin");
678-
const std::string& proto = findDataFile("dnn/layers/layer_convolution" + suffix + ".xml");
680+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
681+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
682+
683+
const std::string& model = findDataFile("dnn/layers/layer_convolution.bin");
684+
const std::string& proto = findDataFile("dnn/layers/layer_convolution.xml");
679685

680686
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
681687
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);
@@ -712,12 +718,14 @@ TEST_P(Test_Model_Optimizer, readFromBuffer)
712718
const Backend backendId = get<0>(GetParam());
713719
const Target targetId = get<1>(GetParam());
714720

721+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
722+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
723+
715724
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
716725
throw SkipTestException("No support for async forward");
717726

718-
const std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : "";
719-
const std::string& weightsFile = findDataFile("dnn/layers/layer_convolution" + suffix + ".bin");
720-
const std::string& modelFile = findDataFile("dnn/layers/layer_convolution" + suffix + ".xml");
727+
const std::string& weightsFile = findDataFile("dnn/layers/layer_convolution.bin");
728+
const std::string& modelFile = findDataFile("dnn/layers/layer_convolution.xml");
721729

722730
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
723731
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);
@@ -765,8 +773,11 @@ TEST_P(Test_Model_Optimizer, flexible_inputs)
765773
const Backend backendId = get<0>(GetParam());
766774
const Target targetId = get<1>(GetParam());
767775

768-
const std::string& model = findDataFile("dnn/layers/layer_convolution_fp16.bin");
769-
const std::string& proto = findDataFile("dnn/layers/layer_convolution_fp16.xml");
776+
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && targetId == DNN_TARGET_MYRIAD)
777+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
778+
779+
const std::string& model = findDataFile("dnn/layers/layer_convolution.bin");
780+
const std::string& proto = findDataFile("dnn/layers/layer_convolution.xml");
770781

771782
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
772783
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);

0 commit comments

Comments
 (0)