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
dfa753c6
Commit
dfa753c6
authored
May 14, 2019
by
Liubov Batanina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support OCV backend
parent
dadb1473
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
batch_norm_layer.cpp
modules/dnn/src/layers/batch_norm_layer.cpp
+12
-10
test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+2
-2
test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+2
-2
No files found.
modules/dnn/src/layers/batch_norm_layer.cpp
View file @
dfa753c6
...
...
@@ -153,7 +153,7 @@ public:
virtual
bool
supportBackend
(
int
backendId
)
CV_OVERRIDE
{
return
(
backendId
==
DNN_BACKEND_OPENCV
&&
(
dims
==
4
||
dims
==
2
)
)
||
return
(
backendId
==
DNN_BACKEND_OPENCV
)
||
(
backendId
==
DNN_BACKEND_HALIDE
&&
haveHalide
())
||
(
backendId
==
DNN_BACKEND_INFERENCE_ENGINE
&&
haveInfEngine
()
&&
(
preferableTarget
==
DNN_TARGET_CPU
||
dims
==
4
));
}
...
...
@@ -181,11 +181,12 @@ public:
}
UMat
&
inpBlob
=
inputs
[
0
];
CV_Assert
(
inpBlob
.
dims
==
2
||
inpBlob
.
dims
==
4
);
int
groups
=
inpBlob
.
size
[
0
];
int
channels
=
inpBlob
.
size
[
1
];
int
rows
=
inpBlob
.
dims
>
2
?
inpBlob
.
size
[
2
]
:
1
;
int
cols
=
inpBlob
.
dims
>
2
?
inpBlob
.
size
[
3
]
:
1
;
int
planeSize
=
1
;
for
(
size_t
i
=
2
;
i
<
inpBlob
.
dims
;
i
++
)
{
planeSize
*=
inpBlob
.
size
[
i
];
}
String
opts
=
(
use_half
)
?
" -DDtype=half"
:
" -DDtype=float"
;
for
(
size_t
ii
=
0
;
ii
<
outputs
.
size
();
ii
++
)
...
...
@@ -199,7 +200,7 @@ public:
}
else
{
MatShape
s
=
shape
(
groups
*
channels
,
rows
*
cols
);
MatShape
s
=
shape
(
groups
*
channels
,
planeSize
);
UMat
src
=
inputs
[
ii
].
reshape
(
1
,
s
.
size
(),
&
s
[
0
]);
UMat
dst
=
outputs
[
ii
].
reshape
(
1
,
s
.
size
(),
&
s
[
0
]);
int
number
=
(
s
[
1
]
%
8
==
0
)
?
8
:
((
s
[
1
]
%
4
==
0
)
?
4
:
1
);
...
...
@@ -251,9 +252,10 @@ public:
CV_Assert
(
inputs
.
size
()
==
1
);
Mat
&
inpBlob
=
inputs
[
0
];
CV_Assert
(
inpBlob
.
dims
==
2
||
inpBlob
.
dims
==
4
);
int
rows
=
inpBlob
.
dims
>
2
?
inpBlob
.
size
[
2
]
:
1
;
int
cols
=
inpBlob
.
dims
>
2
?
inpBlob
.
size
[
3
]
:
1
;
int
planeSize
=
1
;
for
(
size_t
i
=
2
;
i
<
inpBlob
.
dims
;
i
++
)
{
planeSize
*=
inpBlob
.
size
[
i
];
}
for
(
size_t
ii
=
0
;
ii
<
outputs
.
size
();
ii
++
)
{
...
...
@@ -265,8 +267,8 @@ public:
{
float
w
=
weights_
.
at
<
float
>
(
n
);
float
b
=
bias_
.
at
<
float
>
(
n
);
Mat
inpBlobPlane
(
rows
,
cols
,
CV_32F
,
inpBlob
.
ptr
<
float
>
(
num
,
n
));
Mat
outBlobPlane
(
rows
,
cols
,
CV_32F
,
outBlob
.
ptr
<
float
>
(
num
,
n
));
Mat
inpBlobPlane
(
1
,
planeSize
,
CV_32F
,
inpBlob
.
ptr
<
float
>
(
num
,
n
));
Mat
outBlobPlane
(
1
,
planeSize
,
CV_32F
,
outBlob
.
ptr
<
float
>
(
num
,
n
));
inpBlobPlane
.
convertTo
(
outBlobPlane
,
CV_32F
,
w
,
b
);
}
}
...
...
modules/dnn/test/test_onnx_importer.cpp
View file @
dfa753c6
...
...
@@ -169,8 +169,8 @@ TEST_P(Test_ONNX_layers, BatchNormalization)
TEST_P
(
Test_ONNX_layers
,
BatchNormalization3D
)
{
if
(
backend
!=
DNN_BACKEND_INFERENCE_ENGINE
||
target
!=
DNN_TARGET_CPU
)
throw
SkipTestException
(
"Only DLIE backend on CPU is supported
"
);
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
!=
DNN_TARGET_CPU
)
throw
SkipTestException
(
"
"
);
testONNXModels
(
"batch_norm_3d"
);
}
...
...
modules/dnn/test/test_tf_importer.cpp
View file @
dfa753c6
...
...
@@ -190,8 +190,8 @@ TEST_P(Test_TensorFlow_layers, batch_norm)
TEST_P
(
Test_TensorFlow_layers
,
batch_norm3D
)
{
if
(
backend
!=
DNN_BACKEND_INFERENCE_ENGINE
||
target
!=
DNN_TARGET_CPU
)
throw
SkipTestException
(
"Only DLIE backend on CPU is supported
"
);
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
!=
DNN_TARGET_CPU
)
throw
SkipTestException
(
"
"
);
runTensorFlowNet
(
"batch_norm3d"
);
}
...
...
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