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
7c1c97d2
Commit
7c1c97d2
authored
Jun 10, 2019
by
Alexander Pivovarov
Committed by
Yao Wang
Jun 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LOGISTIC operator to relay tflite frontend (#3313)
parent
c4245e3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
python/tvm/relay/frontend/tflite.py
+18
-0
tests/python/frontend/tflite/test_forward.py
+17
-0
No files found.
python/tvm/relay/frontend/tflite.py
View file @
7c1c97d2
...
...
@@ -67,6 +67,7 @@ class OperatorConverter(object):
'MUL'
:
self
.
convert_mul
,
'FULLY_CONNECTED'
:
self
.
convert_fully_connected
,
'PAD'
:
self
.
convert_pad
,
'LOGISTIC'
:
self
.
convert_logistic
,
}
def
check_unsupported_ops
(
self
):
...
...
@@ -218,6 +219,23 @@ class OperatorConverter(object):
return
out
def
convert_logistic
(
self
,
op
):
"""Convert TFLite LOGISTIC"""
try
:
from
tflite.Operator
import
Operator
except
ImportError
:
raise
ImportError
(
"The tflite package must be installed"
)
assert
isinstance
(
op
,
Operator
)
input_tensors
=
self
.
get_input_tensors
(
op
)
assert
len
(
input_tensors
)
==
1
,
"input tensors length should be 1"
input_tensor
=
input_tensors
[
0
]
in_expr
=
self
.
get_expr
(
input_tensor
.
tensor_idx
)
out
=
_op
.
sigmoid
(
in_expr
)
return
out
def
convert_softmax
(
self
,
op
):
"""Convert TFLite softmax"""
try
:
...
...
tests/python/frontend/tflite/test_forward.py
View file @
7c1c97d2
...
...
@@ -424,6 +424,22 @@ def test_forward_pad():
#######################################################################
# Logistic
# --------
def
_test_logistic
(
data
):
""" One iteration of LOGISTIC """
with
tf
.
Graph
()
.
as_default
():
in_data
=
array_ops
.
placeholder
(
shape
=
data
.
shape
,
dtype
=
data
.
dtype
)
out
=
math_ops
.
sigmoid
(
in_data
)
compare_tflite_with_tvm
(
data
,
'Placeholder:0'
,
[
in_data
],
[
out
])
def
test_forward_logistic
():
""" LOGISTIC """
_test_logistic
(
np
.
arange
(
6.0
,
dtype
=
np
.
float32
)
.
reshape
((
1
,
6
)))
#######################################################################
# Softmax
# -------
...
...
@@ -563,6 +579,7 @@ if __name__ == '__main__':
# NN
test_forward_convolution
()
test_forward_logistic
()
test_forward_pooling
()
test_forward_softmax
()
test_forward_fully_connected
()
...
...
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