compile the core directory into a separate static library
This commit is contained in:
parent
beb8527da1
commit
195f04e50e
|
@ -98,6 +98,7 @@ endif()
|
|||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
||||
add_subdirectory(mindspore/ccsrc)
|
||||
add_subdirectory(mindspore/core)
|
||||
if (ENABLE_TESTCASES)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
|
|
@ -52,12 +52,6 @@ install(
|
|||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS mindspore_gvar
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
if (USE_GLOG)
|
||||
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
|
||||
install(
|
||||
|
|
|
@ -130,7 +130,7 @@ set(SUB_COMP
|
|||
frontend/operator
|
||||
pipeline/jit
|
||||
pipeline/pynative
|
||||
common debug gvar pybind_api utils vm
|
||||
common debug pybind_api utils vm
|
||||
)
|
||||
|
||||
foreach (_comp ${SUB_COMP})
|
||||
|
@ -141,23 +141,14 @@ foreach (_comp ${SUB_COMP})
|
|||
add_dependencies(_mindspore_${sub}_obj proto_input )
|
||||
endif ()
|
||||
endforeach ()
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/base base)
|
||||
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_base_obj>)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/abstract abstract)
|
||||
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_abstract_obj>)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/utils util)
|
||||
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_core_utils_obj>)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/ir ir)
|
||||
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_ir_obj>)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/c_ops c_ops)
|
||||
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_c_ops_obj>)
|
||||
add_dependencies(_mindspore_core_utils_obj _mindspore_base_obj _mindspore_ir_obj _mindspore_abstract_obj _mindspore_c_ops_obj proto_input)
|
||||
|
||||
set_property(SOURCE ${SUB_OBJECTS_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_ME)
|
||||
add_library(mindspore STATIC ${SUB_OBJECTS_SRC})
|
||||
|
||||
target_link_libraries(proto_input mindspore::protobuf)
|
||||
|
||||
target_link_libraries(mindspore mindspore_core)
|
||||
|
||||
if (ENABLE_DEBUGGER)
|
||||
# debugger: link grpc
|
||||
target_link_libraries(proto_input mindspore::grpc++)
|
||||
|
@ -244,7 +235,6 @@ set_target_properties(_c_expression PROPERTIES INSTALL_RPATH ${ORIGIN_PATH})
|
|||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
target_link_libraries(mindspore mindspore::pybind11_module)
|
||||
target_link_libraries(mindspore mindspore_gvar)
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore -Wl,--no-whole-archive)
|
||||
else ()
|
||||
if (ENABLE_CPU AND (ENABLE_D OR ENABLE_GPU))
|
||||
|
@ -255,7 +245,6 @@ else ()
|
|||
endif()
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore -Wl,--no-whole-archive)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore::pybind11_module)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore_gvar)
|
||||
endif ()
|
||||
|
||||
if (USE_GLOG)
|
||||
|
@ -299,7 +288,7 @@ add_library(inference SHARED
|
|||
${LOAD_ONNX_SRC}
|
||||
)
|
||||
target_link_libraries(inference PRIVATE ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY}
|
||||
-Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore_gvar mindspore::protobuf)
|
||||
-Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore::protobuf)
|
||||
|
||||
if (ENABLE_CPU)
|
||||
target_link_libraries(inference PRIVATE mindspore::dnnl mindspore::mkldnn)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "backend/kernel_compiler/kernel.h"
|
||||
#include "ir/dtype.h"
|
||||
#include "ir/primitive.h"
|
||||
#include "pybind11/pybind11.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "backend/kernel_compiler/common_utils.h"
|
||||
#include "backend/kernel_compiler/oplib/oplib.h"
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <thread>
|
||||
#include "backend/kernel_compiler/cpu/sub_cpu_kernel.h"
|
||||
#include <sys/time.h>
|
||||
#include <thread>
|
||||
#include "runtime/device/cpu/cpu_device_address.h"
|
||||
|
||||
namespace mindspore {
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
file(GLOB_RECURSE MS_GVAR_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc)
|
||||
set_property(SOURCE ${MS_GVAR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON)
|
||||
add_library(mindspore_gvar SHARED ${MS_GVAR_SRC_LIST})
|
||||
if (APPLE)
|
||||
set_target_properties(mindspore_gvar PROPERTIES MACOSX_RPATH ON)
|
||||
endif ()
|
|
@ -126,7 +126,7 @@ endif()
|
|||
######################################################################
|
||||
|
||||
################# Link with external libraries ########################
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar)
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
if (ENABLE_PYTHON)
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} mindspore::protobuf ${SECUREC_LIBRARY})
|
||||
|
|
|
@ -28,9 +28,9 @@ set_target_properties(_c_mindrecord PROPERTIES
|
|||
|
||||
# add link library
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite mindspore mindspore_gvar mindspore::protobuf)
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite mindspore mindspore::protobuf)
|
||||
else()
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore_gvar mindspore::protobuf)
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore::protobuf)
|
||||
endif()
|
||||
|
||||
if (USE_GLOG)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <vector>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include "utils/base_ref_extends.h"
|
||||
#include "utils/load_onnx/anf_model_parser.h"
|
||||
#include "utils/load_onnx/anf_converter.h"
|
||||
#include "google/protobuf/io/zero_copy_stream_impl.h"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "utils/convert_utils_base.h"
|
||||
#include "utils/primitive_utils.h"
|
||||
#include "utils/base_ref_py.h"
|
||||
#include "utils/base_ref_extends.h"
|
||||
#include "pybind_api/api_register.h"
|
||||
#include "pybind_api/export_flags.h"
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "pipeline/jit/parse/python_adapter.h"
|
||||
#include "utils/log_adapter.h"
|
||||
#include "utils/ms_utils.h"
|
||||
#include "utils/base_ref_extends.h"
|
||||
|
||||
namespace mindspore {
|
||||
py::function GetBpropFunctionByObj(py::object obj) {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/mindspore/core)
|
||||
message("************build core***************")
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF")
|
||||
add_compile_definitions(BUILDING_DLL)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE CORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"abstract/*.cc"
|
||||
"base/*.cc"
|
||||
"c_ops/*.cc"
|
||||
"ir/*.cc"
|
||||
"utils/*.cc"
|
||||
"gvar/*.cc"
|
||||
)
|
||||
set_property(SOURCE ${CORE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_CORE)
|
||||
add_library(mindspore_core STATIC ${CORE_SRC_LIST})
|
||||
if (USE_GLOG)
|
||||
target_link_libraries(mindspore_core PRIVATE mindspore::glog)
|
||||
endif ()
|
|
@ -1,3 +0,0 @@
|
|||
file(GLOB_RECURSE _ABSTRACT_ALL_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
|
||||
set_property(SOURCE ${_ABSTRACT_ALL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_ABSTRACT)
|
||||
add_library(_mindspore_abstract_obj OBJECT ${_ABSTRACT_ALL_SRC_FILES})
|
|
@ -1,3 +0,0 @@
|
|||
file(GLOB_RECURSE _BASE_ALL_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
|
||||
set_property(SOURCE ${_BASE_ALL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_BASE)
|
||||
add_library(_mindspore_base_obj OBJECT ${_BASE_ALL_SRC_FILES})
|
|
@ -1,2 +0,0 @@
|
|||
file(GLOB_RECURSE _C_OPS_ALL_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
|
||||
add_library(_mindspore_c_ops_obj OBJECT ${_C_OPS_ALL_SRC_FILES})
|
|
@ -1,3 +0,0 @@
|
|||
file(GLOB_RECURSE _IR_SRC_LIST ./*.cc dtype/*.cc)
|
||||
set_property(SOURCE ${_IR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_IR)
|
||||
add_library(_mindspore_ir_obj OBJECT ${_IR_SRC_LIST})
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "ir/dtype/type.h"
|
||||
#include "abstract/abstract_value.h"
|
||||
#include "utils/base_ref_extends.h"
|
||||
#include "base/base_ref.h"
|
||||
|
||||
namespace mindspore {
|
||||
// Supported meta type
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
file(GLOB_RECURSE _UTIL_ALL_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
|
||||
set_property(SOURCE ${_UTIL_ALL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_UTILS)
|
||||
add_library(_mindspore_core_utils_obj OBJECT ${_UTIL_ALL_SRC_FILES})
|
|
@ -14,8 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_CCSRC_UTILS_LABEL_H_
|
||||
#define MINDSPORE_CCSRC_UTILS_LABEL_H_
|
||||
#ifndef MINDSPORE_CORE_UTILS_LABEL_H_
|
||||
#define MINDSPORE_CORE_UTILS_LABEL_H_
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -32,4 +32,4 @@ std::string Label(const DebugInfoPtr &debug_info, TraceLabelType trace_type = Tr
|
|||
} // namespace label_manage
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CCSRC_UTILS_LABEL_H_
|
||||
#endif // MINDSPORE_CORE_UTILS_LABEL_H_
|
||||
|
|
|
@ -160,7 +160,7 @@ static std::string ExceptionTypeToString(ExceptionType type) {
|
|||
static const char *GetSubModuleName(SubModuleId module_id) {
|
||||
static const char *sub_module_names[NUM_SUBMODUES] = {
|
||||
"UNKNOWN", // SM_UNKNOWN
|
||||
"BASE", // SM_BASE
|
||||
"CORE", // SM_CORE
|
||||
"ANALYZER", // SM_ANALYZER
|
||||
"COMMON", // SM_COMMON
|
||||
"DEBUG", // SM_DEBUG
|
||||
|
@ -180,7 +180,6 @@ static const char *GetSubModuleName(SubModuleId module_id) {
|
|||
"SESSION", // SM_SESSION
|
||||
"UTILS", // SM_UTILS
|
||||
"VM", // SM_VM
|
||||
"ABSTRACT" // SM_ABSTRACT
|
||||
};
|
||||
|
||||
return sub_module_names[module_id % NUM_SUBMODUES];
|
||||
|
|
|
@ -103,7 +103,7 @@ enum MsLogLevel : int { DEBUG = 0, INFO, WARNING, ERROR, EXCEPTION };
|
|||
|
||||
enum SubModuleId : int {
|
||||
SM_UNKNOWN = 0, // unknown submodule
|
||||
SM_BASE, // base
|
||||
SM_CORE, // core
|
||||
SM_ANALYZER, // static analyzer
|
||||
SM_COMMON, // common
|
||||
SM_DEBUG, // debug
|
||||
|
@ -123,7 +123,6 @@ enum SubModuleId : int {
|
|||
SM_SESSION, // session
|
||||
SM_UTILS, // utils
|
||||
SM_VM, // VM
|
||||
SM_ABSTRACT, // abstract
|
||||
NUM_SUBMODUES // number of submodules
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MINDSPORE_CCSRC_COMMON_UTILS_H_
|
||||
#define MINDSPORE_CCSRC_COMMON_UTILS_H_
|
||||
#ifndef MINDSPORE_CORE_UTILS_MS_UTILS_H_
|
||||
#define MINDSPORE_CORE_UTILS_MS_UTILS_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
@ -49,4 +49,4 @@ static inline int SetEnv(const char *envname, const char *envvar, int overwrite
|
|||
} // namespace common
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CCSRC_COMMON_UTILS_H_
|
||||
#endif // MINDSPORE_CORE_UTILS_MS_UTILS_H_
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_CCSRC_UTILS_PROFILE_H_
|
||||
#define MINDSPORE_CCSRC_UTILS_PROFILE_H_
|
||||
#ifndef MINDSPORE_CORE_UTILS_PROFILE_H_
|
||||
#define MINDSPORE_CORE_UTILS_PROFILE_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
@ -230,4 +230,4 @@ class MsProfile {
|
|||
#define WITH(x) NoProfTransaction(x) -
|
||||
#endif
|
||||
|
||||
#endif // MINDSPORE_CCSRC_UTILS_PROFILE_H_
|
||||
#endif // MINDSPORE_CORE_UTILS_PROFILE_H_
|
||||
|
|
|
@ -65,8 +65,8 @@ endif()
|
|||
|
||||
set(ANF_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/ir/meta_tensor.cc
|
||||
${CCSRC_DIR}/gvar/logging_level.cc
|
||||
${CCSRC_DIR}/gvar/typeid_manager.cc
|
||||
${CORE_DIR}/gvar/logging_level.cc
|
||||
${CORE_DIR}/gvar/typeid_manager.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/base/base.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/utils/log_adapter.cc
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ add_library(minddata-lite SHARED
|
|||
${MINDDATA_DIR}/util/path.cc
|
||||
${MINDDATA_DIR}/api/transforms.cc
|
||||
${CORE_DIR}/utils/log_adapter.cc
|
||||
${CCSRC_DIR}/gvar/logging_level.cc
|
||||
${CORE_DIR}/gvar/logging_level.cc
|
||||
)
|
||||
|
||||
target_link_libraries(minddata-lite
|
||||
|
|
|
@ -9,8 +9,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/dependency_gtest.cmake)
|
|||
### anf src
|
||||
set(ANF_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/meta_tensor.cc
|
||||
${CCSRC_DIR}/gvar/logging_level.cc
|
||||
${CCSRC_DIR}/gvar/typeid_manager.cc
|
||||
${CORE_DIR}/gvar/logging_level.cc
|
||||
${CORE_DIR}/gvar/typeid_manager.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../core/base/base.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/log_adapter.cc
|
||||
)
|
||||
|
|
|
@ -110,5 +110,5 @@ if (ENABLE_ACL)
|
|||
target_link_libraries(ms_serving ${ALC_LIB_SO})
|
||||
target_link_libraries(ms_serving jpeg_turbo::jpeg)
|
||||
else ()
|
||||
target_link_libraries(ms_serving inference mindspore_gvar)
|
||||
target_link_libraries(ms_serving inference)
|
||||
endif ()
|
||||
|
|
|
@ -180,12 +180,12 @@ if (ENABLE_GE)
|
|||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES} pthread util dl)
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::gtest ${PYTHON_LIBRARIES} pthread util dl)
|
||||
if (ENABLE_MINDDATA)
|
||||
target_link_libraries(ut_tests PRIVATE _c_dataengine _c_mindrecord)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::gtest ${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
if (USE_GLOG)
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::glog)
|
||||
|
|
Loading…
Reference in New Issue