added perf tests for T-API core functions

This commit is contained in:
Ilya Lavrenov
2013-12-13 19:35:30 +04:00
parent 06e981f1ce
commit d7c22343aa
4 changed files with 676 additions and 35 deletions

View File

@@ -53,41 +53,31 @@ namespace perf {
void checkDeviceMaxMemoryAllocSize(const Size& size, int type, int factor)
{
assert(factor > 0);
if (!cv::ocl::useOpenCL())
return;
int cn = CV_MAT_CN(type);
int cn_ocl = cn == 3 ? 4 : cn;
int type_ocl = CV_MAKE_TYPE(CV_MAT_DEPTH(type), cn_ocl);
size_t memSize = size.area() * CV_ELEM_SIZE(type_ocl);
size_t memSize = size.area() * CV_ELEM_SIZE(type);
const cv::ocl::Device& dev = cv::ocl::Device::getDefault();
if (memSize * factor >= dev.maxMemAllocSize())
{
throw ::perf::TestBase::PerfSkipTestException();
}
}
void randu(InputOutputArray dst)
{
if (dst.depth() == CV_8U)
{
cv::randu(dst, 0, 256);
}
else if (dst.depth() == CV_8S)
{
cv::randu(dst, -128, 128);
}
else if (dst.depth() == CV_16U)
{
cv::randu(dst, 0, 1024);
}
else if (dst.depth() == CV_32F || dst.depth() == CV_64F)
{
cv::randu(dst, -1.0, 1.0);
}
else // (dst.depth() == CV_16S || dst.depth() == CV_32S)
{
else if (dst.depth() == CV_16S || dst.depth() == CV_32S)
cv::randu(dst, -4096, 4096);
}
else
CV_Error(Error::StsUnsupportedFormat, "Unsupported format");
}
} // namespace perf

View File

@@ -268,7 +268,8 @@ std::string Regression::getCurrentTestNodeName()
bool Regression::isVector(cv::InputArray a)
{
return a.kind() == cv::_InputArray::STD_VECTOR_MAT || a.kind() == cv::_InputArray::STD_VECTOR_VECTOR;
return a.kind() == cv::_InputArray::STD_VECTOR_MAT || a.kind() == cv::_InputArray::STD_VECTOR_VECTOR ||
a.kind() == cv::_InputArray::STD_VECTOR_UMAT;
}
double Regression::getElem(cv::Mat& m, int y, int x, int cn)
@@ -866,17 +867,27 @@ void TestBase::declareArray(SizeVector& sizes, cv::InputOutputArray a, WarmUpTyp
void TestBase::warmup(cv::InputOutputArray a, WarmUpType wtype)
{
if (a.empty())
return;
else if (a.isUMat() && wtype != WARMUP_READ)
{
int depth = a.depth();
if (depth == CV_8U)
cv::randu(a, 0, 256);
else if (depth == CV_8S)
cv::randu(a, -128, 128);
else if (depth == CV_16U)
cv::randu(a, 0, 1024);
else if (depth == CV_32F || depth == CV_64F)
cv::randu(a, -1.0, 1.0);
else if (depth == CV_16S || depth == CV_32S)
cv::randu(a, -4096, 4096);
else
CV_Error(cv::Error::StsUnsupportedFormat, "Unsupported format");
return;
}
else if (a.isUMat())
{
return; // TODO current warmup_impl is not useful for GPU-based data
}
else if (a.kind() != cv::_InputArray::STD_VECTOR_MAT && a.kind() != cv::_InputArray::STD_VECTOR_VECTOR)
{
warmup_impl(a.getMat(), wtype);
}
else
{
size_t total = a.total();