diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp index 534ceff3df..9fd611fd0a 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 { @@ -1323,6 +1331,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 1f95dcfa2a..642b5158b1 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -217,6 +217,21 @@ TEST_P(Test_TensorFlow_layers, concat_axis_1) runTensorFlowNet("concat_axis_1"); } +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"); +} + TEST_P(Test_TensorFlow_layers, batch_norm_1) { runTensorFlowNet("batch_norm");