// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. #include "test_precomp.hpp" #include "test_common.impl.hpp" // shared with perf tests #include namespace opencv_test { void runLayer(cv::Ptr layer, std::vector &inpBlobs, std::vector &outBlobs) { size_t ninputs = inpBlobs.size(); std::vector inp(ninputs), outp, intp; std::vector inputs, outputs, internals; std::vector inputs_types, outputs_types, internals_types; for (size_t i = 0; i < ninputs; i++) { inp[i] = inpBlobs[i].clone(); inputs.push_back(cv::dnn::shape(inp[i])); inputs_types.push_back(cv::dnn::MatType(inp[i].type())); } layer->getMemoryShapes(inputs, 0, outputs, internals); layer->getTypes(inputs_types, outputs.size(), internals.size(), outputs_types, internals_types); for (size_t i = 0; i < outputs.size(); i++) { outp.push_back(cv::Mat(outputs[i], outputs_types[i])); } for (size_t i = 0; i < internals.size(); i++) { intp.push_back(cv::Mat(internals[i], internals_types[i])); } layer->finalize(inp, outp); layer->forward(inp, outp, intp); size_t noutputs = outp.size(); outBlobs.resize(noutputs); for (size_t i = 0; i < noutputs; i++) outBlobs[i] = outp[i]; } }