Skip to content

Commit

Permalink
Merge pull request #2223 from alibaba/feature/sync
Browse files Browse the repository at this point in the history
[MNN:Sync] Sync Internal 2.3.1
  • Loading branch information
jxt1234 authored Feb 15, 2023
2 parents 86b9201 + 4a60900 commit 74782a3
Show file tree
Hide file tree
Showing 92 changed files with 3,664 additions and 2,038 deletions.
47 changes: 11 additions & 36 deletions codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
option(MNN_CODEGEN_LLVM "Build llvm backend for codegen." OFF)
option(MNN_CODEGEN_C "Build C source backend for codegen." OFF)
option(MNN_CODEGEN_OPENCL "Build OpenCL source backend for codegen." OFF)
option(MNN_CODEGEN_JIT "Build jit for codegen." OFF)
option(MNN_CODEGEN_OPENCL "Build OpenCL op fuse." OFF)
option(MNN_CODEGEN_METAL "Build Metal op fuse." OFF)


file(GLOB CODEGEN_HEADER "${CMAKE_CURRENT_LIST_DIR}/*.*")
file(GLOB CPU_SRCS "${CMAKE_CURRENT_LIST_DIR}/cpu/*.*")
file(GLOB JIT_SRCS "${CMAKE_CURRENT_LIST_DIR}/jit/*.*")
list(APPEND MNN_CODEGEN_SRCS ${CODEGEN_HEADER})
list(APPEND MNN_CODEGEN_SRCS ${JIT_SRCS})
file(GLOB MNN_FUSE_SRCS "${CMAKE_CURRENT_LIST_DIR}/*.*")

if(MNN_CODEGEN_OPENCL)
add_definitions(-DMNN_CODEGEN_OPENCL)
file(GLOB OPENCL_SRCS "${CMAKE_CURRENT_LIST_DIR}/opencl/*.*")
list(APPEND MNN_CODEGEN_SRCS ${OPENCL_SRCS})
endif()

if(MNN_CODEGEN_C)
add_definitions(-DMNN_CODEGEN_CPU)
add_definitions(-DMNN_CODEGEN_C)
file(GLOB C_SRCS "${CMAKE_CURRENT_LIST_DIR}/cpu/c/*.*")
list(APPEND MNN_CODEGEN_SRCS ${CPU_SRCS})
list(APPEND MNN_CODEGEN_SRCS ${C_SRCS})
list(APPEND MNN_FUSE_SRCS ${OPENCL_SRCS})
endif()

if(MNN_CODEGEN_LLVM)
add_definitions(-DMNN_CODEGEN_CPU)
add_definitions(-DMNN_CODEGEN_LLVM)
file(GLOB LLVM_SRCS "${CMAKE_CURRENT_LIST_DIR}/cpu/llvm/*.*")
list(APPEND MNN_CODEGEN_SRCS ${CPU_SRCS})
list(APPEND MNN_CODEGEN_SRCS ${LLVM_SRCS})
# add llvm libs
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
llvm_map_components_to_libnames(llvm_libs core bitwriter OrcJIT Support nativecodegen native CodeGen)
list(APPEND MNN_EXTRA_DEPENDS ${llvm_libs})
if(MNN_CODEGEN_METAL)
add_definitions(-DMNN_CODEGEN_METAL)
file(GLOB METAL_SRCS "${CMAKE_CURRENT_LIST_DIR}/metal/*.*")
list(APPEND MNN_FUSE_SRCS ${METAL_SRCS})
endif()

add_library(MNNCodegen OBJECT ${MNN_CODEGEN_SRCS})
set_property(TARGET MNNCodegen PROPERTY CXX_STANDARD 14)
list(APPEND MNN_OBJECTS_TO_LINK $<TARGET_OBJECTS:MNNCodegen>)
add_library(MNNFuse OBJECT ${MNN_FUSE_SRCS})
# set_property(TARGET MNNFuse PROPERTY CXX_STANDARD 14)
list(APPEND MNN_OBJECTS_TO_LINK $<TARGET_OBJECTS:MNNFuse>)
Loading

0 comments on commit 74782a3

Please sign in to comment.