Commit fa3200f1 authored by Rob Earhart's avatar Rob Earhart Committed by Scott Cyphers

Use plaidml cmake config (#2290)

* Use plaidml cmake config

* Require PlaidML if requested

* Don't install libplaidml

We can assume that it's correctly installed on the target, especially
since it needs to be correctly installed in order to find its
configuration files.
parent a2d8a9fd
...@@ -108,7 +108,7 @@ option(NGRAPH_GPUH_ENABLE "Control the building of the Hybrid GPU backend" FALSE ...@@ -108,7 +108,7 @@ option(NGRAPH_GPUH_ENABLE "Control the building of the Hybrid GPU backend" FALSE
option(NGRAPH_DISTRIBUTED_ENABLE "Add distributed mode to the CPU backend" FALSE) option(NGRAPH_DISTRIBUTED_ENABLE "Add distributed mode to the CPU backend" FALSE)
option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" FALSE) option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" FALSE)
option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" FALSE) option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" FALSE)
option(NGRAPH_DEX_ONLY "Build CPU or GPU DEX without codegen" FALSE) option(NGRAPH_DEX_ONLY "Build CPU DEX without codegen" FALSE)
option(NGRAPH_CODE_COVERAGE_ENABLE "Enable code coverage data collection" FALSE) option(NGRAPH_CODE_COVERAGE_ENABLE "Enable code coverage data collection" FALSE)
option(NGRAPH_LIB_VERSIONING_ENABLE "Enable shared library versioning" FALSE) option(NGRAPH_LIB_VERSIONING_ENABLE "Enable shared library versioning" FALSE)
option(NGRAPH_PYTHON_BUILD_ENABLE "Enable build nGraph python package wheel" FALSE) option(NGRAPH_PYTHON_BUILD_ENABLE "Enable build nGraph python package wheel" FALSE)
...@@ -139,7 +139,17 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) ...@@ -139,7 +139,17 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
option(NGRAPH_ONNXIFI_ENABLE "Enable ONNX Interface for Framework Integration" TRUE) option(NGRAPH_ONNXIFI_ENABLE "Enable ONNX Interface for Framework Integration" TRUE)
endif() endif()
option(NGRAPH_PLAIDML_ENABLE "Enable the PlaidML backend" FALSE) find_package(PlaidML CONFIG)
option(NGRAPH_PLAIDML_ENABLE "Enable the PlaidML backend" ${PLAIDML_FOUND})
if (NGRAPH_PLAIDML_ENABLE)
if (NOT PLAIDML_FOUND)
message(FATAL_ERROR "PlaidML not installed")
endif()
endif()
message(STATUS "NGRAPH_PLAIDML_ENABLE: ${NGRAPH_PLAIDML_ENABLE}")
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
# Installation logic... # Installation logic...
......
...@@ -37,4 +37,6 @@ if (NGRAPH_GPUH_ENABLE) ...@@ -37,4 +37,6 @@ if (NGRAPH_GPUH_ENABLE)
add_subdirectory(gpuh) add_subdirectory(gpuh)
endif() endif()
add_subdirectory(plaidml) if (NGRAPH_PLAIDML_ENABLE)
add_subdirectory(plaidml)
endif()
...@@ -60,25 +60,16 @@ set(SRC ...@@ -60,25 +60,16 @@ set(SRC
plaidml_translate.cpp plaidml_translate.cpp
) )
if (NGRAPH_PLAIDML_ENABLE) add_library(libplaidml INTERFACE)
find_package(PlaidML CONFIG REQUIRED) target_link_libraries(libplaidml INTERFACE ${PLAIDML_LIBRARIES})
message(STATUS "PlaidML enabled") add_library(plaidml_backend SHARED ${SRC})
if(NGRAPH_LIB_VERSIONING_ENABLE)
add_library(libplaidml INTERFACE) set_target_properties(plaidml_backend PROPERTIES
target_link_libraries(libplaidml INTERFACE ${PLAIDML_LIBRARIES}) VERSION ${NGRAPH_VERSION}
install(FILES ${PLAIDML_LIBRARIES} DESTINATION ${NGRAPH_INSTALL_LIB}) SOVERSION ${NGRAPH_API_VERSION})
add_library(plaidml_backend SHARED ${SRC})
if(NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(plaidml_backend PROPERTIES
VERSION ${NGRAPH_VERSION}
SOVERSION ${NGRAPH_API_VERSION})
endif()
target_include_directories(plaidml_backend SYSTEM PUBLIC ${PLAIDML_INCLUDE_DIRS})
target_link_libraries(plaidml_backend PUBLIC ngraph libplaidml)
set_target_properties(plaidml_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${NGRAPH_BUILD_DIR}")
install(TARGETS plaidml_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB})
else()
message(STATUS "PlaidML not enabled")
endif() endif()
target_include_directories(plaidml_backend SYSTEM PUBLIC ${PLAIDML_INCLUDE_DIRS})
target_link_libraries(plaidml_backend PUBLIC ngraph libplaidml)
set_target_properties(plaidml_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${NGRAPH_BUILD_DIR}")
install(TARGETS plaidml_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment