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
3a4d4080
Commit
3a4d4080
authored
Jan 01, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed overflow for cv::norm NORM_L2
parent
1c3bfae2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
10 deletions
+12
-10
perf_arithm.cpp
modules/core/perf/opencl/perf_arithm.cpp
+4
-4
reduce.cl
modules/core/src/opencl/reduce.cl
+1
-1
stat.cpp
modules/core/src/stat.cpp
+6
-4
test_arithm.cpp
modules/core/test/ocl/test_arithm.cpp
+1
-1
No files found.
modules/core/perf/opencl/perf_arithm.cpp
View file @
3a4d4080
...
...
@@ -651,13 +651,13 @@ OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity,
typedef
Size_MatType
MeanStdDevFixture
;
OCL_PERF_TEST_P
(
MeanStdDevFixture
,
DISABLED_
MeanStdDev
,
OCL_PERF_TEST_P
(
MeanStdDevFixture
,
MeanStdDev
,
::
testing
::
Combine
(
OCL_PERF_ENUM
(
OCL_SIZE_1
,
OCL_SIZE_2
,
OCL_SIZE_3
),
OCL_TEST_TYPES
))
{
const
Size_MatType_t
params
=
GetParam
();
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
);
const
double
eps
=
1
e-5
;
const
double
eps
=
2
e-5
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
...
...
@@ -687,7 +687,7 @@ CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
typedef
std
::
tr1
::
tuple
<
Size
,
MatType
,
NormType
>
NormParams
;
typedef
TestBaseWithParam
<
NormParams
>
NormFixture
;
OCL_PERF_TEST_P
(
NormFixture
,
DISABLED_
Norm
,
OCL_PERF_TEST_P
(
NormFixture
,
Norm
,
::
testing
::
Combine
(
OCL_PERF_ENUM
(
OCL_SIZE_1
,
OCL_SIZE_2
,
OCL_SIZE_3
),
OCL_TEST_TYPES
,
NormType
::
all
()))
{
const
NormParams
params
=
GetParam
();
...
...
@@ -703,7 +703,7 @@ OCL_PERF_TEST_P(NormFixture, DISABLED_Norm,
OCL_TEST_CYCLE
()
res
=
cv
::
norm
(
src1
,
src2
,
normType
);
SANITY_CHECK
(
res
,
1e-
6
,
ERROR_RELATIVE
);
SANITY_CHECK
(
res
,
1e-
5
,
ERROR_RELATIVE
);
}
///////////// Repeat ////////////////////////
...
...
modules/core/src/opencl/reduce.cl
View file @
3a4d4080
...
...
@@ -88,7 +88,7 @@
#define REDUCE_GLOBAL \
accumulator += src[0] == zero ? zero : one
#define SET_LOCAL_1 \
localmem[lid] = accumulator
localmem[lid] = accumulator
#define REDUCE_LOCAL_1 \
localmem[lid - WGS2_ALIGNED] += accumulator
#define REDUCE_LOCAL_2 \
...
...
modules/core/src/stat.cpp
View file @
3a4d4080
...
...
@@ -479,7 +479,8 @@ static bool ocl_sum( InputArray _src, Scalar & res, int sum_op )
int
dbsize
=
ocl
::
Device
::
getDefault
().
maxComputeUnits
();
size_t
wgs
=
ocl
::
Device
::
getDefault
().
maxWorkGroupSize
();
int
ddepth
=
std
::
max
(
CV_32S
,
depth
),
dtype
=
CV_MAKE_TYPE
(
ddepth
,
cn
);
int
ddepth
=
std
::
max
(
sum_op
==
OCL_OP_SUM_SQR
?
CV_32F
:
CV_32S
,
depth
),
dtype
=
CV_MAKE_TYPE
(
ddepth
,
cn
);
int
wgs2_aligned
=
1
;
while
(
wgs2_aligned
<
(
int
)
wgs
)
...
...
@@ -501,7 +502,7 @@ static bool ocl_sum( InputArray _src, Scalar & res, int sum_op )
dbsize
,
ocl
::
KernelArg
::
PtrWriteOnly
(
db
));
size_t
globalsize
=
dbsize
*
wgs
;
if
(
k
.
run
(
1
,
&
globalsize
,
&
wgs
,
tru
e
))
if
(
k
.
run
(
1
,
&
globalsize
,
&
wgs
,
fals
e
))
{
typedef
Scalar
(
*
part_sum
)(
Mat
m
);
part_sum
funcs
[
3
]
=
{
ocl_part_sum
<
int
>
,
ocl_part_sum
<
float
>
,
ocl_part_sum
<
double
>
},
...
...
@@ -1927,8 +1928,9 @@ static bool ocl_norm( InputArray _src, int normType, double & result )
Scalar
s
;
bool
unstype
=
depth
==
CV_8U
||
depth
==
CV_16U
;
ocl_sum
(
src
.
reshape
(
1
),
s
,
normType
==
NORM_L2
?
OCL_OP_SUM_SQR
:
(
unstype
?
OCL_OP_SUM
:
OCL_OP_SUM_ABS
)
);
if
(
!
ocl_sum
(
src
.
reshape
(
1
),
s
,
normType
==
NORM_L2
?
OCL_OP_SUM_SQR
:
(
unstype
?
OCL_OP_SUM
:
OCL_OP_SUM_ABS
))
)
return
false
;
result
=
normType
==
NORM_L1
?
s
[
0
]
:
std
::
sqrt
(
s
[
0
]);
}
...
...
modules/core/test/ocl/test_arithm.cpp
View file @
3a4d4080
...
...
@@ -1355,7 +1355,7 @@ OCL_TEST_P(ScaleAdd, Mat)
OCL_OFF
(
cv
::
scaleAdd
(
src1_roi
,
val
[
0
],
src2_roi
,
dst1_roi
));
OCL_ON
(
cv
::
scaleAdd
(
usrc1_roi
,
val
[
0
],
usrc2_roi
,
udst1_roi
));
Near
(
depth
<=
CV_32S
?
1
:
1e-
6
);
Near
(
depth
<=
CV_32S
?
1
:
1e-
3
);
}
}
...
...
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