Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
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
ngraph
Commits
e4bc7014
Unverified
Commit
e4bc7014
authored
Jul 22, 2019
by
Tomasz Dołbniak
Committed by
GitHub
Jul 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tomdol/pycapsule
parents
4ead8aef
e4955613
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
179 additions
and
3 deletions
+179
-3
ngraph.ops.rst
doc/sphinx/source/python_api/_autosummary/ngraph.ops.rst
+1
-0
__init__.py
python/ngraph/__init__.py
+1
-0
__init__.py
python/ngraph/impl/op/__init__.py
+1
-0
ops.py
python/ngraph/ops.py
+20
-2
elu.cpp
python/pyngraph/ops/elu.cpp
+30
-0
elu.hpp
python/pyngraph/ops/elu.hpp
+23
-0
elu.cpp
python/pyngraph/ops/fused/elu.cpp
+30
-0
regmodule_pyngraph_op.cpp
python/pyngraph/ops/regmodule_pyngraph_op.cpp
+1
-0
regmodule_pyngraph_op.hpp
python/pyngraph/ops/regmodule_pyngraph_op.hpp
+1
-0
setup.py
python/setup.py
+1
-0
test_ops_fused.py
python/test/ngraph/test_ops_fused.py
+69
-0
elu.cpp
src/ngraph/op/fused/elu.cpp
+1
-1
No files found.
doc/sphinx/source/python_api/_autosummary/ngraph.ops.rst
View file @
e4bc7014
...
...
@@ -32,6 +32,7 @@ ngraph.ops
cosh
divide
dot
elu
equal
exp
floor
...
...
python/ngraph/__init__.py
View file @
e4bc7014
...
...
@@ -45,6 +45,7 @@ from ngraph.ops import cos
from
ngraph.ops
import
cosh
from
ngraph.ops
import
divide
from
ngraph.ops
import
dot
from
ngraph.ops
import
elu
from
ngraph.ops
import
equal
from
ngraph.ops
import
exp
from
ngraph.ops
import
floor
...
...
python/ngraph/impl/op/__init__.py
View file @
e4bc7014
...
...
@@ -69,6 +69,7 @@ from _pyngraph.op import Cos
from
_pyngraph.op
import
Cosh
from
_pyngraph.op
import
Divide
from
_pyngraph.op
import
Dot
from
_pyngraph.op
import
Elu
from
_pyngraph.op
import
Equal
from
_pyngraph.op
import
Exp
from
_pyngraph.op
import
Floor
...
...
python/ngraph/ops.py
View file @
e4bc7014
...
...
@@ -22,7 +22,7 @@ from ngraph.impl import AxisSet, AxisVector, Coordinate, CoordinateDiff, Functio
from
ngraph.impl.op
import
Abs
,
Acos
,
Add
,
And
,
Asin
,
ArgMax
,
ArgMin
,
Atan
,
AvgPool
,
\
BatchNormTraining
,
BatchNormInference
,
Broadcast
,
Ceiling
,
Concat
,
Constant
,
Convert
,
\
Convolution
,
ConvolutionBackpropData
,
Cos
,
Cosh
,
Divide
,
Dot
,
Equal
,
Exp
,
Floor
,
\
Convolution
,
ConvolutionBackpropData
,
Cos
,
Cosh
,
Divide
,
Dot
,
E
lu
,
E
qual
,
Exp
,
Floor
,
\
GetOutputElement
,
Greater
,
GreaterEq
,
Less
,
LessEq
,
Log
,
LRN
,
Max
,
Maximum
,
MaxPool
,
\
Min
,
Minimum
,
Multiply
,
Negative
,
Not
,
NotEqual
,
OneHot
,
Or
,
Pad
,
Parameter
,
Product
,
\
Power
,
Relu
,
ReplaceSlice
,
Reshape
,
Reverse
,
Select
,
Sign
,
Sin
,
Sinh
,
Slice
,
Softmax
,
\
...
...
@@ -35,7 +35,7 @@ from ngraph.utils.decorators import nameable_op, binary_op, unary_op
from
ngraph.utils.input_validation
import
assert_list_of_ints
from
ngraph.utils.reduction
import
get_reduction_axes
from
ngraph.utils.types
import
NumericType
,
NumericData
,
TensorShape
,
make_constant_node
,
\
NodeInput
,
ScalarData
NodeInput
,
ScalarData
,
as_node
from
ngraph.utils.types
import
get_element_type
...
...
@@ -60,6 +60,24 @@ def constant(value, dtype=None, name=None): # type: (NumericData, NumericType,
return
make_constant_node
(
value
,
dtype
)
@nameable_op
def
elu
(
data
,
alpha
,
name
=
None
):
# type: (NodeInput, NodeInput, str) -> Node
"""Perform Exponential Linear Unit operation element-wise on data from input node.
Computes exponential linear: alpha * (exp(data) - 1) if < 0, data otherwise.
For more information refer to:
`Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)
<http://arxiv.org/abs/1511.07289>`_
:param data: Input tensor. One of: input node, array or scalar.
:param alpha: Multiplier for negative values. One of: input node or scalar value.
:param name: Optional output node name.
:return: The new node performing an ELU operation on its input data element-wise.
"""
return
Elu
(
as_node
(
data
),
as_node
(
alpha
))
# Unary ops
@unary_op
def
absolute
(
node
,
name
=
None
):
# type: (NodeInput, str) -> Node
...
...
python/pyngraph/ops/elu.cpp
0 → 100644
View file @
e4bc7014
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "ngraph/op/fused/elu.hpp"
#include "pyngraph/ops/elu.hpp"
namespace
py
=
pybind11
;
void
regclass_pyngraph_op_Elu
(
py
::
module
m
)
{
py
::
class_
<
ngraph
::
op
::
Elu
,
std
::
shared_ptr
<
ngraph
::
op
::
Elu
>
,
ngraph
::
op
::
Op
>
elu
(
m
,
"Elu"
);
elu
.
doc
()
=
"ngraph.impl.op.Elu wraps ngraph::op::Elu"
;
elu
.
def
(
py
::
init
<
const
std
::
shared_ptr
<
ngraph
::
Node
>&
,
const
std
::
shared_ptr
<
ngraph
::
Node
>&>
());
}
python/pyngraph/ops/elu.hpp
0 → 100644
View file @
e4bc7014
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <pybind11/pybind11.h>
namespace
py
=
pybind11
;
void
regclass_pyngraph_op_Elu
(
py
::
module
m
);
python/pyngraph/ops/fused/elu.cpp
0 → 100644
View file @
e4bc7014
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "ngraph/op/fused/elu.hpp"
#include "pyngraph/ops/fused/elu.hpp"
namespace
py
=
pybind11
;
void
regclass_pyngraph_op_Elu
(
py
::
module
m
)
{
py
::
class_
<
ngraph
::
op
::
Elu
,
std
::
shared_ptr
<
ngraph
::
op
::
Elu
>
,
ngraph
::
op
::
Op
>
elu
(
m
,
"Elu"
);
elu
.
doc
()
=
"ngraph.impl.op.Elu wraps ngraph::op::Elu"
;
elu
.
def
(
py
::
init
<
const
std
::
shared_ptr
<
ngraph
::
Node
>&
,
const
std
::
shared_ptr
<
ngraph
::
Node
>&>
());
}
python/pyngraph/ops/regmodule_pyngraph_op.cpp
View file @
e4bc7014
...
...
@@ -49,6 +49,7 @@ void regmodule_pyngraph_op(py::module m_op)
regclass_pyngraph_op_Cosh
(
m_op
);
regclass_pyngraph_op_Divide
(
m_op
);
regclass_pyngraph_op_Dot
(
m_op
);
regclass_pyngraph_op_Elu
(
m_op
);
regclass_pyngraph_op_Equal
(
m_op
);
regclass_pyngraph_op_Exp
(
m_op
);
regclass_pyngraph_op_Floor
(
m_op
);
...
...
python/pyngraph/ops/regmodule_pyngraph_op.hpp
View file @
e4bc7014
...
...
@@ -39,6 +39,7 @@
#include "pyngraph/ops/cosh.hpp"
#include "pyngraph/ops/divide.hpp"
#include "pyngraph/ops/dot.hpp"
#include "pyngraph/ops/elu.hpp"
#include "pyngraph/ops/equal.hpp"
#include "pyngraph/ops/exp.hpp"
#include "pyngraph/ops/floor.hpp"
...
...
python/setup.py
View file @
e4bc7014
...
...
@@ -179,6 +179,7 @@ sources = [
'pyngraph/ops/ceiling.cpp'
,
'pyngraph/ops/divide.cpp'
,
'pyngraph/ops/dot.cpp'
,
'pyngraph/ops/elu.cpp'
,
'pyngraph/ops/equal.cpp'
,
'pyngraph/ops/exp.cpp'
,
'pyngraph/ops/floor.cpp'
,
...
...
python/test/ngraph/test_ops_fused.py
0 → 100644
View file @
e4bc7014
# ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ******************************************************************************
import
numpy
as
np
import
ngraph
as
ng
from
test.ngraph.util
import
get_runtime
def
test_elu_operator
():
runtime
=
get_runtime
()
data_shape
=
[
2
,
2
]
alpha_shape
=
[
2
]
parameter_data
=
ng
.
parameter
(
data_shape
,
name
=
'Data'
,
dtype
=
np
.
float32
)
parameter_alpha
=
ng
.
parameter
(
alpha_shape
,
name
=
'Alpha'
,
dtype
=
np
.
float32
)
model
=
ng
.
elu
(
parameter_data
,
parameter_alpha
)
computation
=
runtime
.
computation
(
model
,
parameter_data
,
parameter_alpha
)
value_data
=
np
.
array
([[
-
5
,
1
],
[
-
2
,
3
]],
dtype
=
np
.
float32
)
value_alpha
=
np
.
array
([
3
,
3
],
dtype
=
np
.
float32
)
result
=
computation
(
value_data
,
value_alpha
)
expected
=
np
.
array
([[
-
2.9797862
,
1.
],
[
-
2.5939941
,
3.
]],
dtype
=
np
.
float32
)
assert
np
.
allclose
(
result
,
expected
)
def
test_elu_operator_with_scalar_and_array
():
runtime
=
get_runtime
()
data_value
=
np
.
array
([[
-
5
,
1
],
[
-
2
,
3
]],
dtype
=
np
.
float32
)
alpha_value
=
np
.
float32
(
3
)
model
=
ng
.
elu
(
data_value
,
alpha_value
)
computation
=
runtime
.
computation
(
model
)
result
=
computation
()
expected
=
np
.
array
([[
-
2.9797862
,
1.
],
[
-
2.5939941
,
3.
]],
dtype
=
np
.
float32
)
assert
np
.
allclose
(
result
,
expected
)
def
test_elu_operator_with_scalar
():
runtime
=
get_runtime
()
data_value
=
np
.
array
([[
-
5
,
1
],
[
-
2
,
3
]],
dtype
=
np
.
float32
)
alpha_value
=
np
.
float32
(
3
)
data_shape
=
[
2
,
2
]
parameter_data
=
ng
.
parameter
(
data_shape
,
name
=
'Data'
,
dtype
=
np
.
float32
)
model
=
ng
.
elu
(
parameter_data
,
alpha_value
)
computation
=
runtime
.
computation
(
model
,
parameter_data
)
result
=
computation
(
data_value
)
expected
=
np
.
array
([[
-
2.9797862
,
1.
],
[
-
2.5939941
,
3.
]],
dtype
=
np
.
float32
)
assert
np
.
allclose
(
result
,
expected
)
src/ngraph/op/fused/elu.cpp
View file @
e4bc7014
...
...
@@ -39,7 +39,7 @@ NodeVector op::Elu::decompose_op() const
auto
data
=
get_argument
(
0
);
auto
alpha_node
=
get_argument
(
1
);
alpha_node
=
ngraph
::
op
::
make_broadcast_node
(
alpha_node
,
data
->
get_shape
());
alpha_node
=
ngraph
::
op
::
numpy_style_broadcast
(
alpha_node
,
data
->
get_shape
());
shared_ptr
<
ngraph
::
Node
>
zero_node
=
builder
::
make_constant
(
data
->
get_element_type
(),
data
->
get_shape
(),
0
);
...
...
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