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
eacc2bc4
Commit
eacc2bc4
authored
Sep 30, 2018
by
Stilistik
Committed by
Tianqi Chen
Sep 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement tensorflow relational operators and related tests (#1714)
parent
47e57be4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletions
+41
-1
nnvm/python/nnvm/frontend/tensorflow.py
+15
-0
nnvm/tests/python/frontend/tensorflow/test_forward.py
+26
-1
No files found.
nnvm/python/nnvm/frontend/tensorflow.py
View file @
eacc2bc4
...
...
@@ -759,6 +759,15 @@ def _mean():
extras
=
{
'axis'
:
tuple
(
axis
.
asnumpy
())})(
inputs
[
0
],
attr
)
return
_impl
def
_broadcast
(
name
):
def
_impl
(
inputs
,
attr
,
params
):
op_name
=
_math_name_picker
(
name
)(
attr
)
return
AttrCvt
(
op_name
=
op_name
,
ignores
=
[
'name'
,
'Tidx'
]
)(
inputs
,
attr
)
return
_impl
# compatible operators that do NOT require any conversion.
_identity_list
=
[]
...
...
@@ -819,6 +828,12 @@ _convert_map = {
'Transpose'
:
_transpose
(),
'Tanh'
:
AttrCvt
(
'tanh'
),
'Mean'
:
_mean
(),
'Less'
:
_broadcast
(
'less'
),
'Greater'
:
_broadcast
(
'greater'
),
'LessEqual'
:
_broadcast
(
'less_equal'
),
'GreaterEqual'
:
_broadcast
(
'greater_equal'
),
'Equal'
:
_broadcast
(
'equal'
),
'NotEqual'
:
_broadcast
(
'not_equal'
),
}
# _convert_map_rnn defines maps of rnn operator name to
...
...
nnvm/tests/python/frontend/tensorflow/test_forward.py
View file @
eacc2bc4
...
...
@@ -378,7 +378,7 @@ def test_forward_reduce():
data
=
np
.
random
.
uniform
(
size
=
(
8
,
4
,
9
))
.
astype
(
'float32'
)
_test_reduce
(
tf
.
reduce_sum
,
data
=
data
)
_test_reduce
(
tf
.
reduce_sum
,
data
=
data
,
axis
=
0
)
_test_reduce
(
tf
.
reduce_sum
,
data
=
data
,
axis
=
(
0
,
1
))
_test_reduce
(
tf
.
reduce_sum
,
data
=
data
,
axis
=
(
0
,
1
))
#######################################################################
...
...
@@ -979,6 +979,28 @@ def test_forward_mean():
check_mean
((
10
,
8
,
16
,
32
),
axis
=
(
1
,
2
),
keepdims
=
True
)
#######################################################################
# Relational operators
# --------------------
def
_test_forward_rel_op
(
data
,
func
):
with
tf
.
Graph
()
.
as_default
():
in1
=
tf
.
placeholder
(
shape
=
data
[
0
]
.
shape
,
dtype
=
data
[
0
]
.
dtype
,
name
=
'in1'
)
in2
=
tf
.
placeholder
(
shape
=
data
[
1
]
.
shape
,
dtype
=
data
[
1
]
.
dtype
,
name
=
'in2'
)
op
=
func
(
in1
,
in2
,
name
=
'op'
)
out
=
tf
.
cast
(
op
,
tf
.
int32
,
name
=
'out1'
)
compare_tf_with_tvm
([
data
[
0
],
data
[
1
]],
[
'in1:0'
,
'in2:0'
],
'out1:0'
)
def
test_forward_rel_ops
():
t1
=
np
.
array
([[
1
,
2
,
3
],
[
4
,
5
,
6
],
[
7
,
8
,
9
]])
t2
=
np
.
array
([[
9
,
8
,
7
],
[
6
,
5
,
4
],
[
3
,
2
,
1
]])
_test_forward_rel_op
([
t1
,
t2
],
math_ops
.
less
)
_test_forward_rel_op
([
t1
,
t2
],
math_ops
.
greater
)
_test_forward_rel_op
([
t1
,
t2
],
math_ops
.
less_equal
)
_test_forward_rel_op
([
t1
,
t2
],
math_ops
.
greater_equal
)
_test_forward_rel_op
([
t1
,
t2
],
math_ops
.
equal
)
_test_forward_rel_op
([
t1
,
t2
],
math_ops
.
not_equal
)
#######################################################################
# Main
# ----
if
__name__
==
'__main__'
:
...
...
@@ -1030,3 +1052,6 @@ if __name__ == '__main__':
# Elementwise
test_forward_ceil
()
test_forward_floor
()
# Relational ops
test_forward_rel_ops
()
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