|
|
|
@ -923,8 +923,9 @@ TEST_P(Layer_Test_Convolution_DLDT, Accuracy) |
|
|
|
|
{ |
|
|
|
|
Target targetId = GetParam(); |
|
|
|
|
|
|
|
|
|
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : ""; |
|
|
|
|
Net netDefault = readNet(_tf("layer_convolution.caffemodel"), _tf("layer_convolution.prototxt")); |
|
|
|
|
Net net = readNet(_tf("layer_convolution.xml"), _tf("layer_convolution.bin")); |
|
|
|
|
Net net = readNet(_tf("layer_convolution" + suffix + ".xml"), _tf("layer_convolution" + suffix + ".bin")); |
|
|
|
|
|
|
|
|
|
Mat inp = blobFromNPY(_tf("blob.npy")); |
|
|
|
|
|
|
|
|
@ -935,22 +936,15 @@ TEST_P(Layer_Test_Convolution_DLDT, Accuracy) |
|
|
|
|
net.setInput(inp); |
|
|
|
|
net.setPreferableTarget(targetId); |
|
|
|
|
|
|
|
|
|
if (targetId != DNN_TARGET_MYRIAD) |
|
|
|
|
{ |
|
|
|
|
Mat out = net.forward(); |
|
|
|
|
Mat out = net.forward(); |
|
|
|
|
|
|
|
|
|
normAssert(outDefault, out); |
|
|
|
|
double l1 = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 1.4e-3 : 1e-5; |
|
|
|
|
double lInf = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 1.8e-2 : 1e-4; |
|
|
|
|
normAssert(outDefault, out, "", l1, lInf); |
|
|
|
|
|
|
|
|
|
std::vector<int> outLayers = net.getUnconnectedOutLayers(); |
|
|
|
|
ASSERT_EQ(net.getLayer(outLayers[0])->name, "output_merge"); |
|
|
|
|
ASSERT_EQ(net.getLayer(outLayers[0])->type, "Concat"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// An assertion is expected because the model is in FP32 format but
|
|
|
|
|
// Myriad plugin supports only FP16 models.
|
|
|
|
|
ASSERT_ANY_THROW(net.forward()); |
|
|
|
|
} |
|
|
|
|
std::vector<int> outLayers = net.getUnconnectedOutLayers(); |
|
|
|
|
ASSERT_EQ(net.getLayer(outLayers[0])->name, "output"); |
|
|
|
|
ASSERT_EQ(net.getLayer(outLayers[0])->type, "Convolution"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(Layer_Test_Convolution_DLDT, setInput_uint8) |
|
|
|
@ -962,23 +956,16 @@ TEST_P(Layer_Test_Convolution_DLDT, setInput_uint8) |
|
|
|
|
randu(inputs[0], 0, 255); |
|
|
|
|
inputs[0].convertTo(inputs[1], CV_32F); |
|
|
|
|
|
|
|
|
|
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : ""; |
|
|
|
|
|
|
|
|
|
Mat outs[2]; |
|
|
|
|
for (int i = 0; i < 2; ++i) |
|
|
|
|
{ |
|
|
|
|
Net net = readNet(_tf("layer_convolution.xml"), _tf("layer_convolution.bin")); |
|
|
|
|
Net net = readNet(_tf("layer_convolution" + suffix + ".xml"), _tf("layer_convolution" + suffix + ".bin")); |
|
|
|
|
net.setPreferableTarget(targetId); |
|
|
|
|
net.setInput(inputs[i]); |
|
|
|
|
if (targetId != DNN_TARGET_MYRIAD) |
|
|
|
|
{ |
|
|
|
|
outs[i] = net.forward(); |
|
|
|
|
ASSERT_EQ(outs[i].type(), CV_32F); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// An assertion is expected because the model is in FP32 format but
|
|
|
|
|
// Myriad plugin supports only FP16 models.
|
|
|
|
|
ASSERT_ANY_THROW(net.forward()); |
|
|
|
|
} |
|
|
|
|
outs[i] = net.forward(); |
|
|
|
|
ASSERT_EQ(outs[i].type(), CV_32F); |
|
|
|
|
} |
|
|
|
|
if (targetId != DNN_TARGET_MYRIAD) |
|
|
|
|
normAssert(outs[0], outs[1]); |
|
|
|
@ -1020,7 +1007,8 @@ TEST_P(Test_DLDT_two_inputs_3dim, as_IR) |
|
|
|
|
throw SkipTestException("Test is enabled starts from OpenVINO 2018R4"); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
Net net = readNet(_tf("net_two_inputs.xml"), _tf("net_two_inputs.bin")); |
|
|
|
|
std::string suffix = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? "_fp16" : ""; |
|
|
|
|
Net net = readNet(_tf("net_two_inputs" + suffix + ".xml"), _tf("net_two_inputs.bin")); |
|
|
|
|
std::vector<int> inpSize = get<3>(GetParam()); |
|
|
|
|
Mat firstInp(3, inpSize.data(), firstInpType); |
|
|
|
|
Mat secondInp(3, inpSize.data(), secondInpType); |
|
|
|
@ -1030,20 +1018,17 @@ TEST_P(Test_DLDT_two_inputs_3dim, as_IR) |
|
|
|
|
net.setInput(firstInp, "data"); |
|
|
|
|
net.setInput(secondInp, "second_input"); |
|
|
|
|
net.setPreferableTarget(targetId); |
|
|
|
|
if (targetId != DNN_TARGET_MYRIAD) |
|
|
|
|
{ |
|
|
|
|
Mat out = net.forward(); |
|
|
|
|
|
|
|
|
|
Mat ref; |
|
|
|
|
cv::add(firstInp, secondInp, ref, Mat(), CV_32F); |
|
|
|
|
normAssert(out, ref); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// An assertion is expected because the model is in FP32 format but
|
|
|
|
|
// Myriad plugin supports only FP16 models.
|
|
|
|
|
ASSERT_ANY_THROW(net.forward()); |
|
|
|
|
} |
|
|
|
|
double l1 = ((targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) && |
|
|
|
|
(firstInpType == CV_32F || secondInpType == CV_32F)) ? 0.06 : 0.0; |
|
|
|
|
double lInf = ((targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) && |
|
|
|
|
(firstInpType == CV_32F || secondInpType == CV_32F)) ? 0.23 : 0.0; |
|
|
|
|
|
|
|
|
|
Mat out = net.forward(); |
|
|
|
|
|
|
|
|
|
Mat ref; |
|
|
|
|
cv::add(firstInp, secondInp, ref, Mat(), CV_32F); |
|
|
|
|
normAssert(out, ref, "", l1, lInf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector< std::vector<int> > list_sizes{ {1, 2, 3}, {3, 2, 1}, {5, 5, 5}, {13, 7, 11} }; |
|
|
|
|