Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
8beb514e
Commit
8beb514e
authored
Sep 30, 2013
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ocl: merge with upstream/2.4
parent
16adbda4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
28 deletions
+26
-28
arithm.cpp
modules/ocl/src/arithm.cpp
+3
-3
svm.cpp
modules/ocl/src/svm.cpp
+17
-19
test_matrix_operation.cpp
modules/ocl/test/test_matrix_operation.cpp
+6
-6
No files found.
modules/ocl/src/arithm.cpp
View file @
8beb514e
...
...
@@ -614,7 +614,7 @@ double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType)
CV_Assert
(
!
src1
.
empty
());
CV_Assert
(
src2
.
empty
()
||
(
src1
.
type
()
==
src2
.
type
()
&&
src1
.
size
()
==
src2
.
size
()));
if
(
!
src1
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src1
.
depth
()
==
CV_64F
)
if
(
!
src1
.
clCxt
->
supportsFeature
(
FEATURE_
CL_DOUBLE
)
&&
src1
.
depth
()
==
CV_64F
)
{
CV_Error
(
CV_GpuNotSupported
,
"Selected device doesn't support double"
);
}
...
...
@@ -1261,7 +1261,7 @@ int cv::ocl::countNonZero(const oclMat &src)
CV_Error
(
CV_GpuNotSupported
,
"selected device doesn't support double"
);
}
size_t
groupnum
=
src
.
clCxt
->
computeUnits
()
;
size_t
groupnum
=
src
.
clCxt
->
getDeviceInfo
().
maxComputeUnits
;
CV_Assert
(
groupnum
!=
0
);
int
dbsize
=
groupnum
;
...
...
@@ -1708,7 +1708,7 @@ void cv::ocl::pow(const oclMat &x, double p, oclMat &y)
void
cv
::
ocl
::
setIdentity
(
oclMat
&
src
,
const
Scalar
&
scalar
)
{
Context
*
clCxt
=
Context
::
getContext
();
if
(
!
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
if
(
!
clCxt
->
supportsFeature
(
FEATURE_
CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
{
CV_Error
(
CV_GpuNotSupported
,
"Selected device doesn't support double
\r\n
"
);
return
;
...
...
modules/ocl/src/svm.cpp
View file @
8beb514e
...
...
@@ -43,9 +43,13 @@
//
//M*/
#include "precomp.hpp"
#include "opencl_kernels.hpp"
using
namespace
cv
;
using
namespace
ocl
;
namespace
cv
{
namespace
ocl
{
#if 1
typedef
float
Qfloat
;
#define QFLOAT_TYPE CV_32F
...
...
@@ -54,14 +58,6 @@ typedef double Qfloat;
#define QFLOAT_TYPE CV_64F
#endif
namespace
cv
{
namespace
ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern
const
char
*
svm
;
}
}
class
CvSVMKernel_ocl
:
public
CvSVMKernel
{
public
:
...
...
@@ -612,7 +608,7 @@ static void matmul_rbf(oclMat& src, oclMat& src_e, oclMat& dst, int src_rows, in
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src2_cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
width
));
float
gamma
=
0.0
f
;
if
(
!
Context
::
getContext
()
->
supportsFeature
(
Context
::
CL_DOUBLE
))
if
(
!
Context
::
getContext
()
->
supportsFeature
(
FEATURE_
CL_DOUBLE
))
{
gamma
=
(
float
)
gamma1
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_float
),
(
void
*
)
&
gamma
));
...
...
@@ -748,7 +744,7 @@ float CvSVM_OCL::predict(const CvMat* samples, CV_OUT CvMat* results) const
if
(
params
.
kernel_type
==
CvSVM
::
RBF
)
{
sv_
.
upload
(
sv_temp
);
if
(
!
Context
::
getContext
()
->
supportsFeature
(
Context
::
CL_DOUBLE
))
if
(
!
Context
::
getContext
()
->
supportsFeature
(
FEATURE_
CL_DOUBLE
))
{
dst
=
oclMat
(
sample_count
,
sv_total
,
CV_32FC1
);
}
...
...
@@ -886,7 +882,7 @@ bool CvSVMSolver_ocl::solve_generic( CvSVMSolutionInfo& si )
if
(
params
->
kernel_type
==
CvSVM
::
RBF
)
{
src_e
=
src
;
if
(
!
Context
::
getContext
()
->
supportsFeature
(
Context
::
CL_DOUBLE
))
if
(
!
Context
::
getContext
()
->
supportsFeature
(
FEATURE_
CL_DOUBLE
))
{
dst
=
oclMat
(
sample_count
,
sample_count
,
CV_32FC1
);
}
...
...
@@ -1053,7 +1049,7 @@ void CvSVMKernel_ocl::calc( int vcount, const int row_idx, Qfloat* results, Mat&
//int j;
(
this
->*
calc_func_ocl
)(
vcount
,
row_idx
,
results
,
src
);
#if defined HAVE_CLAMDBLAS
// FIXIT
#if defined HAVE_CLAMDBLAS
const
Qfloat
max_val
=
(
Qfloat
)(
FLT_MAX
*
1e-3
);
int
j
;
for
(
j
=
0
;
j
<
vcount
;
j
++
)
...
...
@@ -1063,7 +1059,7 @@ void CvSVMKernel_ocl::calc( int vcount, const int row_idx, Qfloat* results, Mat&
results
[
j
]
=
max_val
;
}
}
#endif
// FIXIT
#endif
}
bool
CvSVMKernel_ocl
::
create
(
const
CvSVMParams
*
_params
,
Calc_ocl
_calc_func
,
Calc
_calc_func1
)
{
...
...
@@ -1115,7 +1111,7 @@ void CvSVMKernel_ocl::calc_non_rbf_base( int vcount, const int row_idx, Qfloat*
}
void
CvSVMKernel_ocl
::
calc_rbf
(
int
vcount
,
const
int
row_idx
,
Qfloat
*
results
,
Mat
&
src
)
{
if
(
!
Context
::
getContext
()
->
supportsFeature
(
Context
::
CL_DOUBLE
))
if
(
!
Context
::
getContext
()
->
supportsFeature
(
FEATURE_
CL_DOUBLE
))
{
for
(
int
m
=
0
;
m
<
vcount
;
m
++
)
{
...
...
@@ -1140,14 +1136,14 @@ void CvSVMKernel_ocl::calc_poly( int vcount, const int row_idx, Qfloat* results,
calc_non_rbf_base
(
vcount
,
row_idx
,
results
,
src
);
#if defined HAVE_CLAMDBLAS
//FIXIT
#if defined HAVE_CLAMDBLAS
CvMat
R
=
cvMat
(
1
,
vcount
,
QFLOAT_TYPE
,
results
);
if
(
vcount
>
0
)
{
cvPow
(
&
R
,
&
R
,
params
->
degree
);
}
#endif
//FIXIT
#endif
}
...
...
@@ -1155,11 +1151,11 @@ void CvSVMKernel_ocl::calc_sigmoid( int vcount, const int row_idx, Qfloat* resul
{
calc_non_rbf_base
(
vcount
,
row_idx
,
results
,
src
);
// TODO: speedup this
#if defined HAVE_CLAMDBLAS
//FIXIT
#if defined HAVE_CLAMDBLAS
for
(
int
j
=
0
;
j
<
vcount
;
j
++
)
{
Qfloat
t
=
results
[
j
];
double
e
=
exp
(
-
fabs
(
t
));
double
e
=
::
exp
(
-
fabs
(
t
));
if
(
t
>
0
)
{
results
[
j
]
=
(
Qfloat
)((
1.
-
e
)
/
(
1.
+
e
));
...
...
@@ -1169,7 +1165,7 @@ void CvSVMKernel_ocl::calc_sigmoid( int vcount, const int row_idx, Qfloat* resul
results
[
j
]
=
(
Qfloat
)((
e
-
1.
)
/
(
e
+
1.
));
}
}
#endif
//FIXIT
#endif
}
CvSVM_OCL
::
CvSVM_OCL
()
{
...
...
@@ -1199,3 +1195,5 @@ void CvSVM_OCL::create_solver( )
{
solver
=
new
CvSVMSolver_ocl
(
&
params
);
}
}
}
modules/ocl/test/test_matrix_operation.cpp
View file @
8beb514e
...
...
@@ -132,7 +132,7 @@ typedef ConvertToTestBase ConvertTo;
TEST_P
(
ConvertTo
,
Accuracy
)
{
if
((
src_depth
==
CV_64F
||
dst_depth
==
CV_64F
)
&&
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
Context
::
CL_DOUBLE
))
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
FEATURE_
CL_DOUBLE
))
{
return
;
// returns silently
}
...
...
@@ -228,7 +228,7 @@ typedef CopyToTestBase CopyTo;
TEST_P
(
CopyTo
,
Without_mask
)
{
if
((
src
.
depth
()
==
CV_64F
)
&&
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
Context
::
CL_DOUBLE
))
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
FEATURE_
CL_DOUBLE
))
{
return
;
// returns silently
}
...
...
@@ -246,7 +246,7 @@ TEST_P(CopyTo, Without_mask)
TEST_P
(
CopyTo
,
With_mask
)
{
if
(
src
.
depth
()
==
CV_64F
&&
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
Context
::
CL_DOUBLE
))
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
FEATURE_
CL_DOUBLE
))
{
return
;
// returns silently
}
...
...
@@ -342,7 +342,7 @@ typedef SetToTestBase SetTo;
TEST_P
(
SetTo
,
Without_mask
)
{
if
(
depth
==
CV_64F
&&
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
Context
::
CL_DOUBLE
))
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
FEATURE_
CL_DOUBLE
))
{
return
;
// returns silently
}
...
...
@@ -360,7 +360,7 @@ TEST_P(SetTo, Without_mask)
TEST_P
(
SetTo
,
With_mask
)
{
if
(
depth
==
CV_64F
&&
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
Context
::
CL_DOUBLE
))
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
FEATURE_
CL_DOUBLE
))
{
return
;
// returns silently
}
...
...
@@ -430,7 +430,7 @@ PARAM_TEST_CASE(convertC3C4, MatType, bool)
TEST_P
(
convertC3C4
,
Accuracy
)
{
if
(
depth
==
CV_64F
&&
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
Context
::
CL_DOUBLE
))
!
cv
::
ocl
::
Context
::
getContext
()
->
supportsFeature
(
cv
::
ocl
::
FEATURE_
CL_DOUBLE
))
{
return
;
// returns silently
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment