Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
27ca76f4
Commit
27ca76f4
authored
Feb 19, 2019
by
Paul
Browse files
Fix tests on python 3
parent
df2c494a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
10 deletions
+16
-10
test/py/CMakeLists.txt
test/py/CMakeLists.txt
+3
-3
test/py/test_array.py
test/py/test_array.py
+13
-7
test/py/test_cpu.py
test/py/test_cpu.py
+0
-0
test/py/test_gpu.py
test/py/test_gpu.py
+0
-0
No files found.
test/py/CMakeLists.txt
View file @
27ca76f4
...
...
@@ -16,8 +16,8 @@ endfunction()
add_dependencies
(
tests migraphx_py
)
add_dependencies
(
check migraphx_py
)
add_py_test
(
cpu cpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
cpu
test_
cpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
if
(
MIGRAPHX_ENABLE_GPU
)
add_py_test
(
gpu gpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
array array.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
gpu
test_
gpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
array
test_
array.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
endif
()
test/py/array.py
→
test/py/
test_
array.py
View file @
27ca76f4
...
...
@@ -19,11 +19,11 @@ def write_float(b, index):
def
nelements
(
lens
):
return
reduce
(
lambda
x
,
y
:
x
*
y
,
lens
,
1
)
def
create_buffer
(
t
,
data
):
def
create_buffer
(
t
,
data
,
shape
):
a
=
array
.
array
(
t
,
data
)
if
sys
.
version_info
>=
(
3
,
0
):
m
=
memoryview
(
a
.
tobytes
())
return
m
.
cast
(
t
)
return
m
.
cast
(
t
,
shape
)
else
:
m
=
memoryview
(
a
.
tostring
())
return
m
...
...
@@ -48,14 +48,20 @@ def run(p):
return
migraphx
.
from_gpu
(
p
.
run
(
params
))
def
test_shape
(
shape
):
data
=
list
(
range
(
nelements
(
shape
)))
m
=
create_buffer
(
'f'
,
data
,
shape
)
a
=
migraphx
.
argument
(
m
)
check_shapes
(
a
,
m
)
assert_eq
(
a
.
tolist
(),
data
)
def
test_input
():
data
=
list
(
range
(
4
))
m
=
create_buffer
(
'f'
,
data
)
if
sys
.
version_info
>=
(
3
,
0
):
a
=
migraphx
.
argument
(
m
)
check_shapes
(
a
,
m
)
assert_eq
(
a
.
tolist
(),
data
)
test_shape
([
4
])
# test_shape([2, 3])
else
:
data
=
list
(
range
(
4
))
m
=
create_buffer
(
'f'
,
data
,
[
4
])
a1
=
migraphx
.
argument
(
m
)
a2
=
migraphx
.
argument
(
bytearray
(
a1
))
check_shapes
(
a2
,
m
)
...
...
test/py/cpu.py
→
test/py/
test_
cpu.py
View file @
27ca76f4
File moved
test/py/gpu.py
→
test/py/
test_
gpu.py
View file @
27ca76f4
File moved
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