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} +)); + }}