1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #21703 from rogday:transpose

Add n-dimensional transpose to core

* add n-dimensional transpose to core

* add performance test, write sequentially and address review comments
This commit is contained in:
rogday
2022-03-14 16:10:04 +03:00
committed by GitHub
parent 5bf3c1df24
commit e16cb8b4a2
4 changed files with 175 additions and 0 deletions
+24
View File
@@ -1,4 +1,5 @@
#include "perf_precomp.hpp"
#include <numeric>
namespace opencv_test
{
@@ -393,6 +394,29 @@ PERF_TEST_P_(BinaryOpTest, reciprocal)
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, transposeND)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type).reshape(1);
std::vector<int> order(a.dims);
std::iota(order.begin(), order.end(), 0);
std::reverse(order.begin(), order.end());
std::vector<int> new_sz(a.dims);
std::copy(a.size.p, a.size.p + a.dims, new_sz.begin());
std::reverse(new_sz.begin(), new_sz.end());
cv::Mat b = Mat(new_sz, type);
declare.in(a,WARMUP_RNG).out(b);
TEST_CYCLE() cv::transposeND(a, order, b);
SANITY_CHECK_NOTHING();
}
INSTANTIATE_TEST_CASE_P(/*nothing*/ , BinaryOpTest,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p),