0D test for Reshape layer (#25206)

* reshape test for 0D

* fix comments according to PR
pull/25263/head
Abduragim Shtanchaev 9 months ago committed by GitHub
parent 8e342f8857
commit d188319b82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 26
      modules/dnn/test/test_layers_1d.cpp

@ -245,4 +245,30 @@ INSTANTIATE_TEST_CASE_P(/*nothing*/, Layer_Elemwise_1d_Test, Combine(
/*operation*/ Values("div", "prod", "max", "min", "sum")
));
TEST(Layer_Reshape_Test, Accuracy)
{
LayerParams lp;
lp.type = "Reshape";
lp.name = "ReshapeLayer";
lp.set("axis", 0); // Set axis to 0 to start reshaping from the first dimension
lp.set("num_axes", -1); // Set num_axes to -1 to indicate all following axes are included in the reshape
int newShape[] = {1};
lp.set("dim", DictValue::arrayInt(newShape, 1));
Ptr<ReshapeLayer> layer = ReshapeLayer::create(lp);
std::vector<int> input_shape = {0};
Mat input(0, input_shape.data(), CV_32F);
randn(input, 0.0, 1.0);
Mat output_ref(1, newShape, CV_32F, input.data);
std::vector<Mat> inputs{input};
std::vector<Mat> outputs;
runLayer(layer, inputs, outputs);
ASSERT_EQ(shape(output_ref), shape(outputs[0]));
normAssert(output_ref, outputs[0]);
}
}}

Loading…
Cancel
Save