From a31f4f4040242385a682a63ba92b0b00d96d1d24 Mon Sep 17 00:00:00 2001 From: Abdurrahheem Date: Wed, 3 Apr 2024 12:22:53 +0400 Subject: [PATCH] git squash --- modules/dnn/test/test_layers_1d.cpp | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/modules/dnn/test/test_layers_1d.cpp b/modules/dnn/test/test_layers_1d.cpp index a79614c3f6..8c2350a6ed 100644 --- a/modules/dnn/test/test_layers_1d.cpp +++ b/modules/dnn/test/test_layers_1d.cpp @@ -480,4 +480,37 @@ INSTANTIATE_TEST_CASE_P(/*nothing*/, Layer_Scatter_Test, Combine( +typedef testing::TestWithParam>> Layer_Permute_Test; +TEST_P(Layer_Permute_Test, Accuracy_01D) +{ + LayerParams lp; + lp.type = "Permute"; + lp.name = "PermuteLayer"; + + int order[] = {0}; // Since it's a 0D tensor, the order remains [0] + lp.set("order", DictValue::arrayInt(order, 1)); + Ptr layer = PermuteLayer::create(lp); + + std::vector input_shape = get<0>(GetParam()); + + Mat input = Mat(input_shape.size(), input_shape.data(), CV_32F); + cv::randn(input, 0.0, 1.0); + Mat output_ref = input.clone(); + + std::vector inputs{input}; + std::vector outputs; + + runLayer(layer, inputs, outputs); + ASSERT_EQ(outputs.size(), 1); + ASSERT_EQ(shape(output_ref), shape(outputs[0])); + normAssert(output_ref, outputs[0]); +} +INSTANTIATE_TEST_CASE_P(/*nothing*/, Layer_Permute_Test, +/*input blob shape*/ testing::Values( + std::vector{}, + std::vector{1}, + std::vector{1, 4}, + std::vector{4, 1} +)); + }}