Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
6d1bb63a
Commit
6d1bb63a
authored
Feb 04, 2019
by
Paul
Browse files
Add python test
parent
c570fb57
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
1 deletion
+33
-1
src/py/CMakeLists.txt
src/py/CMakeLists.txt
+4
-1
src/py/migraphx_py.cpp
src/py/migraphx_py.cpp
+10
-0
test/CMakeLists.txt
test/CMakeLists.txt
+2
-0
test/py/CMakeLists.txt
test/py/CMakeLists.txt
+16
-0
test/py/test.py
test/py/test.py
+1
-0
No files found.
src/py/CMakeLists.txt
View file @
6d1bb63a
find_package
(
pybind11 REQUIRED
)
pybind11_add_module
(
migraphx_py migraphx_py.cpp
)
target_link_libraries
(
migraphx_py migraphx migraphx_onnx migraphx_gpu migraphx_cpu
)
target_link_libraries
(
migraphx_py migraphx migraphx_onnx migraphx_cpu
)
set_target_properties
(
migraphx_py PROPERTIES
OUTPUT_NAME migraphx
)
src/py/migraphx_py.cpp
View file @
6d1bb63a
...
...
@@ -2,6 +2,8 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/cpu/target.hpp>
#include <migraphx/onnx.hpp>
namespace
py
=
pybind11
;
...
...
@@ -71,6 +73,14 @@ PYBIND11_MODULE(migraphx, m)
m
.
def
(
"parse_onnx"
,
&
migraphx
::
parse_onnx
);
m
.
def
(
"target"
,
[](
const
std
::
string
&
name
)
->
migraphx
::
target
{
if
(
name
==
"cpu"
)
return
migraphx
::
cpu
::
target
{};
throw
std
::
runtime_error
(
"Target not found: "
+
name
);
});
m
.
def
(
"generate_argument"
,
&
migraphx
::
generate_argument
,
py
::
arg
(
"s"
),
py
::
arg
(
"seed"
)
=
0
);
#ifdef VERSION_INFO
m
.
attr
(
"__version__"
)
=
VERSION_INFO
;
#else
...
...
test/CMakeLists.txt
View file @
6d1bb63a
...
...
@@ -120,6 +120,8 @@ add_test(NAME test_onnx COMMAND $<TARGET_FILE:test_onnx> WORKING_DIRECTORY ${CMA
add_dependencies
(
tests test_onnx
)
add_dependencies
(
check test_onnx
)
add_subdirectory
(
py
)
function
(
test_header NAME HEADER
)
file
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/header-main-include-
${
NAME
}
.cpp
...
...
test/py/CMakeLists.txt
0 → 100644
View file @
6d1bb63a
find_package
(
PythonInterp
)
function
(
add_py_test NAME SCRIPT
)
set
(
ENV_COMMAND
${
CMAKE_COMMAND
}
-E env
"PYTHONPATH=$<TARGET_FILE_DIR:migraphx_py>"
)
add_test
(
NAME test_py_
${
NAME
}
COMMAND
${
ENV_COMMAND
}
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCRIPT
}
${
ARGN
}
)
add_custom_target
(
test_py_
${
NAME
}
COMMAND
${
ENV_COMMAND
}
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCRIPT
}
${
ARGN
}
COMMENT
"
${
PYTHON_EXECUTABLE
}
${
SCRIPT
}
"
)
endfunction
()
add_py_test
(
test test.py
)
test/py/test.py
0 → 100644
View file @
6d1bb63a
import
migraphx
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