From aa08900ac8c3399534d57f55b7e7b3b1a6d8c132 Mon Sep 17 00:00:00 2001 From: Liubov Batanina Date: Tue, 21 Apr 2020 10:34:56 +0300 Subject: [PATCH 1/3] Supported TF concat 3d --- modules/dnn/src/tensorflow/tf_importer.cpp | 10 ++++++++++ modules/dnn/test/test_tf_importer.cpp | 1 + 2 files changed, 11 insertions(+) diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp index 0dd21770a4..6aadc57f40 100644 --- a/modules/dnn/src/tensorflow/tf_importer.cpp +++ b/modules/dnn/src/tensorflow/tf_importer.cpp @@ -46,6 +46,14 @@ static int toNCHW(int idx) else return (4 + idx) % 3 + 1; } +static int toNCDHW(int idx) +{ + CV_Assert(-5 <= idx && idx < 5); + if (idx == 0) return 0; + else if (idx > 0) return idx % 4 + 1; + else return (5 + idx) % 4 + 1; +} + // This values are used to indicate layer output's data layout where it's possible. enum DataLayout { @@ -1313,6 +1321,8 @@ void TFImporter::populateNet(Net dstNet) if (getDataLayout(name, data_layouts) == DATA_LAYOUT_NHWC) axis = toNCHW(axis); + else if (getDataLayout(name, data_layouts) == DATA_LAYOUT_NDHWC) + axis = toNCDHW(axis); layerParams.set("axis", axis); // input(0) or input(n-1) is concat_dim diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index b71dfbc84a..8c487434a0 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -196,6 +196,7 @@ TEST_P(Test_TensorFlow_layers, pad_and_concat) TEST_P(Test_TensorFlow_layers, concat_axis_1) { runTensorFlowNet("concat_axis_1"); + runTensorFlowNet("concat_3d"); } TEST_P(Test_TensorFlow_layers, batch_norm_1) From 1c1762d3f678f31ca402ade3b7ef9603c30eeaa7 Mon Sep 17 00:00:00 2001 From: Liubov Batanina Date: Wed, 22 Apr 2020 09:52:20 +0300 Subject: [PATCH 2/3] Skip myriad --- modules/dnn/test/test_tf_importer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index 8c487434a0..9e30bcafee 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -196,6 +196,8 @@ TEST_P(Test_TensorFlow_layers, pad_and_concat) TEST_P(Test_TensorFlow_layers, concat_axis_1) { runTensorFlowNet("concat_axis_1"); + if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD) + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); runTensorFlowNet("concat_3d"); } From 4bf94cb5d104d348583a393fa6fca0ebda5a6e7f Mon Sep 17 00:00:00 2001 From: Liubov Batanina Date: Sun, 26 Apr 2020 20:42:11 +0300 Subject: [PATCH 3/3] Fix test --- modules/dnn/test/test_tf_importer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index 9e30bcafee..8c4558bf4d 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -196,8 +196,20 @@ TEST_P(Test_TensorFlow_layers, pad_and_concat) TEST_P(Test_TensorFlow_layers, concat_axis_1) { runTensorFlowNet("concat_axis_1"); - if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); +} + +TEST_P(Test_TensorFlow_layers, concat_3d) +{ + if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU) + { + if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16); + if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL); + } + + if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH || + backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019) && target == DNN_TARGET_MYRIAD) + applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); + runTensorFlowNet("concat_3d"); }