forked from mindspore-Ecosystem/mindspore
support building of static lib for mindspore lite
This commit is contained in:
parent
f16c01460f
commit
9bdcc0a2dd
|
@ -54,6 +54,7 @@ endif ()
|
|||
|
||||
if (PLATFORM_ARM64)
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.a DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${INC_DIR}/ir/dtype COMPONENT ${COMPONENT_NAME})
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/schema/ DESTINATION ${INC_DIR}/schema COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "inner" EXCLUDE)
|
||||
|
@ -61,6 +62,7 @@ if (PLATFORM_ARM64)
|
|||
install(DIRECTORY ${TOP_DIR}/third_party/flatbuffers/include DESTINATION ${FLATBF_DIR} COMPONENT ${COMPONENT_NAME})
|
||||
elseif (PLATFORM_ARM32)
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.a DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${INC_DIR}/ir/dtype COMPONENT ${COMPONENT_NAME})
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/schema/ DESTINATION ${INC_DIR}/schema COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "inner" EXCLUDE)
|
||||
|
@ -77,7 +79,7 @@ else ()
|
|||
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${INC_DIR_RUN_X86}/ir/dtype COMPONENT ${RUN_X86_COMPONENT_NAME})
|
||||
install(DIRECTORY ${TOP_DIR}/third_party/flatbuffers/include DESTINATION ${FLATBF_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
|
||||
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.a DESTINATION ${LIB_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/third_party/protobuf/build/lib/libprotobuf.so.19.0.0 DESTINATION ${PROTOBF_DIR}/lib RENAME libprotobuf.so.19 COMPONENT ${COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/third_party/flatbuffers/build/libflatbuffers.so.1.11.0 DESTINATION ${FLATBF_DIR}/lib RENAME libflatbuffers.so.1 COMPONENT ${COMPONENT_NAME})
|
||||
endif ()
|
||||
|
|
|
@ -181,7 +181,7 @@ if (BUILD_MINDDATA STREQUAL "full")
|
|||
elseif (BUILD_MINDDATA STREQUAL "lite")
|
||||
list(REMOVE_ITEM MINDDATA_CORE_SRC_FILES "${MINDDATA_DIR}/core/client.cc")
|
||||
list(REMOVE_ITEM MINDDATA_KERNELS_SRC_FILES "${MINDDATA_DIR}/kernels/py_func_op.cc")
|
||||
add_library(minddata-eager OBJECT
|
||||
add_library(minddata_eager_mid OBJECT
|
||||
${MINDDATA_DIR}/api/de_tensor.cc
|
||||
${MINDDATA_DIR}/api/execute.cc
|
||||
)
|
||||
|
|
|
@ -26,55 +26,67 @@ set(LITE_SRC
|
|||
)
|
||||
|
||||
if (SUPPORT_GPU)
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/kernel/opencl/subgraph_opencl_kernel.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/kernel/opencl/utils.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_executor.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_allocator.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_runtime.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_wrapper.cc
|
||||
)
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/kernel/opencl/subgraph_opencl_kernel.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/kernel/opencl/utils.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_executor.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_allocator.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_runtime.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/opencl/opencl_wrapper.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if (SUPPORT_TRAIN)
|
||||
set(ANF_SRC
|
||||
${ANF_SRC}
|
||||
|
||||
${ANF_SRC}
|
||||
)
|
||||
set(PASS_SRC)
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
${ANF_SRC}
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/train/ops/train_ops.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/train/train_populate_parameter.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/train/train_session.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lite_session.cc
|
||||
)
|
||||
|
||||
endif ()
|
||||
|
||||
file(GLOB_RECURSE C_OPS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/ops/*.cc)
|
||||
add_subdirectory(runtime/kernel/arm)
|
||||
|
||||
add_library(mindspore-lite SHARED ${LITE_SRC} ${C_OPS_SRC})
|
||||
set_target_properties(mindspore-lite PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
add_library(mindspore-lite_static STATIC ${LITE_SRC} ${C_OPS_SRC})
|
||||
set_target_properties(mindspore-lite_static PROPERTIES OUTPUT_NAME "mindspore-lite")
|
||||
set_target_properties(mindspore-lite_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
|
||||
if (SUPPORT_GPU)
|
||||
add_subdirectory(runtime/kernel/opencl)
|
||||
target_link_libraries(mindspore-lite
|
||||
cpu_kernel_mid_
|
||||
opencl_kernel_lib_
|
||||
cpu_kernel_mid
|
||||
opencl_kernel_mid
|
||||
)
|
||||
target_link_libraries(mindspore-lite_static
|
||||
cpu_kernel_mid
|
||||
opencl_kernel_mid
|
||||
)
|
||||
else ()
|
||||
target_link_libraries(mindspore-lite
|
||||
cpu_kernel_mid_
|
||||
cpu_kernel_mid
|
||||
)
|
||||
target_link_libraries(mindspore-lite_static
|
||||
cpu_kernel_mid
|
||||
)
|
||||
endif ()
|
||||
add_subdirectory(runtime/kernel/arm)
|
||||
if (PLATFORM_ARM32 OR PLATFORM_ARM64)
|
||||
target_link_libraries(mindspore-lite log)
|
||||
endif ()
|
||||
if (BUILD_MINDDATA STREQUAL "lite")
|
||||
target_link_libraries(mindspore-lite minddata-eager minddata-lite)
|
||||
target_link_libraries(mindspore-lite minddata_eager_mid minddata-lite)
|
||||
target_link_libraries(mindspore-lite_static minddata_eager_mid)
|
||||
endif ()
|
||||
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND (PLATFORM_ARM64 OR PLATFORM_ARM32))
|
||||
|
|
|
@ -16,6 +16,7 @@ file (GLOB TRAIN_KERNEL_SRC
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/fp32_grad/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../../../nnacl/fp32_grad/*.c
|
||||
)
|
||||
set(KERNEL_SRC ${KERNEL_SRC} ${TRAIN_KERNEL_SRC})
|
||||
endif()
|
||||
|
||||
if (PLATFORM_ARM64)
|
||||
|
@ -35,4 +36,4 @@ if (PLATFORM_ARM32)
|
|||
set(KERNEL_SRC ${KERNEL_SRC} ${ASSEMBLY_SRC})
|
||||
endif()
|
||||
|
||||
add_library(cpu_kernel_mid_ OBJECT ${KERNEL_SRC} ${TRAIN_KERNEL_SRC})
|
||||
add_library(cpu_kernel_mid OBJECT ${KERNEL_SRC})
|
||||
|
|
|
@ -38,9 +38,6 @@ class PoolingGradCPUKernel : public LiteKernel {
|
|||
int Init() override;
|
||||
int ReSize() override;
|
||||
int Run() override;
|
||||
|
||||
private:
|
||||
uint8_t data_shape_{0};
|
||||
};
|
||||
|
||||
} // namespace mindspore::kernel
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
file(GLOB_RECURSE OPENCL_KERNEL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/kernel/*.cc)
|
||||
add_library(opencl_kernel_lib_ OBJECT ${KERNEL_SRC} ${OPENCL_KERNEL_SRC})
|
||||
add_library(opencl_kernel_mid OBJECT ${OPENCL_KERNEL_SRC})
|
||||
|
|
|
@ -336,8 +336,8 @@ endif()
|
|||
|
||||
if (BUILD_MINDDATA STREQUAL "lite")
|
||||
target_link_libraries(lite-test
|
||||
minddata_eager_mid
|
||||
minddata-lite
|
||||
minddata-eager
|
||||
)
|
||||
if (PLATFORM_ARM32 OR PLATFORM_ARM64)
|
||||
target_link_libraries(lite-test log)
|
||||
|
|
Loading…
Reference in New Issue