// 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 "perf_precomp.hpp" #include namespace opencv_test { typedef TestBaseWithParam > DeconvolutionCoordinates; PERF_TEST_P(DeconvolutionCoordinates, forward, testing::Values(make_tuple(2, 1, 1, 0), make_tuple(2, 2, 2, 0), make_tuple(2, 3, 1, 0), make_tuple(3, 1, 1, 0), make_tuple(3, 2, 2, 0), make_tuple(3, 3, 1, 0), make_tuple(2, 3, 1, 1), make_tuple(2, 4, 2, 1))) { const int dims = get<0>(GetParam()); const int kernelSize = get<1>(GetParam()); const int strideSize = get<2>(GetParam()); const int padSize = get<3>(GetParam()); std::vector inputShape = {1, 16}; for (int d = 0; d < dims; ++d) inputShape.push_back(dims == 2 ? 128 : 16); std::vector weightShape = {16, 16}; weightShape.resize(dims + 2, kernelSize); std::vector kernel(dims, kernelSize), stride(dims, strideSize), pad(dims, padSize); LayerParams lp; lp.set("kernel_size", DictValue::arrayInt(kernel.data(), dims)); lp.set("stride", DictValue::arrayInt(stride.data(), dims)); lp.set("pad", DictValue::arrayInt(pad.data(), dims)); lp.set("num_output", 16); lp.set("bias_term", true); Mat input(inputShape, CV_32F), weights(weightShape, CV_32F), bias(1, 16, CV_32F); randu(input, -1.0f, 1.0f); randu(weights, -1.0f, 1.0f); randu(bias, -1.0f, 1.0f); lp.blobs = {weights, bias}; Ptr layer = DeconvolutionLayer::create(lp); std::vector outputShapes, internalShapes; layer->getMemoryShapes({input.shape()}, 0, outputShapes, internalShapes); std::vector inputs(1, input), outputs, internals; for (const MatShape& shape : outputShapes) outputs.push_back(Mat(shape, CV_32F)); for (const MatShape& shape : internalShapes) internals.push_back(Mat(shape, CV_32F)); layer->finalize(inputs, outputs); layer->forward(inputs, outputs, internals); TEST_CYCLE() { layer->forward(inputs, outputs, internals); } SANITY_CHECK_NOTHING(); } } // namespace