diff --git a/modules/dnn/src/graph_block_layout.cpp b/modules/dnn/src/graph_block_layout.cpp index f304807236..e109adc9a7 100644 --- a/modules/dnn/src/graph_block_layout.cpp +++ b/modules/dnn/src/graph_block_layout.cpp @@ -166,6 +166,17 @@ struct BlockLayoutTransformer CV_Assert(inputLayoutsNew.size() == ninputs); CV_Assert(outputLayouts.size() == noutputs); + fprintf(stderr, "BLKALL op=%s name=%s\n", op_name.c_str(), name.c_str()); + if (op_name == "Pooling" || op_name == "DequantizeLinear" || op_name == "QuantizeLinear") { + fprintf(stderr, "BLKDBG op=%s name=%s deviceOp=%d defaultLayout=%d orig=[", op_name.c_str(), name.c_str(), (int)deviceOp, (int)defaultLayout); + for (auto l : inputLayoutsOrig) fprintf(stderr, "%d,", (int)l); + fprintf(stderr, "] new=["); + for (auto l : inputLayoutsNew) fprintf(stderr, "%d,", (int)l); + fprintf(stderr, "] out=["); + for (auto l : outputLayouts) fprintf(stderr, "%d,", (int)l); + fprintf(stderr, "]\n"); + } + if (deviceOp) { for (size_t i = 0; i < ninputs; i++) inputLayoutsNew[i] = defaultLayout; diff --git a/modules/dnn/src/layers/conv2_common.cpp b/modules/dnn/src/layers/conv2_common.cpp index 89d5d3b052..876b185e23 100644 --- a/modules/dnn/src/layers/conv2_common.cpp +++ b/modules/dnn/src/layers/conv2_common.cpp @@ -396,7 +396,7 @@ MatShape deconvInferShape(const MatShape& inpShape, const MatShape& wshape, const std::vector& adjustPads, AutoPadding autoPad) { - bool blockLayout = true; + bool blockLayout = (inpShape.layout == DATA_LAYOUT_BLOCK); int ndims = inpShape.dims; int nspatialdims = ndims - 2 - int(blockLayout); CV_Assert(nspatialdims >= 1); @@ -413,9 +413,13 @@ MatShape deconvInferShape(const MatShape& inpShape, const MatShape& wshape, kshape_[i] = wshape[i + 2]; } - int C0 = inpShape[ndims - 1]; int K_out = ngroups * wshape[1]; - outshape[1] = (K_out + C0 - 1) / C0; + if (blockLayout) { + int C0 = inpShape[ndims - 1]; + outshape[1] = (K_out + C0 - 1) / C0; + } else { + outshape[1] = K_out; + } CV_Assert(strides.empty() || (int)strides.size() == nspatialdims); CV_Assert(dilations.empty() || (int)dilations.size() == nspatialdims); @@ -439,7 +443,7 @@ MatShape deconvInferShape(const MatShape& inpShape, const MatShape& wshape, } outshape[i + 2] = outsz; } - outshape.C = K_out; + outshape.C = blockLayout ? K_out : 0; return outshape; } diff --git a/modules/dnn/src/layers/pooling_layer.cpp b/modules/dnn/src/layers/pooling_layer.cpp index 1f3932dc7b..2757b8513e 100644 --- a/modules/dnn/src/layers/pooling_layer.cpp +++ b/modules/dnn/src/layers/pooling_layer.cpp @@ -1180,6 +1180,10 @@ public: { CV_Assert(inputs.size() != 0); + fprintf(stderr, "DBG Pooling '%s' inp0 dims=%d layout=%d global=%d kernel=%zu pads_begin=%zu shape=[", name.c_str(), (int)inputs[0].size(), (int)inputs[0].layout, (int)globalPooling, kernel_size.size(), pads_begin.size()); + for (size_t _i=0;_i inpShape(inputs[0].begin() + 2, inputs[0].end()); std::vector outShape(inputs[0].begin(), inputs[0].begin() + 2); diff --git a/modules/dnn/test/test_model.cpp b/modules/dnn/test/test_model.cpp index 47935ae7bd..5d71d518c7 100644 --- a/modules/dnn/test/test_model.cpp +++ b/modules/dnn/test/test_model.cpp @@ -776,7 +776,7 @@ TEST_P(Reproducibility_ResNet50_ONNX, Accuracy) timeMax = std::max(timeMax, t); } - std::cout << "[ BENCHMARK ] ResNet50 ONNX (backend=" << backendId << ", target=" << targetId << ") over " + std::cout << "[ BENCHMARK ] ResNet50 ONNX (backend=" << (int)backendId << ", target=" << (int)targetId << ") over " << numRuns << " runs: avg=" << (timeSum / numRuns) << " ms" << ", min=" << timeMin << " ms" << ", max=" << timeMax << " ms" << std::endl;