Skip to content

Commit

Permalink
Fixed cross compiling error
Browse files Browse the repository at this point in the history
Added cmake flag control for cross compiling
Modified cmake and macro configuration of mlas to make it suitable for
vsinpu cross compiling

Type: New Feature
Signed-off-by: Feiyue Chen <[email protected]>
  • Loading branch information
chenfeiyue-cfy committed Jan 17, 2024
1 parent 46c90e3 commit dbe4cde
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmake/onnxruntime_mlas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ else()
${MLAS_SRC_DIR}/qgemm_kernel_udot.cpp
${MLAS_SRC_DIR}/qgemm_kernel_sdot.cpp
)
if (NOT APPLE)
if (NOT APPLE AND NOT onnxruntime_USE_VSINPU)
set(mlas_platform_srcs
${mlas_platform_srcs}
${MLAS_SRC_DIR}/aarch64/HalfGemmKernelNeon.S
Expand Down
21 changes: 16 additions & 5 deletions cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,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 @@ -1808,12 +1807,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
10 changes: 6 additions & 4 deletions onnxruntime/core/mlas/inc/mlas.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Module Name:

#if (!defined(_MSC_VER)) || (_MSC_VER >= 1930)
#if defined(MLAS_TARGET_ARM64) || defined(MLAS_TARGET_ARM64EC)
#if !defined(USE_VSINPU)
#if !defined(__APPLE__)
// Had to temporary disable fp16 under APPLE ARM64, as compiling
// the source files require a hardware specific compilation flag.
Expand All @@ -87,7 +88,8 @@ Module Name:

#define MLAS_F16VEC_INTRINSICS_SUPPORTED

#endif //
#endif
#endif //
#endif // ARM64
#endif // Visual Studio 16 or earlier does not support fp16 intrinsic

Expand Down Expand Up @@ -1619,7 +1621,7 @@ MlasHalfGemmConvertPackB(
* @param Channels # of input channels
* @param OutputCount # of output pixels
* @param KernelSize # kernel size
* @return
* @return
*/
void
MLASCALL
Expand Down Expand Up @@ -1657,7 +1659,7 @@ MlasTranspose(
* @param Channels C in NHWC
* @param OutputCount Number of output pixels
* @param KernelSize Size of the kernel
* @return
* @return
*/
void
MLASCALL
Expand All @@ -1676,7 +1678,7 @@ MlasNhwcMaxPool(
* @param Channels C in NHWC
* @param OutputCount Number of output pixels
* @param KernelSize size of the kernel
* @return
* @return
*/
void
MLASCALL
Expand Down

0 comments on commit dbe4cde

Please sign in to comment.