Skip to content

Commit

Permalink
Padding layer test. Strange behavior in normAssert.
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdurrahheem committed Apr 10, 2024
1 parent b3e4e58 commit 88aae51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/dnn/test/test_common.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void normAssert(
cv::InputArray ref, cv::InputArray test, const char *comment /*= ""*/,
double l1 /*= 0.00001*/, double lInf /*= 0.0001*/)
{
std::cout << "ref size: " << ref.size() << std::endl;
double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total();
EXPECT_LE(normL1, l1) << comment << " |ref| = " << cvtest::norm(ref, cv::NORM_INF);

Expand Down
8 changes: 5 additions & 3 deletions modules/dnn/test/test_layers_1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ TEST_P(Layer_Padding_Test, Accuracy_01D){
if (input_shape.size() == 0 || input_shape.size() == 1){
std::cout << "shape output_ref: " << shape(output_ref) << std::endl;
std::cout << "total: " << output_ref.total() << std::endl;
// output_ref = output_ref.reshape(1, {3});
std::cout << "output_ref: " << output_ref.size() << std::endl;
output_ref = output_ref.reshape(1, (int)output_ref.total());
output_ref.dims = 1;
std::cout << "output_ref: " << output_ref.size() << std::endl;
}
std::cout << "input: " << input << std::endl;
std::cout << "output_ref: " << output_ref << std::endl;
std::cout << "shape output_ref: " << shape(output_ref) << std::endl;

std::vector<Mat> inputs{input};
Expand All @@ -550,6 +550,8 @@ TEST_P(Layer_Padding_Test, Accuracy_01D){
runLayer(layer, inputs, outputs);
std::cout << "output[0]: " << outputs[0] << std::endl;
std::cout << "output[0] shape: " << shape(outputs[0]) << std::endl;
std::cout << "output_ref: " << output_ref.size() << std::endl;
std::cout << "output[0]: " << outputs[0].size() << std::endl;
ASSERT_EQ(outputs.size(), 1);
ASSERT_EQ(shape(output_ref), shape(outputs[0]));
normAssert(output_ref, outputs[0]);
Expand Down
4 changes: 4 additions & 0 deletions modules/ts/src/ts_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,8 @@ double norm(InputArray _src, int normType, InputArray _mask)
double norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask)
{
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
std::cout << "scr1 size: " << src1.size << std::endl;
std::cout << "scr2 size: " << src2.size << std::endl;
if( src1.depth() == CV_16F || src1.depth() == CV_16BF )
{
Mat src1_32f, src2_32f;
Expand Down Expand Up @@ -1502,6 +1504,8 @@ double norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask)
normType = normType == NORM_L2SQR ? NORM_L2 : normType;

CV_CheckTypeEQ(src1.type(), src2.type(), "");
std::cout << "scr1 size: " << src1.size << std::endl;
std::cout << "scr2 size: " << src2.size << std::endl;
CV_Assert(src1.size == src2.size);
CV_Assert( mask.empty() || (src1.size == mask.size && mask.type() == CV_8U) );
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 );
Expand Down

0 comments on commit 88aae51

Please sign in to comment.