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
48afdcab
Unverified
Commit
48afdcab
authored
Oct 11, 2023
by
Artur Wojcik
Committed by
GitHub
Oct 10, 2023
Browse files
make pybind compilation optional (#2280)
parent
cd968ae1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
18 deletions
+32
-18
CMakeLists.txt
CMakeLists.txt
+6
-0
src/CMakeLists.txt
src/CMakeLists.txt
+2
-0
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+6
-1
src/driver/main.cpp
src/driver/main.cpp
+4
-0
src/py/CMakeLists.txt
src/py/CMakeLists.txt
+14
-17
No files found.
CMakeLists.txt
View file @
48afdcab
...
@@ -53,6 +53,12 @@ include(CTest)
...
@@ -53,6 +53,12 @@ include(CTest)
find_package
(
ROCM REQUIRED
)
find_package
(
ROCM REQUIRED
)
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
if
(
WIN32
)
option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
OFF
)
else
()
option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
)
endif
()
find_path
(
HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half
)
find_path
(
HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half
)
if
(
NOT HALF_INCLUDE_DIR
)
if
(
NOT HALF_INCLUDE_DIR
)
message
(
FATAL_ERROR
"Could not find half.hpp - Please check that the install path of half.hpp has been added to CMAKE_PREFIX_PATH"
)
message
(
FATAL_ERROR
"Could not find half.hpp - Please check that the install path of half.hpp has been added to CMAKE_PREFIX_PATH"
)
...
...
src/CMakeLists.txt
View file @
48afdcab
...
@@ -282,7 +282,9 @@ add_subdirectory(driver)
...
@@ -282,7 +282,9 @@ add_subdirectory(driver)
add_subdirectory
(
onnx
)
add_subdirectory
(
onnx
)
add_subdirectory
(
tf
)
add_subdirectory
(
tf
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
add_subdirectory
(
py
)
add_subdirectory
(
py
)
endif
()
add_subdirectory
(
targets/ref
)
add_subdirectory
(
targets/ref
)
target_link_libraries
(
migraphx_all_targets INTERFACE migraphx_ref
)
target_link_libraries
(
migraphx_all_targets INTERFACE migraphx_ref
)
if
(
MIGRAPHX_ENABLE_CPU
)
if
(
MIGRAPHX_ENABLE_CPU
)
...
...
src/driver/CMakeLists.txt
View file @
48afdcab
...
@@ -48,7 +48,12 @@ rocm_clang_tidy_check(driver)
...
@@ -48,7 +48,12 @@ rocm_clang_tidy_check(driver)
file
(
STRINGS
"
${
CMAKE_SOURCE_DIR
}
/test/onnx/.onnxrt-commit"
String_output
)
file
(
STRINGS
"
${
CMAKE_SOURCE_DIR
}
/test/onnx/.onnxrt-commit"
String_output
)
target_compile_definitions
(
driver PUBLIC MIGRAPHX_ORT_SHA1=
"
${
String_output
}
"
)
target_compile_definitions
(
driver PUBLIC MIGRAPHX_ORT_SHA1=
"
${
String_output
}
"
)
target_link_libraries
(
driver migraphx_all_targets migraphx_onnx migraphx_tf migraphx_py
)
target_link_libraries
(
driver migraphx_all_targets migraphx_onnx migraphx_tf
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
target_link_libraries
(
driver migraphx_py
)
target_compile_definitions
(
driver PRIVATE MIGRAPHX_ENABLE_PYTHON
)
endif
()
rocm_install_targets
(
rocm_install_targets
(
TARGETS driver
TARGETS driver
...
...
src/driver/main.cpp
View file @
48afdcab
...
@@ -32,7 +32,9 @@
...
@@ -32,7 +32,9 @@
#include <migraphx/tf.hpp>
#include <migraphx/tf.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/onnx.hpp>
#ifdef MIGRAPHX_ENABLE_PYTHON
#include <migraphx/py.hpp>
#include <migraphx/py.hpp>
#endif
#include <migraphx/stringutils.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/convert_to_json.hpp>
#include <migraphx/convert_to_json.hpp>
#include <migraphx/load_save.hpp>
#include <migraphx/load_save.hpp>
...
@@ -281,10 +283,12 @@ struct loader
...
@@ -281,10 +283,12 @@ struct loader
options
.
format
=
"json"
;
options
.
format
=
"json"
;
p
=
migraphx
::
load
(
file
,
options
);
p
=
migraphx
::
load
(
file
,
options
);
}
}
#ifdef MIGRAPHX_ENABLE_PYTHON
else
if
(
file_type
==
"py"
)
else
if
(
file_type
==
"py"
)
{
{
p
=
migraphx
::
load_py
(
file
);
p
=
migraphx
::
load_py
(
file
);
}
}
#endif
else
if
(
file_type
==
"migraphx"
)
else
if
(
file_type
==
"migraphx"
)
{
{
p
=
migraphx
::
load
(
file
);
p
=
migraphx
::
load
(
file
);
...
...
src/py/CMakeLists.txt
View file @
48afdcab
...
@@ -22,27 +22,24 @@
...
@@ -22,27 +22,24 @@
# THE SOFTWARE.
# THE SOFTWARE.
#####################################################################################
#####################################################################################
option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
)
add_library
(
migraphx_py py_loader.cpp
)
add_library
(
migraphx_py py_loader.cpp
)
migraphx_generate_export_header
(
migraphx_py
)
migraphx_generate_export_header
(
migraphx_py
)
target_include_directories
(
migraphx_py PRIVATE include
)
target_include_directories
(
migraphx_py PRIVATE include
)
target_link_libraries
(
migraphx_py PUBLIC migraphx
)
target_link_libraries
(
migraphx_py PUBLIC migraphx
)
rocm_install_targets
(
TARGETS migraphx_py INCLUDE include
)
rocm_install_targets
(
TARGETS migraphx_py INCLUDE include
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
include
(
PythonModules
)
include
(
PythonModules
)
foreach
(
PYTHON_VERSION
${
PYTHON_VERSIONS
}
)
foreach
(
PYTHON_VERSION
${
PYTHON_VERSIONS
}
)
py_add_module
(
migraphx_pybind_
${
PYTHON_VERSION
}
migraphx_py.cpp PYTHON_VERSION
${
PYTHON_VERSION
}
PYTHON_MODULE migraphx
)
py_add_module
(
migraphx_pybind_
${
PYTHON_VERSION
}
migraphx_py.cpp PYTHON_VERSION
${
PYTHON_VERSION
}
PYTHON_MODULE migraphx
)
target_link_libraries
(
migraphx_pybind_
${
PYTHON_VERSION
}
PRIVATE migraphx migraphx_tf migraphx_onnx migraphx_all_targets
)
target_link_libraries
(
migraphx_pybind_
${
PYTHON_VERSION
}
PRIVATE migraphx migraphx_tf migraphx_onnx migraphx_all_targets
)
rocm_install_targets
(
TARGETS migraphx_pybind_
${
PYTHON_VERSION
}
)
rocm_install_targets
(
TARGETS migraphx_pybind_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_pybind_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_pybind_
${
PYTHON_VERSION
}
)
add_library
(
migraphx_py_
${
PYTHON_VERSION
}
py.cpp
)
add_library
(
migraphx_py_
${
PYTHON_VERSION
}
py.cpp
)
target_include_directories
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE include
)
target_include_directories
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE include
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PUBLIC migraphx
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PUBLIC migraphx
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE pybind11::pybind11 python
${
PYTHON_VERSION
}
::runtime
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE pybind11::pybind11 python
${
PYTHON_VERSION
}
::runtime
)
rocm_install_targets
(
TARGETS migraphx_py_
${
PYTHON_VERSION
}
)
rocm_install_targets
(
TARGETS migraphx_py_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_py_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_py_
${
PYTHON_VERSION
}
)
endforeach
()
endforeach
()
endif
()
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