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
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_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_LIB_VERSIONING_ENABLE "Enable shared library versioning" FALSE)
option(NGRAPH_PYTHON_BUILD_ENABLE "Enable build nGraph python package wheel" FALSE)
......@@ -139,7 +139,17 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
option(NGRAPH_ONNXIFI_ENABLE "Enable ONNX Interface for Framework Integration" TRUE)
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...
......
......@@ -37,4 +37,6 @@ if (NGRAPH_GPUH_ENABLE)
add_subdirectory(gpuh)
endif()
add_subdirectory(plaidml)
if (NGRAPH_PLAIDML_ENABLE)
add_subdirectory(plaidml)
endif()
......@@ -60,25 +60,16 @@ set(SRC
plaidml_translate.cpp
)
if (NGRAPH_PLAIDML_ENABLE)
find_package(PlaidML CONFIG REQUIRED)
message(STATUS "PlaidML enabled")
add_library(libplaidml INTERFACE)
target_link_libraries(libplaidml INTERFACE ${PLAIDML_LIBRARIES})
install(FILES ${PLAIDML_LIBRARIES} DESTINATION ${NGRAPH_INSTALL_LIB})
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")
add_library(libplaidml INTERFACE)
target_link_libraries(libplaidml INTERFACE ${PLAIDML_LIBRARIES})
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})
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