|
|
|
@ -23,6 +23,9 @@ using GMat3 = std::tuple<GMat, GMat, GMat>; |
|
|
|
|
using GScalar = cv::GScalar; |
|
|
|
|
template <typename T> using GArray = cv::GArray<T>; |
|
|
|
|
|
|
|
|
|
using ArrayT = int; |
|
|
|
|
using WrongArrayT = char; |
|
|
|
|
|
|
|
|
|
GAPI_TRANSFORM(gmat_in_gmat_out, <GMat(GMat)>, "gmat_in_gmat_out") |
|
|
|
|
{ |
|
|
|
|
static GMat pattern(GMat) { return {}; } |
|
|
|
@ -59,22 +62,34 @@ GAPI_TRANSFORM(gmat_in_gsc_out, <GScalar(GMat)>, "gmat_in_gsc_out") |
|
|
|
|
static GScalar substitute(GMat) { return {}; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GAPI_TRANSFORM(garr_in_gmat_out, <GMat(GArray<int>)>, "garr_in_gmat_out") |
|
|
|
|
GAPI_TRANSFORM(garr_in_gmat_out, <GMat(GArray<ArrayT>)>, "garr_in_gmat_out") |
|
|
|
|
{ |
|
|
|
|
static GMat pattern(GArray<ArrayT>) { return {}; } |
|
|
|
|
static GMat substitute(GArray<ArrayT>) { return {}; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GAPI_TRANSFORM(gmat_in_garr_out, <GArray<ArrayT>(GMat)>, "gmat_in_garr_out") |
|
|
|
|
{ |
|
|
|
|
static GMat pattern(GArray<int>) { return {}; } |
|
|
|
|
static GMat substitute(GArray<int>) { return {}; } |
|
|
|
|
static GArray<ArrayT> pattern(GMat) { return {}; } |
|
|
|
|
static GArray<ArrayT> substitute(GMat) { return {}; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GAPI_TRANSFORM(gmat_in_garr_out, <GArray<int>(GMat)>, "gmat_in_garr_out") |
|
|
|
|
GAPI_TRANSFORM(garr_in_gscalar_out, <GScalar(GArray<ArrayT>)>, "garr_in_gscalar_out") |
|
|
|
|
{ |
|
|
|
|
static GArray<int> pattern(GMat) { return {}; } |
|
|
|
|
static GArray<int> substitute(GMat) { return {}; } |
|
|
|
|
static GScalar pattern(GArray<ArrayT>) { return {}; } |
|
|
|
|
static GScalar substitute(GArray<ArrayT>) { return {}; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GAPI_TRANSFORM(gmat_gsc_garray_in_gmat2_out, <GMat2(GMat, GScalar, GArray<int>)>, "gmat_gsc_garray_in_gmat2_out") |
|
|
|
|
GAPI_TRANSFORM(gscalar_in_garr_out, <GArray<ArrayT>(GScalar)>, "gscalar_in_garr_out") |
|
|
|
|
{ |
|
|
|
|
static GMat2 pattern(GMat, GScalar, GArray<int>) { return {}; } |
|
|
|
|
static GMat2 substitute(GMat, GScalar, GArray<int>) { return {}; } |
|
|
|
|
static GArray<ArrayT> pattern(GScalar) { return {}; } |
|
|
|
|
static GArray<ArrayT> substitute(GScalar) { return {}; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GAPI_TRANSFORM(gmat_gsc_garray_in_gmat2_out, <GMat2(GMat, GScalar, GArray<ArrayT>)>, "gmat_gsc_garray_in_gmat2_out") |
|
|
|
|
{ |
|
|
|
|
static GMat2 pattern(GMat, GScalar, GArray<ArrayT>) { return {}; } |
|
|
|
|
static GMat2 substitute(GMat, GScalar, GArray<ArrayT>) { return {}; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
@ -90,11 +105,13 @@ TEST(KernelPackageTransform, CreatePackage) |
|
|
|
|
, gmat_in_gsc_out |
|
|
|
|
, garr_in_gmat_out |
|
|
|
|
, gmat_in_garr_out |
|
|
|
|
, garr_in_gscalar_out |
|
|
|
|
, gscalar_in_garr_out |
|
|
|
|
, gmat_gsc_garray_in_gmat2_out |
|
|
|
|
>(); |
|
|
|
|
|
|
|
|
|
auto tr = pkg.get_transformations(); |
|
|
|
|
EXPECT_EQ(9u, tr.size()); |
|
|
|
|
EXPECT_EQ(11u, tr.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, Include) |
|
|
|
@ -116,14 +133,15 @@ TEST(KernelPackageTransform, Combine) |
|
|
|
|
EXPECT_EQ(2u, tr.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
namespace |
|
|
|
|
{ |
|
|
|
|
template <typename T> |
|
|
|
|
inline bool ProtoContainsT(const cv::GProtoArg &arg) { |
|
|
|
|
return cv::GProtoArg::index_of<T>() == arg.index(); |
|
|
|
|
} |
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, gmat_gsc_in_gmat_out) |
|
|
|
|
TEST(KernelPackageTransform, gmat_gsc_garray_in_gmat2_out) |
|
|
|
|
{ |
|
|
|
|
auto tr = gmat_gsc_garray_in_gmat2_out::transformation(); |
|
|
|
|
|
|
|
|
@ -135,8 +153,8 @@ TEST(KernelPackageTransform, gmat_gsc_in_gmat_out) |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_ins[0])); |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<GScalar>(p.m_ins[1])); |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_ins[2])); |
|
|
|
|
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_ins[2]).holds<int>()); |
|
|
|
|
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_ins[2]).holds<char>()); |
|
|
|
|
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_ins[2]).holds<ArrayT>()); |
|
|
|
|
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_ins[2]).holds<WrongArrayT>()); |
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[0])); |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[1])); |
|
|
|
@ -146,44 +164,102 @@ TEST(KernelPackageTransform, gmat_gsc_in_gmat_out) |
|
|
|
|
check(tr.substitute()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, gmat_in_garr_out) |
|
|
|
|
namespace |
|
|
|
|
{ |
|
|
|
|
auto tr = gmat_in_garr_out::transformation(); |
|
|
|
|
template<typename InType, typename OutType> |
|
|
|
|
typename std::enable_if<(cv::detail::GTypeTraits<OutType>::kind == cv::detail::ArgKind::GARRAY), void>::type |
|
|
|
|
array_check(const cv::GComputation::Priv &p) |
|
|
|
|
{ |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<InType>(p.m_ins[0])); |
|
|
|
|
|
|
|
|
|
auto check = [](const cv::GComputation &comp){ |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_outs[0])); |
|
|
|
|
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_outs[0]).holds<ArrayT>()); |
|
|
|
|
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_outs[0]).holds<WrongArrayT>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename InType, typename OutType> |
|
|
|
|
typename std::enable_if<(cv::detail::GTypeTraits<InType>::kind == cv::detail::ArgKind::GARRAY), void>::type |
|
|
|
|
array_check(const cv::GComputation::Priv &p) |
|
|
|
|
{ |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<OutType>(p.m_outs[0])); |
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_ins[0])); |
|
|
|
|
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_ins[0]).holds<ArrayT>()); |
|
|
|
|
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_ins[0]).holds<WrongArrayT>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename InType, typename OutType> |
|
|
|
|
typename std::enable_if<(cv::detail::GTypeTraits<InType>::kind == cv::detail::ArgKind::GARRAY || |
|
|
|
|
cv::detail::GTypeTraits<OutType>::kind == cv::detail::ArgKind::GARRAY), void>::type |
|
|
|
|
args_check(const cv::GComputation &comp) |
|
|
|
|
{ |
|
|
|
|
const auto &p = comp.priv(); |
|
|
|
|
EXPECT_EQ(1u, p.m_ins.size()); |
|
|
|
|
EXPECT_EQ(1u, p.m_outs.size()); |
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_ins[0])); |
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_outs[0])); |
|
|
|
|
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_outs[0]).holds<int>()); |
|
|
|
|
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_outs[0]).holds<float>()); |
|
|
|
|
array_check<InType, OutType>(p); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
check(tr.pattern()); |
|
|
|
|
check(tr.substitute()); |
|
|
|
|
template<typename InType, typename OutType> |
|
|
|
|
typename std::enable_if<(cv::detail::GTypeTraits<InType>::kind != cv::detail::ArgKind::GARRAY && |
|
|
|
|
cv::detail::GTypeTraits<OutType>::kind != cv::detail::ArgKind::GARRAY), void>::type |
|
|
|
|
args_check(const cv::GComputation &comp) |
|
|
|
|
{ |
|
|
|
|
const auto &p = comp.priv(); |
|
|
|
|
EXPECT_EQ(1u, p.m_ins.size()); |
|
|
|
|
EXPECT_EQ(1u, p.m_outs.size()); |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<InType>(p.m_ins[0])); |
|
|
|
|
EXPECT_TRUE(ProtoContainsT<OutType>(p.m_outs[0])); |
|
|
|
|
} |
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
|
|
template <typename Transformation, typename InType, typename OutType> |
|
|
|
|
static void transformTest() |
|
|
|
|
{ |
|
|
|
|
auto tr = Transformation::transformation(); |
|
|
|
|
|
|
|
|
|
args_check<InType, OutType>(tr.pattern()); |
|
|
|
|
args_check<InType, OutType>(tr.substitute()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, garr_in_gmat_out) |
|
|
|
|
TEST(KernelPackageTransform, gmat_in_gmat_out) |
|
|
|
|
{ |
|
|
|
|
auto tr = garr_in_gmat_out::transformation(); |
|
|
|
|
transformTest<gmat_in_gmat_out, GMat, GMat>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto check = [](const cv::GComputation &comp){ |
|
|
|
|
const auto &p = comp.priv(); |
|
|
|
|
EXPECT_EQ(1u, p.m_ins.size()); |
|
|
|
|
EXPECT_EQ(1u, p.m_outs.size()); |
|
|
|
|
TEST(KernelPackageTransform, gmatp_in_gmatp_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<gmatp_in_gmatp_out, GMatP, GMatP>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_ins[0])); |
|
|
|
|
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_ins[0]).holds<int>()); |
|
|
|
|
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_ins[0]).holds<bool>()); |
|
|
|
|
TEST(KernelPackageTransform, gsc_in_gmat_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<gsc_in_gmat_out, GScalar, GMat>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[0])); |
|
|
|
|
}; |
|
|
|
|
TEST(KernelPackageTransform, gmat_in_gsc_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<gmat_in_gsc_out, GMat, GScalar>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
check(tr.pattern()); |
|
|
|
|
check(tr.substitute()); |
|
|
|
|
TEST(KernelPackageTransform, garr_in_gmat_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<garr_in_gmat_out, GArray<ArrayT>, GMat>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, gmat_in_garr_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<gmat_in_garr_out, GMat, GArray<ArrayT>>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, garr_in_gscalar_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<garr_in_gscalar_out, GArray<ArrayT>, GScalar>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(KernelPackageTransform, gscalar_in_garr_out) |
|
|
|
|
{ |
|
|
|
|
transformTest<gscalar_in_garr_out, GScalar, GArray<ArrayT>>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace opencv_test
|
|
|
|
|