Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
eec3648a
Commit
eec3648a
authored
Oct 05, 2018
by
Meghan Cowan
Committed by
Tianqi Chen
Oct 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RELAY] Add sigmoid relay operator (#1836)
parent
b90620ea
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
0 deletions
+45
-0
docs/langref/relay_op.rst
+2
-0
python/tvm/relay/op/tensor.py
+16
-0
src/relay/op/tensor/unary.cc
+11
-0
tests/python/relay/test_op_level1.py
+16
-0
No files found.
docs/langref/relay_op.rst
View file @
eec3648a
...
...
@@ -25,6 +25,7 @@ This level enables fully connected multi-layer perceptron.
tvm.relay.log
tvm.relay.sqrt
tvm.relay.exp
tvm.relay.sigmoid
tvm.relay.add
tvm.relay.expand_dims
...
...
@@ -61,6 +62,7 @@ Level 1 Definitions
.. autofunction:: tvm.relay.log
.. autofunction:: tvm.relay.sqrt
.. autofunction:: tvm.relay.exp
.. autofunction:: tvm.relay.sigmoid
.. autofunction:: tvm.relay.add
...
...
python/tvm/relay/op/tensor.py
View file @
eec3648a
...
...
@@ -60,6 +60,22 @@ def sqrt(data):
return
_make
.
sqrt
(
data
)
def
sigmoid
(
data
):
"""Compute elementwise sigmoid of data.
Parameters
----------
data : relay.Expr
The input data
Returns
-------
result : relay.Expr
The computed result.
"""
return
_make
.
sigmoid
(
data
)
def
add
(
lhs
,
rhs
):
"""Addition with numpy-style broadcasting.
...
...
src/relay/op/tensor/unary.cc
View file @
eec3648a
...
...
@@ -65,6 +65,17 @@ RELAY_REGISTER_UNARY_OP("sqrt")
.
add_type_rel
(
"Identity"
,
IdentityRel
);
RELAY_REGISTER_UNARY_OP
(
"sigmoid"
)
.
describe
(
R"code(Returns the sigmoid input array, computed element-wise.
.. math::
sigmoid(x)
)code"
TVM_ADD_FILELINE
)
.
set_support_level
(
1
)
.
add_type_rel
(
"Identity"
,
IdentityRel
);
// Concat
TVM_REGISTER_API
(
"relay.op._make.concat"
)
.
set_body_typed
<
Expr
(
Expr
)
>
([](
Expr
tuple
)
{
...
...
tests/python/relay/test_op_level1.py
View file @
eec3648a
...
...
@@ -16,5 +16,21 @@ def test_expand_dims_infer_type():
(
n
,
t
,
1
,
100
),
"float32"
)
def
test_unary_op
():
for
op
in
[
relay
.
exp
,
relay
.
log
,
relay
.
sqrt
,
relay
.
sigmoid
]:
ib
=
relay
.
ir_builder
.
IRBuilder
()
x
=
ib
.
param
(
"x"
,
relay
.
TensorType
((
10
,
4
),
"int32"
))
with
ib
.
function
(
x
)
as
func
:
ib
.
ret
(
op
(
x
.
var
))
ib
.
ret
(
func
)
func
=
relay
.
ir_pass
.
infer_type
(
ib
.
env
,
func
.
to_func
())
ftype
=
func
.
checked_type
()
assert
ftype
.
ret_type
==
relay
.
TensorType
((
10
,
4
),
"int32"
)
if
__name__
==
"__main__"
:
test_expand_dims_infer_type
()
test_unary_op
()
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