There are usually 4 ways to integrate ppl.nn into your applications.
After building and installing ppl.nn, there is a directory(specified by CMAKE_INSTALL_PREFIX) containing header files, libraries and cmake configurations. The entry point for finding ppl.nn is ${CMAKE_INSTALL_PREFIX}/lib/cmake/ppl/pplnn-config.cmake. Here is a sample snippet of CMakeLists.txt:
set(pplnn_DIR "<pplnn_install_dir>/lib/cmake/ppl")
find_package(pplnn REQUIRED)
target_include_directories(<target> PUBLIC ${PPLNN_INCLUDE_DIRS})
target_link_libraries(<target> PUBLIC ${PPLNN_LIBRARIES})Refer to ${CMAKE_INSTALL_PREFIX}/lib/cmake/ppl/pplnn-config.cmake for other cmake variables like versions and supported devices. In this form you can only use public APIs defined in ${CMAKE_INSTALL_PREFIX}/include/ppl.
A simple example integration shows how to use pplnn-config.cmake to integrate x86 engine into an application.
integration-cuda is a CUDA example.
You can also import ppl.nn's source like this:
add_subdirectory(pplnn_source_dir)
if(PPLNN_ENABLE_ONNX_MODEL)
target_link_libraries(<target> PUBLIC pplnn_onnx_static)
endif()
target_include_directories(<target> PUBLIC <pplnn_source_dir>/include <pplnn_source_dir>/src)Both public and internal APIs are avaliable in this form. NOTE internal APIs are changed frequently and not guaranteed to keep compatibility.
ppl.nn provides the following variables:
PPLNN_SOURCE_EXTERNAL_SOURCES: source files built and packed intoppl.nnPPLNN_SOURCE_EXTERNAL_INCLUDE_DIRECTORIES: extra include directories when building your codePPLNN_SOURCE_EXTERNAL_LINK_DIRECTORIES: extra link directories when building your codePPLNN_SOURCE_EXTERNAL_LINK_LIBRARIES: extra link libraries when building your codePPLNN_SOURCE_EXTERNAL_COMPILE_DEFINITIONS: extra compile definitions when building your code
and the following for specific modules:
PPLNN_SOURCE_EXTERNAL_ONNX_MODEL_SOURCES: source files for onnx modelPPLNN_SOURCE_EXTERNAL_PMX_MODEL_SOURCES: source files for pmx model
In this form you don't need to write extra configurations and .os are packed into the ppl.nn libraries.
You may also set PPLNN_VERSION_STR(in the form of <major>.<minor>.<patch>) and PPLNN_COMMIT_STR(a string) to the internal version info to override the default values.
Example:
set(PPLNN_SOURCE_EXTERNAL_SOURCES foo.cc bar.cc)
set(PPLNN_SOURCE_EXTERNAL_INCLUDE_DIRECTORIES /path/to/include)
set(PPLNN_VERSION_STR '1.0.0')
set(PPLNN_COMMIT_STR '1e1065')
add_subdirectory(pplnn_source_dir)Good luck!