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
660a7098
Commit
660a7098
authored
Dec 06, 2019
by
Liubov Batanina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support Swish and Mish activations
parent
d99d1830
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
elementwise_layers.cpp
modules/dnn/src/layers/elementwise_layers.cpp
+11
-4
No files found.
modules/dnn/src/layers/elementwise_layers.cpp
View file @
660a7098
...
...
@@ -579,7 +579,7 @@ struct SwishFunctor
bool
supportBackend
(
int
backendId
,
int
)
{
return
backendId
==
DNN_BACKEND_OPENCV
||
backendId
==
DNN_BACKEND_HALIDE
;
backendId
==
DNN_BACKEND_HALIDE
||
backendId
==
DNN_BACKEND_INFERENCE_ENGINE_NGRAPH
;
;
}
void
apply
(
const
float
*
srcptr
,
float
*
dstptr
,
int
len
,
size_t
planeSize
,
int
cn0
,
int
cn1
)
const
...
...
@@ -640,7 +640,8 @@ struct SwishFunctor
#ifdef HAVE_DNN_NGRAPH
std
::
shared_ptr
<
ngraph
::
Node
>
initNgraphAPI
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
)
{
CV_Error
(
Error
::
StsNotImplemented
,
""
);
auto
sigmoid
=
std
::
make_shared
<
ngraph
::
op
::
Sigmoid
>
(
node
);
return
std
::
make_shared
<
ngraph
::
op
::
v1
::
Multiply
>
(
node
,
sigmoid
);
}
#endif // HAVE_DNN_NGRAPH
...
...
@@ -659,7 +660,7 @@ struct MishFunctor
bool
supportBackend
(
int
backendId
,
int
)
{
return
backendId
==
DNN_BACKEND_OPENCV
||
backendId
==
DNN_BACKEND_HALIDE
;
backendId
==
DNN_BACKEND_HALIDE
||
backendId
==
DNN_BACKEND_INFERENCE_ENGINE_NGRAPH
;
}
void
apply
(
const
float
*
srcptr
,
float
*
dstptr
,
int
len
,
size_t
planeSize
,
int
cn0
,
int
cn1
)
const
...
...
@@ -720,7 +721,13 @@ struct MishFunctor
#ifdef HAVE_DNN_NGRAPH
std
::
shared_ptr
<
ngraph
::
Node
>
initNgraphAPI
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
)
{
CV_Error
(
Error
::
StsNotImplemented
,
""
);
float
one
=
1.0
f
;
auto
constant
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
ngraph
::
element
::
f32
,
ngraph
::
Shape
{
1
},
&
one
);
auto
exp_node
=
std
::
make_shared
<
ngraph
::
op
::
v0
::
Exp
>
(
node
);
auto
sum
=
std
::
make_shared
<
ngraph
::
op
::
v1
::
Add
>
(
constant
,
exp_node
,
ngraph
::
op
::
AutoBroadcastType
::
NUMPY
);
auto
log_node
=
std
::
make_shared
<
ngraph
::
op
::
v0
::
Log
>
(
sum
);
auto
tanh_node
=
std
::
make_shared
<
ngraph
::
op
::
Tanh
>
(
log_node
);
return
std
::
make_shared
<
ngraph
::
op
::
v1
::
Multiply
>
(
node
,
tanh_node
);
}
#endif // HAVE_DNN_NGRAPH
...
...
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