mirror of
https://github.com/opencv/opencv.git
synced 2025-08-01 02:18:01 +08:00
Merge pull request #13107 from alalek:core_divzero_simd_test
This commit is contained in:
commit
93d1785820
@ -2249,33 +2249,53 @@ void testDivideChecks(const Mat& dst)
|
|||||||
{
|
{
|
||||||
for (int x = 0; x < dst.cols; x++)
|
for (int x = 0; x < dst.cols; x++)
|
||||||
{
|
{
|
||||||
if (x == 2)
|
if ((x % 4) == 2)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(0, dst.at<T>(y, x)) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
|
EXPECT_EQ(0, dst.at<T>(y, x)) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EXPECT_TRUE(0 == cvIsNaN((double)dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
|
||||||
|
EXPECT_TRUE(0 == cvIsInf((double)dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> static inline
|
||||||
template <typename T, bool isUMat> static inline
|
void testDivide(bool isUMat, double scale, bool largeSize, bool tailProcessing, bool roi)
|
||||||
void testDivide()
|
|
||||||
{
|
{
|
||||||
Mat src1, src2;
|
Mat src1, src2;
|
||||||
testDivideInitData<T>(src1, src2);
|
testDivideInitData<T>(src1, src2);
|
||||||
ASSERT_FALSE(src1.empty()); ASSERT_FALSE(src2.empty());
|
ASSERT_FALSE(src1.empty()); ASSERT_FALSE(src2.empty());
|
||||||
|
|
||||||
|
if (largeSize)
|
||||||
|
{
|
||||||
|
repeat(src1.clone(), 1, 8, src1);
|
||||||
|
repeat(src2.clone(), 1, 8, src2);
|
||||||
|
}
|
||||||
|
if (tailProcessing)
|
||||||
|
{
|
||||||
|
src1 = src1(Rect(0, 0, src1.cols - 1, src1.rows));
|
||||||
|
src2 = src2(Rect(0, 0, src2.cols - 1, src2.rows));
|
||||||
|
}
|
||||||
|
if (!roi && tailProcessing)
|
||||||
|
{
|
||||||
|
src1 = src1.clone();
|
||||||
|
src2 = src2.clone();
|
||||||
|
}
|
||||||
|
|
||||||
Mat dst;
|
Mat dst;
|
||||||
if (!isUMat)
|
if (!isUMat)
|
||||||
{
|
{
|
||||||
cv::divide(src1, src2, dst);
|
cv::divide(src1, src2, dst, scale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UMat usrc1, usrc2, udst;
|
UMat usrc1, usrc2, udst;
|
||||||
src1.copyTo(usrc1);
|
src1.copyTo(usrc1);
|
||||||
src2.copyTo(usrc2);
|
src2.copyTo(usrc2);
|
||||||
cv::divide(usrc1, usrc2, udst);
|
cv::divide(usrc1, usrc2, udst, scale);
|
||||||
udst.copyTo(dst);
|
udst.copyTo(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2289,14 +2309,46 @@ void testDivide()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Core_DivideRules, type_32s) { testDivide<int, false>(); }
|
typedef tuple<bool, double, bool, bool, bool> DivideRulesParam;
|
||||||
TEST(UMat_Core_DivideRules, type_32s) { testDivide<int, true>(); }
|
typedef testing::TestWithParam<DivideRulesParam> Core_DivideRules;
|
||||||
TEST(Core_DivideRules, type_16s) { testDivide<short, false>(); }
|
|
||||||
TEST(UMat_Core_DivideRules, type_16s) { testDivide<short, true>(); }
|
TEST_P(Core_DivideRules, type_32s)
|
||||||
TEST(Core_DivideRules, type_32f) { testDivide<float, false>(); }
|
{
|
||||||
TEST(UMat_Core_DivideRules, type_32f) { testDivide<float, true>(); }
|
DivideRulesParam param = GetParam();
|
||||||
TEST(Core_DivideRules, type_64f) { testDivide<double, false>(); }
|
testDivide<int>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
|
||||||
TEST(UMat_Core_DivideRules, type_64f) { testDivide<double, true>(); }
|
}
|
||||||
|
TEST_P(Core_DivideRules, type_16s)
|
||||||
|
{
|
||||||
|
DivideRulesParam param = GetParam();
|
||||||
|
testDivide<short>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
|
||||||
|
}
|
||||||
|
TEST_P(Core_DivideRules, type_32f)
|
||||||
|
{
|
||||||
|
DivideRulesParam param = GetParam();
|
||||||
|
testDivide<float>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
|
||||||
|
}
|
||||||
|
TEST_P(Core_DivideRules, type_64f)
|
||||||
|
{
|
||||||
|
DivideRulesParam param = GetParam();
|
||||||
|
testDivide<double>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(/* */, Core_DivideRules, testing::Combine(
|
||||||
|
/* isMat */ testing::Values(false),
|
||||||
|
/* scale */ testing::Values(1.0, 5.0),
|
||||||
|
/* largeSize */ testing::Bool(),
|
||||||
|
/* tail */ testing::Bool(),
|
||||||
|
/* roi */ testing::Bool()
|
||||||
|
));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(UMat, Core_DivideRules, testing::Combine(
|
||||||
|
/* isMat */ testing::Values(true),
|
||||||
|
/* scale */ testing::Values(1.0, 5.0),
|
||||||
|
/* largeSize */ testing::Bool(),
|
||||||
|
/* tail */ testing::Bool(),
|
||||||
|
/* roi */ testing::Bool()
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
TEST(Core_MinMaxIdx, rows_overflow)
|
TEST(Core_MinMaxIdx, rows_overflow)
|
||||||
|
Loading…
Reference in New Issue
Block a user