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
923b4a26
Unverified
Commit
923b4a26
authored
Mar 12, 2020
by
ANSHUMAN TRIPATHY
Committed by
GitHub
Mar 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[1] Test case modified for int type (#5012)
parent
173b4fc4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
8 deletions
+30
-8
tests/python/relay/test_op_level4.py
+30
-8
No files found.
tests/python/relay/test_op_level4.py
View file @
923b4a26
...
...
@@ -88,12 +88,9 @@ def test_cmp_type():
tvm
.
testing
.
assert_allclose
(
op_res
.
asnumpy
(),
ref_res
)
def
test_binary_int_broadcast
():
def
test_binary_int_broadcast
_1
():
for
op
,
ref
in
[(
relay
.
right_shift
,
np
.
right_shift
),
(
relay
.
left_shift
,
np
.
left_shift
),
(
relay
.
mod
,
np
.
mod
),
(
relay
.
maximum
,
np
.
maximum
),
(
relay
.
minimum
,
np
.
minimum
)]:
(
relay
.
left_shift
,
np
.
left_shift
)]:
x
=
relay
.
var
(
"x"
,
relay
.
TensorType
((
10
,
4
),
"int32"
))
y
=
relay
.
var
(
"y"
,
relay
.
TensorType
((
5
,
10
,
1
),
"int32"
))
z
=
op
(
x
,
y
)
...
...
@@ -105,8 +102,8 @@ def test_binary_int_broadcast():
y_shape
=
(
5
,
10
,
1
)
t1
=
relay
.
TensorType
(
x_shape
,
'int32'
)
t2
=
relay
.
TensorType
(
y_shape
,
'int32'
)
x_data
=
np
.
random
.
rand
(
*
x_shape
)
.
astype
(
t1
.
dtype
)
y_data
=
np
.
random
.
rand
(
*
y_shape
)
.
astype
(
t2
.
dtype
)
x_data
=
np
.
random
.
randint
(
1
,
10000
,
size
=
(
x_shape
)
)
.
astype
(
t1
.
dtype
)
y_data
=
np
.
random
.
randint
(
1
,
31
,
size
=
(
y_shape
)
)
.
astype
(
t2
.
dtype
)
func
=
relay
.
Function
([
x
,
y
],
z
)
ref_res
=
ref
(
x_data
,
y_data
)
...
...
@@ -115,6 +112,30 @@ def test_binary_int_broadcast():
op_res
=
intrp
.
evaluate
(
func
)(
x_data
,
y_data
)
tvm
.
testing
.
assert_allclose
(
op_res
.
asnumpy
(),
ref_res
)
def
test_binary_int_broadcast_2
():
for
op
,
ref
in
[(
relay
.
maximum
,
np
.
maximum
),
(
relay
.
minimum
,
np
.
minimum
),
(
relay
.
mod
,
np
.
mod
)]:
x
=
relay
.
var
(
"x"
,
relay
.
TensorType
((
10
,
4
),
"int32"
))
y
=
relay
.
var
(
"y"
,
relay
.
TensorType
((
5
,
10
,
1
),
"int32"
))
z
=
op
(
x
,
y
)
zz
=
run_infer_type
(
z
)
assert
zz
.
checked_type
==
relay
.
TensorType
((
5
,
10
,
4
),
"int32"
)
if
ref
is
not
None
:
x_shape
=
(
10
,
4
)
y_shape
=
(
5
,
10
,
1
)
t1
=
relay
.
TensorType
(
x_shape
,
'int32'
)
t2
=
relay
.
TensorType
(
y_shape
,
'int32'
)
x_data
=
np
.
random
.
randint
(
1
,
10000
,
size
=
(
x_shape
))
.
astype
(
t1
.
dtype
)
y_data
=
np
.
random
.
randint
(
1
,
10000
,
size
=
(
y_shape
))
.
astype
(
t2
.
dtype
)
func
=
relay
.
Function
([
x
,
y
],
z
)
ref_res
=
ref
(
x_data
,
y_data
)
for
target
,
ctx
in
ctx_list
():
intrp
=
relay
.
create_executor
(
"graph"
,
ctx
=
ctx
,
target
=
target
)
op_res
=
intrp
.
evaluate
(
func
)(
x_data
,
y_data
)
tvm
.
testing
.
assert_allclose
(
op_res
.
asnumpy
(),
ref_res
)
def
test_where
():
shape
=
(
3
,
4
)
...
...
@@ -341,7 +362,8 @@ if __name__ == "__main__":
test_strided_set
()
test_binary_op
()
test_cmp_type
()
test_binary_int_broadcast
()
test_binary_int_broadcast_1
()
test_binary_int_broadcast_2
()
test_where
()
test_reduce_functions
()
test_mean_var_std
()
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