Skip to content

Commit

Permalink
Merge pull request #16 from chenfeiyue-cfy/fix_compiling
Browse files Browse the repository at this point in the history
Fix cross compiling error
  • Loading branch information
sunshinemyson authored Jun 6, 2024
2 parents a47a8ff + 11216c5 commit 6d2c24a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ endif()

if (onnxruntime_USE_VSINPU)
add_definitions(-DUSE_VSINPU=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
file(GLOB_RECURSE onnxruntime_providers_vsinpu_srcs
"${ONNXRUNTIME_ROOT}/core/providers/vsinpu/builders/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/vsinpu/builders/*.cc"
Expand All @@ -212,12 +211,24 @@ if (onnxruntime_USE_VSINPU)
target_include_directories(onnxruntime_providers_vsinpu PRIVATE ${ONNXRUNTIME_ROOT} $ENV{TIM_VX_INSTALL}/include)

find_library(TIMVX_LIBRARY NAMES tim-vx PATHS $ENV{TIM_VX_INSTALL}/lib NO_DEFAULT_PATH)
if(TIMVX_LIBRARY)
target_link_libraries(onnxruntime_providers_vsinpu PRIVATE ${TIMVX_LIBRARY})
else()
message(FATAL_ERROR "Cannot find TIM-VX library!")
if(NOT TIMVX_LIBRARY)
message(FATAL_ERROR "TIM-VX library is not found!")
endif()

if(CMAKE_CROSSCOMPILING)
message(STATUS "VSINPU ep will be cross compiled.")
if(EXISTS "$ENV{VIVANTE_SDK_DIR}/drivers")
set(DRIVER_DIR "$ENV{VIVANTE_SDK_DIR}/drivers")
elseif(EXISTS "$ENV{VIVANTE_SDK_DIR}/lib")
set(DRIVER_DIR "$ENV{VIVANTE_SDK_DIR}/lib")
else()
message(FATAL_ERROR "Neither drivers nor lib directory exists in this VIVANTE_SDK_DIR.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wl,-rpath-link ${DRIVER_DIR} ${TIMVX_LIBRARY}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
target_link_libraries(onnxruntime_providers_vsinpu PRIVATE ${TIMVX_LIBRARY})
endif()
endif()

if (onnxruntime_USE_XNNPACK)
Expand Down

0 comments on commit 6d2c24a

Please sign in to comment.