chang sub_directory from lite/micro to lite/micro/coder

This commit is contained in:
chengyuanwang 2021-02-04 15:37:26 +08:00
parent 5367ec88cf
commit 6702aa9592
3 changed files with 51 additions and 63 deletions

View File

@ -204,7 +204,7 @@ if(ENABLE_CONVERTER)
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter)
if(NOT WIN32)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder)
endif()
endif()

View File

@ -1,31 +1,50 @@
cmake_minimum_required(VERSION 3.14)
project(micro)
string(REPLACE "/mindspore/lite/micro" "" MINDSPORE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
string(REPLACE "/mindspore/lite/micro" "" TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 17)
include_directories(${CMAKE_BINARY_DIR})
if(NOT ENABLE_CONVERTER)
set(CMAKE_CXX_STANDARD 17)
include(${MINDSPORE_ROOT_DIR}/cmake/utils.cmake)
include(${MINDSPORE_ROOT_DIR}/cmake/dependency_utils.cmake)
include(${MINDSPORE_ROOT_DIR}/cmake/dependency_securec.cmake)
include(${MINDSPORE_ROOT_DIR}/cmake/external_libs/flatbuffers.cmake)
set(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/model.fbs
${CMAKE_CURRENT_SOURCE_DIR}/../schema/ops.fbs
)
include(${TOP_DIR}/cmake/utils.cmake)
include(${TOP_DIR}/cmake/dependency_utils.cmake)
include(${TOP_DIR}/cmake/dependency_securec.cmake)
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
ms_build_flatbuffers_lite(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/
fbs_src
${CMAKE_BINARY_DIR}/schema
""
)
set(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/model.fbs
${CMAKE_CURRENT_SOURCE_DIR}/../schema/ops.fbs
${CMAKE_CURRENT_SOURCE_DIR}/../schema/model_v0.fbs
${CMAKE_CURRENT_SOURCE_DIR}/../schema/ops_v0.fbs
)
ms_build_flatbuffers_lite(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/
fbs_inner_src
${CMAKE_BINARY_DIR}/schema/inner
"inner"
)
ms_build_flatbuffers_lite(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/
fbs_src
${CMAKE_BINARY_DIR}/schema
""
)
ms_build_flatbuffers_lite(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/
fbs_inner_src
${CMAKE_BINARY_DIR}/schema/inner
"inner"
)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
MESSAGE(" ******Micro Debug********")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDebug -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDebug -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
else()
MESSAGE(" ******Micro Release********")
set(CMAKE_C_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -w -O2 -Werror \
-fstack-protector-all -Wno-attributes -Wno-deprecated-declarations -Wno-missing-braces ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -w -O2 -Werror \
-fstack-protector-all -Wno-attributes -Wno-deprecated-declarations \
-Wno-missing-braces -Wno-overloaded-virtual ${CMAKE_CXX_FLAGS}")
endif()
if(ENABLE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -lasan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-recover=address -lasan")
endif()
add_subdirectory(coder)

View File

@ -1,27 +1,6 @@
if(NOT ENABLE_CONVERTER)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
MESSAGE(" ******Micro Debug********")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDebug -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDebug -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
else()
MESSAGE(" ******Micro Release********")
set(CMAKE_C_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -w -O2 -Werror \
-fstack-protector-all -Wno-attributes -Wno-deprecated-declarations -Wno-missing-braces ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -w -O2 -Werror \
-fstack-protector-all -Wno-attributes -Wno-deprecated-declarations \
-Wno-missing-braces -Wno-overloaded-virtual ${CMAKE_CXX_FLAGS}")
endif()
if(ENABLE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -lasan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-recover=address -lasan")
endif()
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections ")
set(LITE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
set(3RD_DIR ${LITE_DIR}/../../third_party)
set(3RD_DIR ${TOP_DIR}/third_party)
set(NNACL_DIR ${LITE_DIR}/nnacl)
#include 3rd
@ -29,26 +8,21 @@ include_directories(${3RD_DIR})
include_directories(${3RD_DIR}/flatbuffers/include)
include_directories(${3RD_DIR}/securec/include/)
#include ms
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${MINDSPORE_ROOT_DIR})
include_directories(${TOP_DIR}/)
include_directories(${LITE_DIR})
include_directories(${MINDSPORE_ROOT_DIR}/mindspore/core/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../runtime)
include_directories(${TOP_DIR}/mindspore/core/)
#include coder
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils)
include_directories(${MINDSPORE_ROOT_DIR}/mindspore/lite/src/runtime/kernel/arm)
set(MS_SRC
${MINDSPORE_ROOT_DIR}/mindspore/lite/src/common/log_adapter.cc
)
file(GLOB_RECURSE PRIMITIVE_OP_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${LITE_DIR}/src/ops/*.cc
)
set(LITE_COMMON_SRC
set(LITE_SRC
${PRIMITIVE_OP_SRC}
${LITE_DIR}/tools/common/flag_parser.cc
${LITE_DIR}/src/common/file_utils.cc
@ -58,6 +32,7 @@ set(LITE_COMMON_SRC
${LITE_DIR}/src/lite_model.cc
${LITE_DIR}/src/tensorlist.cc
${LITE_DIR}/src/tensor.cc
${LITE_DIR}/src/common/log_adapter.cc
)
file(GLOB_RECURSE MICRO_ALLOCATOR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@ -89,18 +64,12 @@ list(APPEND MICRO_CODER_SRC
${MICRO_GENERATOR}
)
add_executable(codegen main.cc
${MS_SRC}
${MICRO_UTILS}
${LITE_COMMON_SRC}
${LITE_SRC}
${MICRO_CODER_SRC}
${MICRO_RUNTIME_SRC})
add_dependencies(codegen fbs_src)
add_dependencies(codegen fbs_inner_src)
target_link_libraries(codegen ${SECUREC_LIBRARY} ${CMAKE_DL_LIBS})
target_link_libraries(codegen ${SECUREC_LIBRARY})