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
eb173aaa
Commit
eb173aaa
authored
Jul 31, 2023
by
Artur Wojcik
Browse files
Python bindings - default ON on Linux, UNAVAILABLE on Windows
parent
3b3fcc16
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
10 deletions
+30
-10
src/CMakeLists.txt
src/CMakeLists.txt
+3
-0
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+5
-1
src/driver/main.cpp
src/driver/main.cpp
+4
-0
src/include/migraphx/dynamic_loader.hpp
src/include/migraphx/dynamic_loader.hpp
+2
-0
src/include/migraphx/op/convert.hpp
src/include/migraphx/op/convert.hpp
+8
-1
src/py/CMakeLists.txt
src/py/CMakeLists.txt
+8
-8
No files found.
src/CMakeLists.txt
View file @
eb173aaa
...
@@ -274,6 +274,9 @@ target_link_libraries(migraphx INTERFACE $<BUILD_INTERFACE:msgpackc-cxx>)
...
@@ -274,6 +274,9 @@ target_link_libraries(migraphx INTERFACE $<BUILD_INTERFACE:msgpackc-cxx>)
add_library
(
migraphx_all_targets INTERFACE
)
add_library
(
migraphx_all_targets INTERFACE
)
include
(
CMakeDependentOption
)
cmake_dependent_option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
"WIN32"
OFF
)
set
(
PACKAGE_DEPENDS
)
set
(
PACKAGE_DEPENDS
)
add_subdirectory
(
api
)
add_subdirectory
(
api
)
...
...
src/driver/CMakeLists.txt
View file @
eb173aaa
...
@@ -49,7 +49,11 @@ rocm_clang_tidy_check(driver)
...
@@ -49,7 +49,11 @@ 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
)
endif
()
rocm_install_targets
(
rocm_install_targets
(
TARGETS driver
TARGETS driver
...
...
src/driver/main.cpp
View file @
eb173aaa
...
@@ -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>
...
@@ -282,10 +284,12 @@ struct loader
...
@@ -282,10 +284,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/include/migraphx/dynamic_loader.hpp
View file @
eb173aaa
...
@@ -47,7 +47,9 @@ struct MIGRAPHX_EXPORT dynamic_loader
...
@@ -47,7 +47,9 @@ struct MIGRAPHX_EXPORT dynamic_loader
static
fs
::
path
path
(
void
*
address
);
static
fs
::
path
path
(
void
*
address
);
#endif
#endif
#ifdef MIGRAPHX_ENABLE_PYTHON
static
optional
<
dynamic_loader
>
try_load
(
const
fs
::
path
&
p
);
static
optional
<
dynamic_loader
>
try_load
(
const
fs
::
path
&
p
);
#endif
dynamic_loader
()
=
default
;
dynamic_loader
()
=
default
;
...
...
src/include/migraphx/op/convert.hpp
View file @
eb173aaa
...
@@ -68,7 +68,14 @@ struct convert : unary<convert>
...
@@ -68,7 +68,14 @@ struct convert : unary<convert>
auto
y
=
x
;
auto
y
=
x
;
shape
::
visit
(
type
,
[
&
](
auto
as
)
{
shape
::
visit
(
type
,
[
&
](
auto
as
)
{
// clamping value between target_type's max and min doesn't work for NaNs,
// clamping value between target_type's max and min doesn't work for NaNs,
if
(
std
::
isnan
(
x
))
// WIN32: The standard library from MSVC does implement std::isfinite()
// (used by std::isnan() internally) for floating-point types only
// - there are no additional overloads for integer types, which should be
// treated as doubles according to the C++ specification.
// Reference: https://en.cppreference.com/w/cpp/numeric/math/isfinite
if
(
std
::
isnan
(
static_cast
<
double
>
(
x
)))
{
{
y
=
as
.
nan
();
y
=
as
.
nan
();
}
}
...
...
src/py/CMakeLists.txt
View file @
eb173aaa
...
@@ -22,15 +22,15 @@
...
@@ -22,15 +22,15 @@
# THE SOFTWARE.
# THE SOFTWARE.
#####################################################################################
#####################################################################################
option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
)
add_library
(
migraphx_py py_loader.cpp
)
migraphx_generate_export_header
(
migraphx_py
)
target_include_directories
(
migraphx_py PRIVATE include
)
target_link_libraries
(
migraphx_py PUBLIC migraphx
)
rocm_install_targets
(
TARGETS migraphx_py INCLUDE include
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
include
(
PythonModules
)
add_compile_definitions
(
$<$<COMPILE_LANGUAGE:CXX,C>:MIGRAPHX_ENABLE_PYTHON>
)
add_library
(
migraphx_py py_loader.cpp
)
migraphx_generate_export_header
(
migraphx_py
)
target_include_directories
(
migraphx_py PRIVATE include
)
target_link_libraries
(
migraphx_py PUBLIC migraphx
)
rocm_install_targets
(
TARGETS migraphx_py INCLUDE include
)
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
)
...
...
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