dnn(ocl): fix gemm kernels with beta=0

- dst is not initialized, may include NaN values
- 0*NaN produces NaN
This commit is contained in:
Alexander Alekhin
2020-12-15 00:41:35 +00:00
parent 1bfc75ac23
commit 4b3d2c8834
4 changed files with 117 additions and 51 deletions
+10 -1
View File
@@ -2949,6 +2949,15 @@ bool Kernel::empty() const
return ptr() == 0;
}
static cv::String dumpValue(size_t sz, const void* p)
{
if (sz == 4)
return cv::format("%d / %uu / 0x%08x / %g", *(int*)p, *(int*)p, *(int*)p, *(float*)p);
if (sz == 8)
return cv::format("%lld / %lluu / 0x%16llx / %g", *(long long*)p, *(long long*)p, *(long long*)p, *(double*)p);
return cv::format("%p", p);
}
int Kernel::set(int i, const void* value, size_t sz)
{
if (!p || !p->handle)
@@ -2959,7 +2968,7 @@ int Kernel::set(int i, const void* value, size_t sz)
p->cleanupUMats();
cl_int retval = clSetKernelArg(p->handle, (cl_uint)i, sz, value);
CV_OCL_DBG_CHECK_RESULT(retval, cv::format("clSetKernelArg('%s', arg_index=%d, size=%d, value=%p)", p->name.c_str(), (int)i, (int)sz, (void*)value).c_str());
CV_OCL_DBG_CHECK_RESULT(retval, cv::format("clSetKernelArg('%s', arg_index=%d, size=%d, value=%s)", p->name.c_str(), (int)i, (int)sz, dumpValue(sz, value).c_str()).c_str());
if (retval != CL_SUCCESS)
return -1;
return i+1;