Merge pull request #1745 from alalek:ocl_fix_svm_with_blas
This commit is contained in:
commit
14b2eed17b
@ -686,9 +686,6 @@ float CvSVM_OCL::predict(const CvMat* samples, CV_OUT CvMat* results) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// TODO fix it
|
|
||||||
CV_Error(CV_StsNotImplemented, "This part of code contains mistakes. Install AMD BLAS in order to get a correct result or use CPU version of SVM");
|
|
||||||
|
|
||||||
double degree1 = 0.0;
|
double degree1 = 0.0;
|
||||||
if (params.kernel_type == CvSVM::POLY)
|
if (params.kernel_type == CvSVM::POLY)
|
||||||
degree1 = params.degree;
|
degree1 = params.degree;
|
||||||
@ -813,9 +810,6 @@ bool CvSVMSolver_ocl::solve_generic( CvSVMSolutionInfo& si )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// TODO fix it
|
|
||||||
CV_Error(CV_StsNotImplemented, "This part of code contains mistakes. Install AMD BLAS in order to get a correct result or use CPU version of SVM");
|
|
||||||
|
|
||||||
double degree1 = 0.0;
|
double degree1 = 0.0;
|
||||||
if(params->kernel_type == CvSVM::POLY)
|
if(params->kernel_type == CvSVM::POLY)
|
||||||
degree1 = params->degree;
|
degree1 = params->degree;
|
||||||
@ -1000,13 +994,15 @@ void CvSVMKernel_ocl::calc( int vcount, const int row_idx, Qfloat* results, Mat&
|
|||||||
//int j;
|
//int j;
|
||||||
(this->*calc_func_ocl)( vcount, row_idx, results, src);
|
(this->*calc_func_ocl)( vcount, row_idx, results, src);
|
||||||
|
|
||||||
// FIXIT #if defined HAVE_CLAMDBLAS
|
#if !defined(HAVE_CLAMDBLAS)
|
||||||
|
// nothing
|
||||||
|
#else
|
||||||
const Qfloat max_val = (Qfloat)(FLT_MAX * 1e-3);
|
const Qfloat max_val = (Qfloat)(FLT_MAX * 1e-3);
|
||||||
int j;
|
int j;
|
||||||
for( j = 0; j < vcount; j++ )
|
for( j = 0; j < vcount; j++ )
|
||||||
if( results[j] > max_val )
|
if( results[j] > max_val )
|
||||||
results[j] = max_val;
|
results[j] = max_val;
|
||||||
// FIXIT #endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvSVMKernel_ocl::create( const CvSVMParams* _params, Calc_ocl _calc_func, Calc _calc_func1 )
|
bool CvSVMKernel_ocl::create( const CvSVMParams* _params, Calc_ocl _calc_func, Calc _calc_func1 )
|
||||||
@ -1078,12 +1074,13 @@ void CvSVMKernel_ocl::calc_poly( int vcount, const int row_idx, Qfloat* results,
|
|||||||
{
|
{
|
||||||
calc_non_rbf_base( vcount, row_idx, results, src);
|
calc_non_rbf_base( vcount, row_idx, results, src);
|
||||||
|
|
||||||
//FIXIT #if defined HAVE_CLAMDBLAS
|
#if !defined(HAVE_CLAMDBLAS)
|
||||||
|
// nothing
|
||||||
|
#else
|
||||||
CvMat R = cvMat( 1, vcount, QFLOAT_TYPE, results );
|
CvMat R = cvMat( 1, vcount, QFLOAT_TYPE, results );
|
||||||
if( vcount > 0 )
|
if( vcount > 0 )
|
||||||
cvPow( &R, &R, params->degree );
|
cvPow( &R, &R, params->degree );
|
||||||
//FIXIT #endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1091,7 +1088,9 @@ void CvSVMKernel_ocl::calc_sigmoid( int vcount, const int row_idx, Qfloat* resul
|
|||||||
{
|
{
|
||||||
calc_non_rbf_base( vcount, row_idx, results, src);
|
calc_non_rbf_base( vcount, row_idx, results, src);
|
||||||
// TODO: speedup this
|
// TODO: speedup this
|
||||||
//FIXIT #if defined HAVE_CLAMDBLAS
|
#if !defined(HAVE_CLAMDBLAS)
|
||||||
|
// nothing
|
||||||
|
#else
|
||||||
for(int j = 0; j < vcount; j++ )
|
for(int j = 0; j < vcount; j++ )
|
||||||
{
|
{
|
||||||
Qfloat t = results[j];
|
Qfloat t = results[j];
|
||||||
@ -1101,7 +1100,7 @@ void CvSVMKernel_ocl::calc_sigmoid( int vcount, const int row_idx, Qfloat* resul
|
|||||||
else
|
else
|
||||||
results[j] = (Qfloat)((e - 1.) / (e + 1.));
|
results[j] = (Qfloat)((e - 1.) / (e + 1.));
|
||||||
}
|
}
|
||||||
//FIXIT #endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CvSVM_OCL::CvSVM_OCL()
|
CvSVM_OCL::CvSVM_OCL()
|
||||||
|
@ -126,8 +126,6 @@ OCL_TEST_P(KNN, Accuracy)
|
|||||||
INSTANTIATE_TEST_CASE_P(OCL_ML, KNN, Combine(Values(6, 5), Values(Size(200, 400), Size(300, 600)),
|
INSTANTIATE_TEST_CASE_P(OCL_ML, KNN, Combine(Values(6, 5), Values(Size(200, 400), Size(300, 600)),
|
||||||
Values(4, 3), Values(false, true)));
|
Values(4, 3), Values(false, true)));
|
||||||
|
|
||||||
#ifdef HAVE_CLAMDBLAS // TODO does not work non-blas version of SVM
|
|
||||||
|
|
||||||
////////////////////////////////SVM/////////////////////////////////////////////////
|
////////////////////////////////SVM/////////////////////////////////////////////////
|
||||||
|
|
||||||
PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||||
@ -308,6 +306,4 @@ INSTANTIATE_TEST_CASE_P(OCL_ML, SVM_OCL, testing::Combine(
|
|||||||
Values(2, 3, 4)
|
Values(2, 3, 4)
|
||||||
));
|
));
|
||||||
|
|
||||||
#endif // HAVE_CLAMDBLAS
|
|
||||||
|
|
||||||
#endif // HAVE_OPENCL
|
#endif // HAVE_OPENCL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user