forked from mindspore-Ecosystem/mindspore
build core.so
Signed-off-by: zhoufeng <zhoufeng54@huawei.com>
This commit is contained in:
parent
b7efcd3991
commit
8e97ce5cd2
|
@ -90,7 +90,7 @@ install(
|
|||
)
|
||||
|
||||
install(
|
||||
TARGETS mindspore_gvar
|
||||
TARGETS mindspore_core
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
|
|
@ -307,7 +307,7 @@ if(PLATFORM_ARM64)
|
|||
DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libglog.so.0
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
|
||||
install(TARGETS mindspore_core DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${opencv_LIBPATH}/libopencv_core.so.4.5.2
|
||||
DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libopencv_core.so.4.5
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
|
@ -327,6 +327,8 @@ if(PLATFORM_ARM64)
|
|||
DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${RUNTIME_LIB_DIR} RENAME libglog.so.0
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(TARGETS mindspore_core DESTINATION ${CONVERTER_ROOT_DIR}/lib
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "cloud" AND MSLITE_ENABLE_RUNTIME_CONVERT)
|
||||
file(GLOB DATA_ENGINE_LIB_LIST ${LITE_ACL_DIR}/_c_dataengine/*.so)
|
||||
|
@ -517,6 +519,7 @@ elseif(WIN32)
|
|||
DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${glog_LIBPATH}/../bin/libglog.dll DESTINATION ${CONVERTER_ROOT_DIR}/lib
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(TARGETS mindspore_core DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
file(GLOB_RECURSE OPENCV_LIB_LIST
|
||||
${opencv_LIBPATH}/../bin/libopencv_core*
|
||||
${opencv_LIBPATH}/../bin/libopencv_imgcodecs*
|
||||
|
@ -670,7 +673,7 @@ else()
|
|||
DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libglog.so.0
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
|
||||
install(TARGETS mindspore_core DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${opencv_LIBPATH}/libopencv_core.so.4.5.2
|
||||
DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libopencv_core.so.4.5
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
|
@ -690,6 +693,7 @@ else()
|
|||
DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${RUNTIME_LIB_DIR} RENAME libglog.so.0
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(TARGETS mindspore_core DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "cloud" AND MSLITE_ENABLE_RUNTIME_CONVERT)
|
||||
file(GLOB DATA_ENGINE_LIB_LIST ${LITE_ACL_DIR}/_c_dataengine/*.so)
|
||||
|
|
|
@ -67,7 +67,7 @@ install(
|
|||
)
|
||||
|
||||
install(
|
||||
TARGETS mindspore_gvar
|
||||
TARGETS mindspore_core
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
|
|
@ -27,7 +27,7 @@ install(
|
|||
)
|
||||
|
||||
install(
|
||||
TARGETS mindspore_gvar
|
||||
TARGETS mindspore_core
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
|
|
@ -74,7 +74,7 @@ install(
|
|||
)
|
||||
|
||||
install(
|
||||
TARGETS mindspore_gvar
|
||||
TARGETS mindspore_core
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
|
|
@ -213,6 +213,11 @@ if(MODE_ASCEND_ALL)
|
|||
add_compile_definitions(ENABLE_D)
|
||||
endif()
|
||||
|
||||
# core/mindir.proto
|
||||
file(GLOB_RECURSE CORE_PROTO_IN ${CMAKE_SOURCE_DIR}/mindspore/core/proto/*.proto)
|
||||
ms_protobuf_generate(CORE_PROTO_SRC CORE_PROTO_HDR ${CORE_PROTO_IN})
|
||||
list(APPEND MINDSPORE_PROTO_LIST ${CORE_PROTO_SRC})
|
||||
|
||||
if(MINDSPORE_PROTO_LIST)
|
||||
add_library(proto_input STATIC ${MINDSPORE_PROTO_LIST})
|
||||
set_target_properties(proto_input PROPERTIES COMPILE_FLAGS "-Wno-unused-variable")
|
||||
|
@ -250,21 +255,19 @@ endforeach()
|
|||
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(mindspore mindspore_core)
|
||||
|
||||
if(ENABLE_DEBUGGER)
|
||||
# debugger: link grpc
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
target_link_libraries(mindspore mindspore::grpc++)
|
||||
target_link_libraries(mindspore PUBLIC mindspore::grpc++)
|
||||
else()
|
||||
target_link_libraries(mindspore -Wl,--no-as-needed mindspore::grpc++)
|
||||
target_link_libraries(mindspore PUBLIC -Wl,--no-as-needed mindspore::grpc++)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(mindspore securec mindspore::flatbuffers)
|
||||
target_link_libraries(mindspore PUBLIC securec mindspore::flatbuffers)
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(mindspore dl)
|
||||
target_link_libraries(mindspore PUBLIC dl)
|
||||
endif()
|
||||
|
||||
if(MODE_ASCEND_ALL OR MODE_ASCEND_ACL)
|
||||
|
@ -301,7 +304,7 @@ if(ENABLE_D)
|
|||
find_library(GE_RUNNER ge_runner ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
find_library(GRAPH graph ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
find_library(HCCL hccl ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH})
|
||||
target_link_libraries(mindspore ${GE_RUNNER} ${GRAPH} ${HCCL})
|
||||
target_link_libraries(mindspore PUBLIC ${GE_RUNNER} ${GRAPH} ${HCCL})
|
||||
endif()
|
||||
|
||||
if(MODE_ASCEND_ALL)
|
||||
|
@ -326,16 +329,16 @@ if(MODE_ASCEND_ALL)
|
|||
find_library(OPT_FEATURE opt_feature ${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH}
|
||||
${ASCEND_RUNTIME_NEW_PATH} ${ASCEND_TOOLKIT_RUNTIME_NEW_PATH})
|
||||
|
||||
target_link_libraries(mindspore ${RUNTIME_LIB} ${TSDCLIENT} ${DATATRANSFER} ${ERROR_MANAGER} -Wl,--no-as-needed
|
||||
${OPTILING} ${PLATFORM} ${ACL} ${ACL_TDT_CHANNEL} ${OPT_FEATURE} ${PROFILING})
|
||||
target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf -Wl,--end-group)
|
||||
target_link_libraries(mindspore PUBLIC ${RUNTIME_LIB} ${TSDCLIENT} ${DATATRANSFER} ${ERROR_MANAGER}
|
||||
-Wl,--no-as-needed ${OPTILING} ${PLATFORM} ${ACL} ${ACL_TDT_CHANNEL} ${OPT_FEATURE} ${PROFILING})
|
||||
target_link_libraries(mindspore PUBLIC -Wl,--start-group proto_input mindspore::protobuf -Wl,--end-group)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf mindspore::sentencepiece
|
||||
target_link_libraries(mindspore PUBLIC -Wl,--start-group proto_input mindspore::protobuf mindspore::sentencepiece
|
||||
-Wl,--end-group)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
target_link_libraries(mindspore -Wl proto_input mindspore::protobuf mindspore::sentencepiece -Wl)
|
||||
target_link_libraries(mindspore PUBLIC -Wl proto_input mindspore::protobuf mindspore::sentencepiece -Wl)
|
||||
else()
|
||||
target_link_libraries(mindspore -Wl,--start-group proto_input mindspore::protobuf -Wl,--end-group)
|
||||
target_link_libraries(mindspore PUBLIC -Wl,--start-group proto_input mindspore::protobuf -Wl,--end-group)
|
||||
endif()
|
||||
|
||||
# set c_expression building
|
||||
|
@ -375,29 +378,26 @@ set(MINDSPORE_RPATH ${ORIGIN_PATH}/lib:${MINDSPORE_RPATH})
|
|||
set_target_properties(_c_expression PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH})
|
||||
|
||||
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 mindspore_core -Wl,--no-whole-archive)
|
||||
target_link_libraries(mindspore PUBLIC mindspore::pybind11_module)
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore_core)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
target_link_libraries(mindspore proto_input mindspore::protobuf
|
||||
target_link_libraries(mindspore PUBLIC proto_input mindspore::protobuf
|
||||
mindspore::event mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json)
|
||||
target_link_libraries(mindspore mindspore::event_core ps_cache)
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,-all_load mindspore mindspore_core proto_input -Wl,-noall_load)
|
||||
target_link_libraries(mindspore PUBLIC mindspore::event_core ps_cache)
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,-all_load mindspore proto_input -Wl,-noall_load mindspore_core)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore::pybind11_module)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore_gvar)
|
||||
else()
|
||||
if(ENABLE_CPU AND NOT WIN32)
|
||||
target_link_libraries(mindspore proto_input mindspore::protobuf
|
||||
target_link_libraries(mindspore PUBLIC proto_input mindspore::protobuf
|
||||
mindspore::event mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json)
|
||||
target_link_libraries(mindspore -Wl,--no-as-needed mindspore::event_core ps_cache)
|
||||
target_link_libraries(mindspore PUBLIC -Wl,--no-as-needed mindspore::event_core ps_cache)
|
||||
if(${ENABLE_IBVERBS} STREQUAL "ON")
|
||||
target_link_libraries(mindspore ibverbs rdmacm)
|
||||
target_link_libraries(mindspore PUBLIC ibverbs rdmacm)
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore mindspore_core
|
||||
proto_input -Wl,--no-whole-archive)
|
||||
target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore proto_input -Wl,--no-whole-archive
|
||||
mindspore_core)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore::pybind11_module)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore_gvar)
|
||||
endif()
|
||||
|
||||
if(USE_GLOG)
|
||||
|
@ -405,7 +405,7 @@ if(USE_GLOG)
|
|||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
target_link_libraries(mindspore mindspore::crypto mindspore::ssl)
|
||||
target_link_libraries(mindspore PUBLIC mindspore::crypto mindspore::ssl)
|
||||
endif()
|
||||
|
||||
if(ENABLE_GPU)
|
||||
|
|
|
@ -37,9 +37,6 @@ NativeCpuKernelModFactory &NativeCpuKernelModFactory::GetInstance() {
|
|||
void NativeCpuKernelModFactory::Register(const std::string &kernel_name, const KernelAttr &kernel_attr,
|
||||
NativeCpuKernelModCreator &&kernel_creator) {
|
||||
(void)name_to_attr_creator_[kernel_name].emplace_back(kernel_attr, kernel_creator);
|
||||
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__APPLE__)
|
||||
MS_LOG(DEBUG) << "NativeCpuKernelModFactory register operator: " << kernel_name;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeCpuKernelMod> NativeCpuKernelModFactory::Create(const std::string &kernel_name,
|
||||
|
|
|
@ -172,7 +172,7 @@ void InsertTransformOpForOutput(const FuncGraphPtr &graph, const AnfNodePtr &nod
|
|||
}
|
||||
} // namespace
|
||||
|
||||
const mindspore::HashSet<std::string> kChannelLastKernel = {prim::kPrimBiasAdd->name()};
|
||||
const mindspore::HashSet<std::string> kChannelLastKernel = {prim::kBiasAdd};
|
||||
|
||||
bool InsertFormatTransformOpCPU::Run(const FuncGraphPtr &graph) {
|
||||
MS_EXCEPTION_IF_NULL(graph);
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace opt {
|
||||
const mindspore::HashSet<std::string> kConv3DKernel = {prim::kPrimConv3DBackpropInput->name(),
|
||||
prim::kPrimConv3DBackpropFilter->name(),
|
||||
prim::kPrimConv3D->name(), prim::kPrimConv3DTranspose->name()};
|
||||
|
||||
void InsertCast(const FuncGraphPtr &graph, const AnfNodePtr &node, size_t i, const TypeId &src_type,
|
||||
const TypeId &cast_type) {
|
||||
MS_EXCEPTION_IF_NULL(graph);
|
||||
|
@ -71,7 +67,9 @@ bool InsertCastGPU::Run(const FuncGraphPtr &graph) {
|
|||
if (node == nullptr || !node->isa<CNode>() || !AnfUtils::IsRealKernel(node)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
static const mindspore::HashSet<std::string> kConv3DKernel = {
|
||||
prim::kPrimConv3DBackpropInput->name(), prim::kPrimConv3DBackpropFilter->name(), prim::kPrimConv3D->name(),
|
||||
prim::kPrimConv3DTranspose->name()};
|
||||
if (kConv3DKernel.find(AnfAlgo::GetCNodeName(node)) == kConv3DKernel.end()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -55,9 +55,7 @@ constexpr size_t kPartialFuncGraphPos = 1;
|
|||
constexpr size_t kSwitchLayerBranchPos = 2;
|
||||
constexpr size_t kSwitchTrueBranchPos = 2;
|
||||
constexpr size_t kMakeTupleInputStartPos = 1;
|
||||
const std::set<std::string> kNodeTupleOutSet = {prim::kPrimMakeTuple->name(), prim::kPrimGetNext->name()};
|
||||
|
||||
const PrimitiveSet follow_first_input_prims = {prim::kPrimDepend, prim::kPrimLoad};
|
||||
const std::set<std::string> kNodeTupleOutSet = {prim::kMakeTuple, prim::kGetNext};
|
||||
|
||||
std::vector<size_t> TransShapeToSizet(const abstract::ShapePtr &shape) {
|
||||
MS_EXCEPTION_IF_NULL(shape);
|
||||
|
@ -367,6 +365,7 @@ KernelWithIndex AnfRuntimeAlgorithm::VisitKernelWithReturnType(const AnfNodePtr
|
|||
if (AnfAlgo::CheckPrimitiveType(cnode, prim::kPrimUpdateState)) {
|
||||
return VisitKernelWithReturnType(cnode->input(kUpdateStateStateInput), index, skip_nop_node, return_types);
|
||||
}
|
||||
const PrimitiveSet follow_first_input_prims = {prim::kPrimDepend, prim::kPrimLoad};
|
||||
if (IsOneOfPrimitiveCNode(cnode, follow_first_input_prims)) {
|
||||
return VisitKernelWithReturnType(cnode->input(kRealInputIndexInDepend), index, skip_nop_node, return_types);
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ namespace {
|
|||
constexpr auto kIsFeatureMapOutput = "IsFeatureMapOutput";
|
||||
constexpr auto kIsFeatureMapInputList = "IsFeatureMapInputList";
|
||||
constexpr size_t k5dDims = 5;
|
||||
const std::set<std::string> kOpAssignKernelNameList = {prim::kPrimAssign->name(), prim::kPrimAssignAdd->name(),
|
||||
prim::kPrimAssignSub->name()};
|
||||
const std::set<std::string> kOpAssignKernelNameList = {prim::kAssign, prim::kAssignAdd, prim::kAssignSub};
|
||||
|
||||
void PushNoVisitedNode(const AnfNodePtr &node, std::queue<AnfNodePtr> *que,
|
||||
mindspore::HashSet<AnfNodePtr> *visited_nodes) {
|
||||
|
|
|
@ -15,12 +15,6 @@ endif()
|
|||
# build mindspore_shared_lib
|
||||
include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset)
|
||||
if(NOT BUILD_LITE)
|
||||
set(LOAD_MINDIR_SRC
|
||||
${CMAKE_SOURCE_DIR}/mindspore/core/load_mindir/load_model.cc
|
||||
${CMAKE_SOURCE_DIR}/mindspore/core/load_mindir/anf_model_parser.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE API_OPS_SRC ${CMAKE_CURRENT_SOURCE_DIR} "ops/*.cc")
|
||||
|
||||
|
@ -36,11 +30,6 @@ if(ENABLE_D OR ENABLE_ACL)
|
|||
"model/model_converter_utils/*.cc"
|
||||
"graph/acl/*.cc"
|
||||
)
|
||||
|
||||
if(NOT ENABLE_D)
|
||||
list(APPEND API_ACL_SRC $<TARGET_OBJECTS:_mindspore_transform_graph_ir_obj>)
|
||||
list(APPEND API_ACL_SRC $<TARGET_OBJECTS:_mindspore_vm_obj>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_D)
|
||||
|
@ -79,25 +68,30 @@ if(BUILD_LITE)
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/types.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/model/model.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/model/model_impl.cc"
|
||||
${ACL_REMOVE_SRC}
|
||||
$<TARGET_OBJECTS:_mindspore_vm_obj>)
|
||||
${ACL_REMOVE_SRC})
|
||||
endif()
|
||||
|
||||
add_library(mindspore_shared_lib SHARED ${MSLIB_SRC})
|
||||
add_library(mindspore_shared_lib_obj OBJECT ${MSLIB_SRC})
|
||||
add_library(mindspore_shared_lib SHARED $<TARGET_OBJECTS:mindspore_shared_lib_obj>)
|
||||
if(BUILD_LITE)
|
||||
target_link_libraries(mindspore_shared_lib PRIVATE $<TARGET_OBJECTS:_mindspore_transform_graph_ir_obj>)
|
||||
elseif(ENABLE_ACL AND NOT ENABLE_D)
|
||||
target_link_libraries(mindspore_shared_lib PRIVATE $<TARGET_OBJECTS:_mindspore_transform_graph_ir_obj>
|
||||
$<TARGET_OBJECTS:_mindspore_vm_obj>)
|
||||
endif()
|
||||
if(NOT BUILD_LITE)
|
||||
set_target_properties(mindspore_shared_lib PROPERTIES OUTPUT_NAME mindspore)
|
||||
endif()
|
||||
|
||||
if(ENABLE_D OR ENABLE_GPU)
|
||||
target_link_libraries(mindspore_shared_lib PRIVATE -Wl,--as-needed ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY}
|
||||
-Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore_core proto_input mindspore_gvar
|
||||
mindspore::protobuf)
|
||||
-Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore_core proto_input mindspore::protobuf)
|
||||
else()
|
||||
if(BUILD_LITE)
|
||||
target_link_libraries(mindspore_shared_lib PRIVATE ${SECUREC_LIBRARY})
|
||||
else()
|
||||
target_link_libraries(mindspore_shared_lib PRIVATE ${PY3_LIBG} ${SECUREC_LIBRARY}
|
||||
mindspore mindspore_core proto_input mindspore_gvar mindspore::protobuf)
|
||||
mindspore mindspore_core proto_input mindspore::protobuf)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -73,11 +73,17 @@ if(ENABLE_DEBUGGER)
|
|||
target_link_libraries(_mindspore_offline_debug PRIVATE
|
||||
mindspore::pybind11_module
|
||||
mindspore::glog
|
||||
mindspore_gvar
|
||||
mindspore_core
|
||||
)
|
||||
set_target_properties(_mindspore_offline_debug PROPERTIES
|
||||
PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||
SUFFIX "${PYTHON_MODULE_EXTENSION}"
|
||||
)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set_target_properties(_mindspore_offline_debug PROPERTIES MACOSX_RPATH ON)
|
||||
set_target_properties(_mindspore_offline_debug PROPERTIES INSTALL_RPATH @loader_path/lib)
|
||||
else()
|
||||
set_target_properties(_mindspore_offline_debug PROPERTIES INSTALL_RPATH $ORIGIN/lib)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -137,7 +137,7 @@ if(ENABLE_CACHE)
|
|||
add_dependencies(engine-cache-server core)
|
||||
endif()
|
||||
################### Create _c_dataengine Library ######################
|
||||
set(submodules
|
||||
set(dataengine_submodules
|
||||
$<TARGET_OBJECTS:core>
|
||||
$<TARGET_OBJECTS:callback>
|
||||
$<TARGET_OBJECTS:utils>
|
||||
|
@ -170,36 +170,33 @@ set(submodules
|
|||
$<TARGET_OBJECTS:kernels-ir>
|
||||
$<TARGET_OBJECTS:kernels-ir-data>
|
||||
$<TARGET_OBJECTS:kernels-ir-vision>
|
||||
$<TARGET_OBJECTS:md_plugin>
|
||||
)
|
||||
$<TARGET_OBJECTS:md_plugin>)
|
||||
|
||||
if(ENABLE_ACL)
|
||||
set(submodules
|
||||
${submodules}
|
||||
set(dataengine_submodules
|
||||
${dataengine_submodules}
|
||||
$<TARGET_OBJECTS:kernels-dvpp-image>
|
||||
$<TARGET_OBJECTS:dvpp-utils>)
|
||||
endif()
|
||||
|
||||
if(ENABLE_PYTHON)
|
||||
set(submodules
|
||||
${submodules}
|
||||
set(dataengine_submodules
|
||||
${dataengine_submodules}
|
||||
$<TARGET_OBJECTS:APItoPython>)
|
||||
endif()
|
||||
|
||||
if(ENABLE_TDTQUE)
|
||||
if(NOT ENABLE_SECURITY)
|
||||
add_library(_c_dataengine SHARED ${submodules} $<TARGET_OBJECTS:engine-perf> $<TARGET_OBJECTS:engine-tdt>)
|
||||
else()
|
||||
add_library(_c_dataengine SHARED ${submodules} $<TARGET_OBJECTS:engine-tdt>)
|
||||
set(dataengine_submodules ${dataengine_submodules} $<TARGET_OBJECTS:engine-perf>)
|
||||
endif()
|
||||
set(dataengine_submodules ${dataengine_submodules} $<TARGET_OBJECTS:engine-tdt>)
|
||||
else()
|
||||
if(NOT ENABLE_SECURITY)
|
||||
add_library(_c_dataengine SHARED ${submodules} $<TARGET_OBJECTS:engine-perf>)
|
||||
else()
|
||||
add_library(_c_dataengine SHARED ${submodules})
|
||||
set(dataengine_submodules ${dataengine_submodules} $<TARGET_OBJECTS:engine-perf>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(dataengine_submodules ${dataengine_submodules} CACHE INTERNAL "_c_dataengine objects")
|
||||
add_library(_c_dataengine SHARED ${dataengine_submodules})
|
||||
if(ENABLE_PYTHON)
|
||||
set_target_properties(_c_dataengine PROPERTIES
|
||||
PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||
|
@ -210,10 +207,8 @@ endif()
|
|||
######################################################################
|
||||
|
||||
################# Link with external libraries ########################
|
||||
if(MSLITE_ENABLE_CLOUD_MIND_DATA)
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore_gvar)
|
||||
else()
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar)
|
||||
if(NOT MSLITE_ENABLE_CLOUD_MIND_DATA)
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
|
|
@ -76,8 +76,8 @@ if(ENABLE_CACHE)
|
|||
_c_dataengine
|
||||
_c_mindrecord
|
||||
mindspore
|
||||
mindspore_core
|
||||
mindspore::protobuf
|
||||
mindspore_gvar
|
||||
${CUDNN_LIBRARY_PATH}
|
||||
${PYTHON_LIBRARIES}
|
||||
${SECUREC_LIBRARY}
|
||||
|
@ -91,8 +91,8 @@ if(ENABLE_CACHE)
|
|||
_c_dataengine
|
||||
_c_mindrecord
|
||||
mindspore
|
||||
mindspore_core
|
||||
mindspore::protobuf
|
||||
mindspore_gvar
|
||||
${PYTHON_LIBRARIES}
|
||||
${SECUREC_LIBRARY}
|
||||
pthread
|
||||
|
|
|
@ -10,7 +10,6 @@ if(ENABLE_CACHE)
|
|||
_c_mindrecord
|
||||
mindspore
|
||||
mindspore::protobuf
|
||||
mindspore_gvar
|
||||
${PYTHON_LIBRARIES}
|
||||
pthread)
|
||||
|
||||
|
@ -24,7 +23,6 @@ if(ENABLE_CACHE)
|
|||
_c_mindrecord
|
||||
mindspore
|
||||
mindspore::protobuf
|
||||
mindspore_gvar
|
||||
${PYTHON_LIBRARIES}
|
||||
pthread)
|
||||
|
||||
|
|
|
@ -36,3 +36,4 @@ if(ENABLE_PYTHON)
|
|||
endif()
|
||||
|
||||
add_library(engine-datasetops OBJECT ${DATASET_ENGINE_DATASETOPS_SRC_FILES})
|
||||
add_dependencies(engine-datasetops engine-cache-client)
|
||||
|
|
|
@ -23,7 +23,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
|
|||
|
||||
# add shared link library
|
||||
set_property(SOURCE ${DIR_LIB_SRCS} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD)
|
||||
add_library(_c_mindrecord SHARED ${DIR_LIB_SRCS})
|
||||
add_library(mindrecord_obj OBJECT ${DIR_LIB_SRCS})
|
||||
add_library(_c_mindrecord SHARED $<TARGET_OBJECTS:mindrecord_obj>)
|
||||
|
||||
set_target_properties(_c_mindrecord PROPERTIES
|
||||
PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||
|
@ -32,15 +33,15 @@ 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_gvar mindspore::protobuf)
|
||||
mindspore::protobuf)
|
||||
if(NOT MSLITE_ENABLE_CLOUD_MIND_DATA)
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore_core)
|
||||
if(USE_GLOG)
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::glog)
|
||||
else()
|
||||
|
|
|
@ -65,7 +65,6 @@ class TaskFactory {
|
|||
class Register {
|
||||
public:
|
||||
Register(const TaskInfoType &type, const TASK_CREATOR_FUN &func) {
|
||||
MS_LOG(DEBUG) << "register type " << type;
|
||||
TaskFactory::GetInstance().RegisterCreator(type, func);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ void SyncTensorData(const TensorPtr &host_tensor, const DeviceTensorPtr &device_
|
|||
MS_EXCEPTION_IF_NULL(node);
|
||||
MS_EXCEPTION_IF_NULL(device_context);
|
||||
MS_EXCEPTION_IF_NULL(context);
|
||||
|
||||
if ((device_tensor->GetPtr() == nullptr) &&
|
||||
(!device_context->AllocateMemory(device_tensor.get(), device_tensor->GetSize()))) {
|
||||
SET_OPCONTEXT_MEMORY_ALLOC_FAIL_BY_STRATEGY(strategy, *context, *device_context, node->fullname_with_scope(),
|
||||
|
|
|
@ -84,23 +84,18 @@ size_t CountValueNum(const ValueTuplePtr &value_tuple);
|
|||
// to CNode{kPrimTupleGetItem, SparseTensor, int64_t(index)}, used
|
||||
// in backend common optimization pass: sparse_process.cc
|
||||
const mindspore::HashMap<std::string, int64_t> sparse_attr_map = {
|
||||
{prim::kPrimCSRTensorGetIndptr->name(), 0}, {prim::kPrimCSRTensorGetIndices->name(), 1},
|
||||
{prim::kPrimCSRTensorGetValues->name(), 2}, {prim::kPrimCSRTensorGetDenseShape->name(), 3},
|
||||
{prim::kPrimCOOTensorGetIndices->name(), 0}, {prim::kPrimCOOTensorGetValues->name(), 1},
|
||||
{prim::kPrimCOOTensorGetDenseShape->name(), 2}};
|
||||
{prim::kCSRTensorGetIndptr, 0}, {prim::kCSRTensorGetIndices, 1}, {prim::kCSRTensorGetValues, 2},
|
||||
{prim::kCSRTensorGetDenseShape, 3}, {prim::kCOOTensorGetIndices, 0}, {prim::kCOOTensorGetValues, 1},
|
||||
{prim::kCOOTensorGetDenseShapes, 2}};
|
||||
// make_sparse_set records all make_sparse primitives, and tries to replace
|
||||
// make_sparse to make_tuple, used in backend common optimization pass:
|
||||
// sparse_process.cc
|
||||
const mindspore::HashSet<std::string> make_sparse_set = {{prim::kPrimMakeCSRTensor->name()},
|
||||
{prim::kPrimMakeCOOTensor->name()}};
|
||||
const mindspore::HashSet<std::string> make_sparse_set = {{prim::kMakeCSRTensor}, {prim::kMakeCOOTensor}};
|
||||
// sparse_op_set records all sparse_compute operators, which takes sparsetensor
|
||||
// and (possibly) dense tensors, used in backend common optimization pass:
|
||||
// sparse_process.cc
|
||||
const mindspore::HashSet<std::string> sparse_op_set = {{prim::kPrimCOOTensorDenseMatmul->name()},
|
||||
{prim::kPrimCSRDenseMul->name()},
|
||||
{prim::kPrimCSRReduceSum->name()},
|
||||
{prim::kPrimCSRMV->name()},
|
||||
{prim::kPrimCSRMul->name()}};
|
||||
const mindspore::HashSet<std::string> sparse_op_set = {
|
||||
{prim::kSparseTensorDenseMatmul}, {prim::kCSRDenseMul}, {prim::kCSRReduceSum}, {prim::kCSRMV}, {prim::kCSRMul}};
|
||||
|
||||
bool IsCustomCSROP(const AnfNodePtr &cnode);
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -14,8 +14,6 @@ if(NOT(BUILD_LITE))
|
|||
add_subdirectory(mindrt)
|
||||
endif()
|
||||
|
||||
message("************ build core ***************")
|
||||
|
||||
file(GLOB_RECURSE CORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"abstract/*.cc"
|
||||
"base/*.cc"
|
||||
|
@ -48,9 +46,23 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|||
endif()
|
||||
|
||||
set_property(SOURCE ${CORE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_CORE)
|
||||
set_property(SOURCE ${PROTO_SRCS} PROPERTY COMPILE_OPTIONS -Wno-array-bounds)
|
||||
add_library(mindspore_core STATIC ${CORE_SRC_LIST} ${PROTO_SRCS})
|
||||
target_link_libraries(mindspore_core PRIVATE mindspore_gvar)
|
||||
add_library(core_obj OBJECT ${CORE_SRC_LIST})
|
||||
add_library(core_proto_obj OBJECT ${PROTO_SRCS})
|
||||
add_library(mindspore_core SHARED $<TARGET_OBJECTS:core_obj> $<TARGET_OBJECTS:core_proto_obj>
|
||||
$<TARGET_OBJECTS:mindspore_gvar>)
|
||||
target_link_libraries(mindspore_core PRIVATE mindspore::protobuf securec)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
target_link_options(mindspore_core PRIVATE -Wl,-init,mindspore_log_init)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set_target_properties(mindspore_core PROPERTIES MACOSX_RPATH ON)
|
||||
set_target_properties(mindspore_core PROPERTIES INSTALL_RPATH @loader_path)
|
||||
else()
|
||||
set_target_properties(mindspore_core PROPERTIES INSTALL_RPATH $ORIGIN)
|
||||
endif()
|
||||
|
||||
if(NOT(BUILD_LITE))
|
||||
target_link_libraries(mindspore_core PRIVATE mindrt_mid)
|
||||
endif()
|
||||
|
@ -65,3 +77,4 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|||
add_compile_definitions(ENABLE_OPENSSL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ static inline bool IsUndeterminedType(const TypePtr &type) {
|
|||
return (type != nullptr) && (type->type_id() == kObjectTypeUndeterminedType);
|
||||
}
|
||||
|
||||
AbstractBase::TraceNodeProvider AbstractBase::trace_node_provider_ = nullptr;
|
||||
|
||||
bool AbstractBase::operator==(const AbstractBase &other) const {
|
||||
if (this == &other) {
|
||||
// Same object.
|
||||
|
|
|
@ -151,7 +151,7 @@ class MS_CORE_API AbstractBase : public Base {
|
|||
trace_node_provider_ = trace_node_provider;
|
||||
}
|
||||
|
||||
inline static TraceNodeProvider trace_node_provider_ = nullptr;
|
||||
static TraceNodeProvider trace_node_provider_;
|
||||
|
||||
/// \brief Broaden the abstract. It will upgrade the abstract to a higher level.
|
||||
///
|
||||
|
@ -1580,7 +1580,7 @@ class MS_CORE_API AbstractCSRTensor : public AbstractUndetermined {
|
|||
};
|
||||
using AbstractCSRTensorPtr = std::shared_ptr<AbstractCSRTensor>;
|
||||
|
||||
class AbstractMonad : public AbstractBase {
|
||||
class MS_CORE_API AbstractMonad : public AbstractBase {
|
||||
public:
|
||||
~AbstractMonad() override = default;
|
||||
MS_DECLARE_PARENT(AbstractMonad, AbstractBase)
|
||||
|
@ -1600,7 +1600,7 @@ class AbstractMonad : public AbstractBase {
|
|||
};
|
||||
using AbstractMonadPtr = std::shared_ptr<AbstractMonad>;
|
||||
|
||||
class AbstractUMonad final : public AbstractMonad {
|
||||
class MS_CORE_API AbstractUMonad final : public AbstractMonad {
|
||||
public:
|
||||
explicit AbstractUMonad(const ValuePtr &value = kUMonad) : AbstractMonad(value, kUMonadType) {}
|
||||
~AbstractUMonad() override = default;
|
||||
|
@ -1613,7 +1613,7 @@ class AbstractUMonad final : public AbstractMonad {
|
|||
};
|
||||
using AbstractUMonadPtr = std::shared_ptr<AbstractUMonad>;
|
||||
|
||||
class AbstractIOMonad final : public AbstractMonad {
|
||||
class MS_CORE_API AbstractIOMonad final : public AbstractMonad {
|
||||
public:
|
||||
explicit AbstractIOMonad(const ValuePtr &value = kIOMonad) : AbstractMonad(value, kIOMonadType) {}
|
||||
~AbstractIOMonad() override = default;
|
||||
|
@ -1627,10 +1627,11 @@ class AbstractIOMonad final : public AbstractMonad {
|
|||
using AbstractIOMonadPtr = std::shared_ptr<AbstractIOMonad>;
|
||||
|
||||
AnfNodePtr GetTraceNode(const AbstractBasePtr &abs);
|
||||
std::string ExtractLoggingInfo(const std::string &info);
|
||||
|
||||
void SynchronizeSequenceElementsUseFlagsRecursively(const AbstractSequencePtr &lhs_sequence,
|
||||
const AbstractSequencePtr &rhs_sequence);
|
||||
MS_CORE_API std::string ExtractLoggingInfo(const std::string &info);
|
||||
|
||||
MS_CORE_API void SynchronizeSequenceElementsUseFlagsRecursively(const AbstractSequencePtr &lhs_sequence,
|
||||
const AbstractSequencePtr &rhs_sequence);
|
||||
} // namespace abstract
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CORE_ABSTRACT_ABSTRACT_VALUE_H_
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "utils/hash_map.h"
|
||||
#include "abstract/abstract_value.h"
|
||||
#include "ir/meta_func_graph.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace abstract {
|
||||
|
@ -36,7 +37,7 @@ using ArgsSpecToAnalysisContextMap =
|
|||
std::unordered_map<AbstractBasePtrList, AnalysisContextWeakPtr, AbstractBasePtrListHasher, AbstractBasePtrListEqual>;
|
||||
|
||||
// AnalysisContext will be stored in Config in AnalysisCache.
|
||||
class AnalysisContext {
|
||||
class MS_CORE_API AnalysisContext {
|
||||
public:
|
||||
AnalysisContext(const AnalysisContextPtr &parent, const FuncGraphPtr &fg, const AbstractBasePtrList &args_spec_list)
|
||||
: parent_(parent), func_graph_(fg), args_spec_list_(args_spec_list) {
|
||||
|
|
|
@ -37,6 +37,7 @@ std::string ShapeVectorToStr(const std::vector<int64_t> &shp) {
|
|||
return buffer.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// used for print BaseShape content
|
||||
std::ostream &operator<<(std::ostream &os, const BaseShape &bs) {
|
||||
os << bs.ToString();
|
||||
|
@ -128,24 +129,6 @@ BaseShapePtrList SequenceShape::ElementsClone() const {
|
|||
return ele_list;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool SequenceShape::SequenceEqual(const BaseShape &other) const {
|
||||
if (tid() != other.tid()) {
|
||||
return false;
|
||||
}
|
||||
auto other_shapes = static_cast<const T &>(other).p_shapes_;
|
||||
if (other_shapes.size() != p_shapes_.size()) {
|
||||
return false;
|
||||
}
|
||||
for (uint64_t i = 0; i < p_shapes_.size(); ++i) {
|
||||
MS_EXCEPTION_IF_NULL(p_shapes_[i]);
|
||||
MS_EXCEPTION_IF_NULL(other_shapes[i]);
|
||||
if (!(*p_shapes_[i] == *other_shapes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template bool SequenceShape::SequenceEqual<TupleShape>(const BaseShape &) const;
|
||||
template bool SequenceShape::SequenceEqual<ListShape>(const BaseShape &) const;
|
||||
} // namespace abstract
|
||||
|
|
|
@ -108,7 +108,7 @@ class MS_CORE_API NoShape final : public BaseShape {
|
|||
bool IsDimUnknown() const override { return false; }
|
||||
};
|
||||
|
||||
inline const std::shared_ptr<NoShape> kNoShape = std::make_shared<NoShape>();
|
||||
MS_CORE_API inline const std::shared_ptr<NoShape> kNoShape = std::make_shared<NoShape>();
|
||||
|
||||
/// \brief Shape defines dimensions of tensor.
|
||||
class MS_CORE_API Shape final : public BaseShape {
|
||||
|
@ -235,7 +235,23 @@ class MS_CORE_API SequenceShape : public BaseShape {
|
|||
/// \param[in] other Another SequenceShape object.
|
||||
/// \return True if current SequenceShape object is equal to another BaseShape object, otherwise false.
|
||||
template <typename T>
|
||||
bool SequenceEqual(const BaseShape &other) const;
|
||||
bool SequenceEqual(const BaseShape &other) const {
|
||||
if (tid() != other.tid()) {
|
||||
return false;
|
||||
}
|
||||
auto other_shapes = static_cast<const T &>(other).p_shapes_;
|
||||
if (other_shapes.size() != p_shapes_.size()) {
|
||||
return false;
|
||||
}
|
||||
for (uint64_t i = 0; i < p_shapes_.size(); ++i) {
|
||||
MS_EXCEPTION_IF_NULL(p_shapes_[i]);
|
||||
MS_EXCEPTION_IF_NULL(other_shapes[i]);
|
||||
if (!(*p_shapes_[i] == *other_shapes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// \brief Get all element-shapes.
|
||||
///
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "abstract/utils.h"
|
||||
#include "utils/any.h"
|
||||
#include "ir/primitive.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace abstract {
|
||||
|
@ -45,10 +46,10 @@ void CheckShapeSame(const std::string &op, const AbstractTensorPtr &tensor_base,
|
|||
|
||||
TypePtr CheckDtypeSame(const std::string &op, const AbstractTensorPtr &tensor_base, const AbstractTensorPtr &tensor);
|
||||
|
||||
int64_t CheckAxis(const std::string &op, const std::string &arg_name, const ValuePtr &axis, int64_t min, int64_t max,
|
||||
const std::string &rank_name);
|
||||
MS_CORE_API int64_t CheckAxis(const std::string &op, const std::string &arg_name, const ValuePtr &axis, int64_t min,
|
||||
int64_t max, const std::string &rank_name);
|
||||
|
||||
void CheckArgsSize(const std::string &op, const AbstractBasePtrList &args_spec_list, size_t size_expect);
|
||||
MS_CORE_API void CheckArgsSize(const std::string &op, const AbstractBasePtrList &args_spec_list, size_t size_expect);
|
||||
|
||||
void CheckShapeAllPositive(const std::string &op, const ShapeVector &shape);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ AbstractBasePtr InferImplSwitchLayer(const AnalysisEnginePtr &, const PrimitiveP
|
|||
abstract::CheckArgsSize(op_name, args_spec_list, kSwitchLayerInputNum);
|
||||
auto index = CheckArg<AbstractTensor>(op_name, args_spec_list, 0);
|
||||
auto &input_shape = index->shape()->shape();
|
||||
if (!input_shape.empty()) {
|
||||
if (!input_shape.empty() && (input_shape.size() != 1 || input_shape[0] != 1)) {
|
||||
MS_EXCEPTION(ValueError) << op_name << " index must be a 0 dimension tensor, but got a " << input_shape.size()
|
||||
<< " dimension tensor";
|
||||
}
|
||||
|
|
|
@ -45,15 +45,15 @@ struct StandardPrimitiveImplReg {
|
|||
using PrimitiveEvalImplMap =
|
||||
mindspore::HashMap<PrimitivePtr, StandardPrimitiveImplReg, PrimitiveHasher, PrimitiveEqual>;
|
||||
|
||||
PrimitiveEvalImplMap &GetPrimitiveToEvalImplMap();
|
||||
MS_CORE_API PrimitiveEvalImplMap &GetPrimitiveToEvalImplMap();
|
||||
|
||||
PrimitiveEvalImplMap &GetPrimitiveToBackendEvalImplMap();
|
||||
MS_CORE_API PrimitiveEvalImplMap &GetPrimitiveToBackendEvalImplMap();
|
||||
|
||||
StandardPrimitiveImplReg GetPrimitiveInferImpl(const PrimitivePtr &primitive);
|
||||
MS_CORE_API StandardPrimitiveImplReg GetPrimitiveInferImpl(const PrimitivePtr &primitive);
|
||||
|
||||
std::set<int64_t> GetDependsFormMap(const CNodePtr &cnode);
|
||||
MS_CORE_API std::set<int64_t> GetDependsFormMap(const CNodePtr &cnode);
|
||||
|
||||
void RegisterStandardPrimitiveImpl(const PrimitivePtr &primitive, const StandardPrimitiveImplReg &impl_reg);
|
||||
MS_CORE_API void RegisterStandardPrimitiveImpl(const PrimitivePtr &primitive, const StandardPrimitiveImplReg &impl_reg);
|
||||
|
||||
class RegisterStandardPrimitiveEvalHelper {
|
||||
public:
|
||||
|
|
|
@ -28,21 +28,22 @@
|
|||
#include "utils/any.h"
|
||||
#include "utils/misc.h"
|
||||
#include "utils/shape_utils.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace abstract {
|
||||
ValuePtr ValueJoin(const ValuePtr &value1, const ValuePtr &value2);
|
||||
TypePtr TypeJoin(const TypePtr &type1, const TypePtr &type2);
|
||||
MS_CORE_API TypePtr TypeJoin(const TypePtr &type1, const TypePtr &type2);
|
||||
ShapePtr ShapeJoin(const ShapePtr &shape1, const ShapePtr &shape2);
|
||||
|
||||
AbstractBasePtr AbstractJoin(const AbstractBasePtrList &args_spec_list);
|
||||
AbstractBasePtrList AbstractJoin(const AbstractBasePtrList &spec1, const AbstractBasePtrList &spec2);
|
||||
MS_CORE_API AbstractBasePtr AbstractJoin(const AbstractBasePtrList &args_spec_list);
|
||||
MS_CORE_API AbstractBasePtrList AbstractJoin(const AbstractBasePtrList &spec1, const AbstractBasePtrList &spec2);
|
||||
|
||||
// Return an abstract value for the sensitivity of x.
|
||||
// The sensitivity of a function is an Env
|
||||
// The sensitivity of J(x) is x
|
||||
// else self.Clone;
|
||||
AbstractBasePtr SensitivityTransform(const AbstractBasePtr &spec);
|
||||
MS_CORE_API AbstractBasePtr SensitivityTransform(const AbstractBasePtr &spec);
|
||||
|
||||
ShapeVector BroadcastShape(ShapeVector shpx, ShapeVector shpy);
|
||||
|
||||
|
@ -56,8 +57,8 @@ T ShapeSize(const std::vector<T> &shape) {
|
|||
void CheckMinMaxShape(const ShapeVector &shape, ShapeVector *min_shape, ShapeVector *max_shape);
|
||||
|
||||
AbstractBasePtr MakeAbstract(const BaseShapePtr &base_shape, const TypePtr &type);
|
||||
AbstractBasePtr MakeMonadAbstract(const MonadTypePtr &type);
|
||||
AbstractBasePtr MakeAbstractTensor(const ShapePtr &shape, const TypePtr &type);
|
||||
MS_CORE_API AbstractBasePtr MakeMonadAbstract(const MonadTypePtr &type);
|
||||
MS_CORE_API AbstractBasePtr MakeAbstractTensor(const ShapePtr &shape, const TypePtr &type);
|
||||
} // namespace abstract
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CORE_ABSTRACT_UTILS_H_
|
||||
|
|
|
@ -52,7 +52,7 @@ using is_value = std::is_base_of<Value, remove_reference_t<T>>;
|
|||
template <typename T>
|
||||
using is_base_ref = std::is_base_of<BaseRef, remove_reference_t<T>>;
|
||||
|
||||
iterator ConstIteratorCast(std::vector<BaseRef> *v, const_iterator iter);
|
||||
MS_CORE_API iterator ConstIteratorCast(std::vector<BaseRef> *v, const_iterator iter);
|
||||
|
||||
inline std::shared_ptr<VectorRef> MakeNode(const std::vector<BaseRef> &elements) {
|
||||
return std::make_shared<VectorRef>(elements);
|
||||
|
@ -272,7 +272,7 @@ T cast(const BaseRef &handle) {
|
|||
}
|
||||
} // namespace utils
|
||||
|
||||
class VectorRef : public BaseRef {
|
||||
class MS_CORE_API VectorRef : public BaseRef {
|
||||
public:
|
||||
using value_type = BaseRef;
|
||||
|
||||
|
@ -366,7 +366,7 @@ struct VectorRefHash {
|
|||
std::size_t operator()(const VectorRef &c) const { return c.hash(); }
|
||||
};
|
||||
|
||||
class SetRef : public BaseRef {
|
||||
class MS_CORE_API SetRef : public BaseRef {
|
||||
public:
|
||||
SetRef() {}
|
||||
explicit SetRef(const std::set<BaseRef, BaseRefLess> &elements) : elements_(elements) {}
|
||||
|
@ -411,7 +411,7 @@ class SetRef : public BaseRef {
|
|||
|
||||
using SetRefPtr = std::shared_ptr<SetRef>;
|
||||
|
||||
class RunFunctionRef : public BaseRef {
|
||||
class MS_CORE_API RunFunctionRef : public BaseRef {
|
||||
public:
|
||||
RunFunctionRef() {}
|
||||
explicit RunFunctionRef(const RunFuncPtr &ref_func) : func_(ref_func) {}
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
#include "base/base_ref.h"
|
||||
|
||||
namespace mindspore {
|
||||
std::vector<tensor::TensorPtr> TransformVectorRefToMultiTensor(const VectorRef &base_ref);
|
||||
MS_CORE_API std::vector<tensor::TensorPtr> TransformVectorRefToMultiTensor(const VectorRef &base_ref);
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CORE_BASE_BASE_REF_UTILS_H
|
||||
|
|
|
@ -1,23 +1,4 @@
|
|||
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)
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -O2")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF")
|
||||
add_compile_definitions(BUILDING_DLL)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wuser-defined-warnings -Winconsistent-missing-override")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_LITE)
|
||||
add_library(mindspore_gvar STATIC ${MS_GVAR_SRC_LIST})
|
||||
else()
|
||||
add_library(mindspore_gvar SHARED ${MS_GVAR_SRC_LIST})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(mindspore_gvar PROPERTIES MACOSX_RPATH ON)
|
||||
endif()
|
||||
add_library(mindspore_gvar OBJECT ${MS_GVAR_SRC_LIST})
|
||||
target_compile_definitions(mindspore_gvar PRIVATE BUILDING_DLL)
|
||||
|
|
|
@ -20,42 +20,43 @@
|
|||
#include "utils/log_adapter.h"
|
||||
|
||||
namespace mindspore {
|
||||
static const std::vector<std::string> sub_module_names = {
|
||||
"UNKNOWN", // SM_UNKNOWN
|
||||
"CORE", // SM_CORE
|
||||
"ANALYZER", // SM_ANALYZER
|
||||
"COMMON", // SM_COMMON
|
||||
"DEBUG", // SM_DEBUG
|
||||
"OFFLINE_DEBUG", // SM_OFFLINE_DEBUG
|
||||
"DEVICE", // SM_DEVICE
|
||||
"GE_ADPT", // SM_GE_ADPT
|
||||
"IR", // SM_IR
|
||||
"KERNEL", // SM_KERNEL
|
||||
"MD", // SM_MD
|
||||
"ME", // SM_ME
|
||||
"EXPRESS", // SM_EXPRESS
|
||||
"OPTIMIZER", // SM_OPTIMIZER
|
||||
"PARALLEL", // SM_PARALLEL
|
||||
"PARSER", // SM_PARSER
|
||||
"PIPELINE", // SM_PIPELINE
|
||||
"PRE_ACT", // SM_PRE_ACT
|
||||
"PYNATIVE", // SM_PYNATIVE
|
||||
"SESSION", // SM_SESSION
|
||||
"UTILS", // SM_UTILS
|
||||
"VM", // SM_VM
|
||||
"PROFILER", // SM_PROFILER
|
||||
"PS", // SM_PS
|
||||
"FL", // SM_FL
|
||||
"DISTRIBUTED", // SM_DISTRIBUTED
|
||||
"LITE", // SM_LITE
|
||||
"ARMOUR", // SM_ARMOUR
|
||||
"HCCL_ADPT", // SM_HCCL_ADPT
|
||||
"RUNTIME_FRAMEWORK", // SM_RUNTIME_FRAMEWORK
|
||||
"GE", // SM_GE
|
||||
"API", // SM_API
|
||||
};
|
||||
|
||||
const std::string GetSubModuleName(SubModuleId module_id) { return sub_module_names[(module_id % NUM_SUBMODUES)]; }
|
||||
const std::string GetSubModuleName(SubModuleId module_id) {
|
||||
static const std::vector<std::string> sub_module_names = {
|
||||
"UNKNOWN", // SM_UNKNOWN
|
||||
"CORE", // SM_CORE
|
||||
"ANALYZER", // SM_ANALYZER
|
||||
"COMMON", // SM_COMMON
|
||||
"DEBUG", // SM_DEBUG
|
||||
"OFFLINE_DEBUG", // SM_OFFLINE_DEBUG
|
||||
"DEVICE", // SM_DEVICE
|
||||
"GE_ADPT", // SM_GE_ADPT
|
||||
"IR", // SM_IR
|
||||
"KERNEL", // SM_KERNEL
|
||||
"MD", // SM_MD
|
||||
"ME", // SM_ME
|
||||
"EXPRESS", // SM_EXPRESS
|
||||
"OPTIMIZER", // SM_OPTIMIZER
|
||||
"PARALLEL", // SM_PARALLEL
|
||||
"PARSER", // SM_PARSER
|
||||
"PIPELINE", // SM_PIPELINE
|
||||
"PRE_ACT", // SM_PRE_ACT
|
||||
"PYNATIVE", // SM_PYNATIVE
|
||||
"SESSION", // SM_SESSION
|
||||
"UTILS", // SM_UTILS
|
||||
"VM", // SM_VM
|
||||
"PROFILER", // SM_PROFILER
|
||||
"PS", // SM_PS
|
||||
"FL", // SM_FL
|
||||
"DISTRIBUTED", // SM_DISTRIBUTED
|
||||
"LITE", // SM_LITE
|
||||
"ARMOUR", // SM_ARMOUR
|
||||
"HCCL_ADPT", // SM_HCCL_ADPT
|
||||
"RUNTIME_FRAMEWORK", // SM_RUNTIME_FRAMEWORK
|
||||
"GE", // SM_GE
|
||||
"API", // SM_API
|
||||
};
|
||||
return sub_module_names[(module_id % NUM_SUBMODUES)];
|
||||
}
|
||||
|
||||
// export GetTimeString for all sub modules
|
||||
std::string GetTimeString() {
|
||||
|
|
|
@ -1076,16 +1076,16 @@ static S GetValue(const ValuePtr &value) {
|
|||
return v;
|
||||
}
|
||||
|
||||
std::string GetCNodeFuncName(CNodePtr cnode);
|
||||
MS_CORE_API std::string GetCNodeFuncName(CNodePtr cnode);
|
||||
|
||||
// used to get FuncGraphPtr from a cnode first input
|
||||
FuncGraphPtr GetCNodeFuncGraph(const AnfNodePtr &node);
|
||||
MS_CORE_API FuncGraphPtr GetCNodeFuncGraph(const AnfNodePtr &node);
|
||||
|
||||
// used to check whether an AnfNode is a cnode with a kind of Primitive as first input
|
||||
bool IsPrimitiveCNode(const AnfNodePtr &node, const PrimitivePtr &value = nullptr);
|
||||
MS_CORE_API bool IsPrimitiveCNode(const AnfNodePtr &node, const PrimitivePtr &value = nullptr);
|
||||
|
||||
// used to get PrimitivePtr from a cnode first input
|
||||
PrimitivePtr GetCNodePrimitive(const AnfNodePtr &node);
|
||||
MS_CORE_API PrimitivePtr GetCNodePrimitive(const AnfNodePtr &node);
|
||||
|
||||
/// \brief Used to check whether the given node is a ValueNode with some Primitive value.
|
||||
///
|
||||
|
@ -1105,28 +1105,28 @@ bool IsOneOfPrimitive(const AnfNodePtr &node, const PrimitiveSet &prim_set);
|
|||
MS_CORE_API bool IsOneOfPrimitiveCNode(const AnfNodePtr &node, const PrimitiveSet &prim_set);
|
||||
|
||||
// Check whether two primitives are same.
|
||||
bool IsPrimitiveEquals(const PrimitivePtr &prim1, const PrimitivePtr &prim2);
|
||||
MS_CORE_API bool IsPrimitiveEquals(const PrimitivePtr &prim1, const PrimitivePtr &prim2);
|
||||
|
||||
// Get number of AbstractMonad
|
||||
size_t GetAbstractMonadNum(const AbstractBasePtrList &args);
|
||||
MS_CORE_API size_t GetAbstractMonadNum(const AbstractBasePtrList &args);
|
||||
|
||||
// Check whether the given node has monad abstract.
|
||||
bool HasAbstractMonad(const AnfNodePtr &node);
|
||||
MS_CORE_API bool HasAbstractMonad(const AnfNodePtr &node);
|
||||
|
||||
// Check whether the given node has U monad abstract.
|
||||
bool HasAbstractUMonad(const AnfNodePtr &node);
|
||||
MS_CORE_API bool HasAbstractUMonad(const AnfNodePtr &node);
|
||||
|
||||
// Check whether the given node has IO monad abstract.
|
||||
bool HasAbstractIOMonad(const AnfNodePtr &node);
|
||||
MS_CORE_API bool HasAbstractIOMonad(const AnfNodePtr &node);
|
||||
|
||||
// Gets primitive attribute value as a bool flag.
|
||||
bool GetPrimitiveFlag(const PrimitivePtr &prim, const std::string &attr);
|
||||
MS_CORE_API bool GetPrimitiveFlag(const PrimitivePtr &prim, const std::string &attr);
|
||||
|
||||
// Gets effect info from a primitive by its attributes.
|
||||
EffectInfo GetPrimEffectInfo(const PrimitivePtr &prim);
|
||||
MS_CORE_API EffectInfo GetPrimEffectInfo(const PrimitivePtr &prim);
|
||||
|
||||
// Check if monad state is equivalent for the connected two nodes, not strict but more faster.
|
||||
bool IsStateEquivalent(const AnfNodePtr &outer, const AnfNodePtr &inner);
|
||||
MS_CORE_API bool IsStateEquivalent(const AnfNodePtr &outer, const AnfNodePtr &inner);
|
||||
|
||||
// used to check whether a ValueNode has some kind of value
|
||||
template <typename T>
|
||||
|
@ -1163,17 +1163,17 @@ inline S GetValueNode(const AnfNodePtr &node) {
|
|||
return s;
|
||||
}
|
||||
|
||||
size_t NewSeenGeneration();
|
||||
MS_CORE_API size_t NewSeenGeneration();
|
||||
|
||||
namespace id_generator {
|
||||
std::string get_id(const AnfNodePtr &node);
|
||||
void reset_id();
|
||||
MS_CORE_API std::string get_id(const AnfNodePtr &node);
|
||||
MS_CORE_API void reset_id();
|
||||
} // namespace id_generator
|
||||
using TaggedNodeMap = mindspore::HashMap<AnfNodePtr, size_t>;
|
||||
using TaggedGraph = std::pair<FuncGraphPtr, TaggedNodeMap>;
|
||||
std::string GetCNodeTarget(const AnfNodePtr &node);
|
||||
MS_CORE_API std::string GetCNodeTarget(const AnfNodePtr &node);
|
||||
std::string GetOriginNodeTarget(const AnfNodePtr &node);
|
||||
bool ContainMultiTarget(const std::vector<AnfNodePtr> &nodes);
|
||||
MS_CORE_API bool ContainMultiTarget(const std::vector<AnfNodePtr> &nodes);
|
||||
struct GraphSegment {
|
||||
GraphSegment(const std::vector<AnfNodePtr> &nodes, bool is_cut) : nodes_(nodes), is_cut_(is_cut) {}
|
||||
void AddPreSegment(const std::shared_ptr<GraphSegment> &segment) { (void)pre_segments_.insert(segment); }
|
||||
|
@ -1194,11 +1194,10 @@ inline void SetSequenceNodeElementsUseFlags(const AnfNodePtr &node, const std::s
|
|||
}
|
||||
|
||||
// Set the sequence nodes' elements use flags to 'new_flag' at specific 'index' position.
|
||||
void SetSequenceElementsUseFlags(const AbstractBasePtr &abs, std::size_t index, bool new_flag);
|
||||
MS_CORE_API void SetSequenceElementsUseFlags(const AbstractBasePtr &abs, std::size_t index, bool new_flag);
|
||||
// Set the sequence nodes' elements use flags all to 'new_flag'.
|
||||
void SetSequenceElementsUseFlags(const AbstractBasePtr &abs, bool new_flag);
|
||||
MS_CORE_API void SetSequenceElementsUseFlags(const AbstractBasePtr &abs, bool new_flag);
|
||||
// Set the sequence nodes' elements use flags all to 'new_flag' recursively.
|
||||
void SetSequenceElementsUseFlagsRecursively(const AbstractBasePtr &abs, bool new_flag);
|
||||
MS_CORE_API void SetSequenceElementsUseFlagsRecursively(const AbstractBasePtr &abs, bool new_flag);
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_ANF_H_
|
||||
|
|
|
@ -424,20 +424,20 @@ struct MS_CORE_API TypeListEqual {
|
|||
bool operator()(TypePtrList const &lhs, TypePtrList const &rhs) const;
|
||||
};
|
||||
|
||||
inline const TypePtr kTypeExternal = std::make_shared<External>();
|
||||
inline const TypePtr kTypeEnv = std::make_shared<EnvType>();
|
||||
inline const TypePtr kTypeType = std::make_shared<TypeType>();
|
||||
inline const TypePtr kString = std::make_shared<String>();
|
||||
inline const TypePtr kList = std::make_shared<List>();
|
||||
inline const TypePtr kTuple = std::make_shared<Tuple>();
|
||||
inline const TypePtr kDict = std::make_shared<Dictionary>();
|
||||
inline const TypePtr kSlice = std::make_shared<Slice>();
|
||||
inline const TypePtr kKeyword = std::make_shared<Keyword>();
|
||||
inline const TypePtr kTensorType = std::make_shared<TensorType>();
|
||||
inline const TypePtr kTensorTypeFP16 = std::make_shared<TensorType>(std::make_shared<Float>(16));
|
||||
inline const TypePtr kTensorTypeFP32 = std::make_shared<TensorType>(std::make_shared<Float>(32));
|
||||
inline const TypePtr kTensorTypeFP64 = std::make_shared<TensorType>(std::make_shared<Float>(64));
|
||||
inline const TypePtr kCSRTensorType = std::make_shared<CSRTensorType>();
|
||||
MS_CORE_API inline const TypePtr kTypeExternal = std::make_shared<External>();
|
||||
MS_CORE_API inline const TypePtr kTypeEnv = std::make_shared<EnvType>();
|
||||
MS_CORE_API inline const TypePtr kTypeType = std::make_shared<TypeType>();
|
||||
MS_CORE_API inline const TypePtr kString = std::make_shared<String>();
|
||||
MS_CORE_API inline const TypePtr kList = std::make_shared<List>();
|
||||
MS_CORE_API inline const TypePtr kTuple = std::make_shared<Tuple>();
|
||||
MS_CORE_API inline const TypePtr kDict = std::make_shared<Dictionary>();
|
||||
MS_CORE_API inline const TypePtr kSlice = std::make_shared<Slice>();
|
||||
MS_CORE_API inline const TypePtr kKeyword = std::make_shared<Keyword>();
|
||||
MS_CORE_API inline const TypePtr kTensorType = std::make_shared<TensorType>();
|
||||
MS_CORE_API inline const TypePtr kTensorTypeFP16 = std::make_shared<TensorType>(std::make_shared<Float>(16));
|
||||
MS_CORE_API inline const TypePtr kTensorTypeFP32 = std::make_shared<TensorType>(std::make_shared<Float>(32));
|
||||
MS_CORE_API inline const TypePtr kTensorTypeFP64 = std::make_shared<TensorType>(std::make_shared<Float>(64));
|
||||
MS_CORE_API inline const TypePtr kCSRTensorType = std::make_shared<CSRTensorType>();
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_DTYPE_H_
|
||||
|
|
|
@ -101,10 +101,10 @@ class MS_CORE_API TypeEllipsis : public Type {
|
|||
};
|
||||
using TypeEllipsisPtr = std::shared_ptr<TypeEllipsis>;
|
||||
|
||||
inline const TypePtr kTypeNone = std::make_shared<TypeNone>();
|
||||
inline const TypePtr kTypeNull = std::make_shared<TypeNull>();
|
||||
inline const TypePtr kTypeEllipsis = std::make_shared<TypeEllipsis>();
|
||||
inline const TypePtr kAnyType = std::make_shared<TypeAnything>();
|
||||
MS_CORE_API inline const TypePtr kTypeNone = std::make_shared<TypeNone>();
|
||||
MS_CORE_API inline const TypePtr kTypeNull = std::make_shared<TypeNull>();
|
||||
MS_CORE_API inline const TypePtr kTypeEllipsis = std::make_shared<TypeEllipsis>();
|
||||
MS_CORE_API inline const TypePtr kAnyType = std::make_shared<TypeAnything>();
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_DTYPE_EMPTY_H_
|
||||
|
|
|
@ -63,8 +63,8 @@ class IOMonadType : public MonadType {
|
|||
};
|
||||
using IOMonadTypePtr = std::shared_ptr<IOMonadType>;
|
||||
|
||||
extern const TypePtr kIOMonadType;
|
||||
extern const TypePtr kUMonadType;
|
||||
MS_CORE_API extern const TypePtr kIOMonadType;
|
||||
MS_CORE_API extern const TypePtr kUMonadType;
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_DTYPE_MONDA_H_
|
||||
|
|
|
@ -228,24 +228,24 @@ class MS_CORE_API Complex : public Number {
|
|||
std::string DumpText() const override { return std::string("C") + std::to_string(nbits()); }
|
||||
};
|
||||
|
||||
inline const TypePtr kBool = std::make_shared<Bool>();
|
||||
inline const TypePtr kInt8 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits8));
|
||||
inline const TypePtr kInt16 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits16));
|
||||
inline const TypePtr kInt32 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits32));
|
||||
inline const TypePtr kInt64 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits64));
|
||||
inline const TypePtr kUInt8 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits8));
|
||||
inline const TypePtr kUInt16 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits16));
|
||||
inline const TypePtr kUInt32 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits32));
|
||||
inline const TypePtr kUInt64 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits64));
|
||||
inline const TypePtr kFloat16 = std::make_shared<Float>(static_cast<int>(BitsNum::eBits16));
|
||||
inline const TypePtr kFloat32 = std::make_shared<Float>(static_cast<int>(BitsNum::eBits32));
|
||||
inline const TypePtr kFloat64 = std::make_shared<Float>(static_cast<int>(BitsNum::eBits64));
|
||||
inline const TypePtr kInt = std::make_shared<Int>();
|
||||
inline const TypePtr kUInt = std::make_shared<UInt>();
|
||||
inline const TypePtr kFloat = std::make_shared<Float>();
|
||||
inline const TypePtr kNumber = std::make_shared<Number>();
|
||||
inline const TypePtr kComplex64 = std::make_shared<Complex>(static_cast<int>(BitsNum::eBits64));
|
||||
inline const TypePtr kComplex128 = std::make_shared<Complex>(static_cast<int>(BitsNum::eBits128));
|
||||
MS_CORE_API inline const TypePtr kBool = std::make_shared<Bool>();
|
||||
MS_CORE_API inline const TypePtr kInt8 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits8));
|
||||
MS_CORE_API inline const TypePtr kInt16 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits16));
|
||||
MS_CORE_API inline const TypePtr kInt32 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits32));
|
||||
MS_CORE_API inline const TypePtr kInt64 = std::make_shared<Int>(static_cast<int>(BitsNum::eBits64));
|
||||
MS_CORE_API inline const TypePtr kUInt8 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits8));
|
||||
MS_CORE_API inline const TypePtr kUInt16 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits16));
|
||||
MS_CORE_API inline const TypePtr kUInt32 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits32));
|
||||
MS_CORE_API inline const TypePtr kUInt64 = std::make_shared<UInt>(static_cast<int>(BitsNum::eBits64));
|
||||
MS_CORE_API inline const TypePtr kFloat16 = std::make_shared<Float>(static_cast<int>(BitsNum::eBits16));
|
||||
MS_CORE_API inline const TypePtr kFloat32 = std::make_shared<Float>(static_cast<int>(BitsNum::eBits32));
|
||||
MS_CORE_API inline const TypePtr kFloat64 = std::make_shared<Float>(static_cast<int>(BitsNum::eBits64));
|
||||
MS_CORE_API inline const TypePtr kInt = std::make_shared<Int>();
|
||||
MS_CORE_API inline const TypePtr kUInt = std::make_shared<UInt>();
|
||||
MS_CORE_API inline const TypePtr kFloat = std::make_shared<Float>();
|
||||
MS_CORE_API inline const TypePtr kNumber = std::make_shared<Number>();
|
||||
MS_CORE_API inline const TypePtr kComplex64 = std::make_shared<Complex>(static_cast<int>(BitsNum::eBits64));
|
||||
MS_CORE_API inline const TypePtr kComplex128 = std::make_shared<Complex>(static_cast<int>(BitsNum::eBits128));
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_DTYPE_NUMBER_H_
|
||||
|
|
|
@ -65,8 +65,8 @@ class MS_CORE_API RefType final : public TensorType {
|
|||
};
|
||||
using RefTypePtr = std::shared_ptr<RefType>;
|
||||
|
||||
inline const TypePtr kRefKeyType = std::make_shared<RefKeyType>();
|
||||
inline const TypePtr kRefType = std::make_shared<RefType>();
|
||||
MS_CORE_API inline const TypePtr kRefKeyType = std::make_shared<RefKeyType>();
|
||||
MS_CORE_API inline const TypePtr kRefType = std::make_shared<RefType>();
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_DTYPE_REF_H_
|
||||
|
|
|
@ -48,9 +48,9 @@ TypeId ComplexBitsToTypeId(const int nbits);
|
|||
/// \param[in] v Define the input TypeId.
|
||||
/// \return The label of input TypeId.
|
||||
MS_CORE_API const std::string &TypeIdLabel(const TypeId &v);
|
||||
TypeId NormalizeTypeId(const TypeId type_id);
|
||||
MS_CORE_API TypeId NormalizeTypeId(const TypeId type_id);
|
||||
bool IsSameObjectType(const Type &lhs, const Type &rhs);
|
||||
size_t GetTypeByte(const TypePtr &type_ptr);
|
||||
MS_CORE_API size_t GetTypeByte(const TypePtr &type_ptr);
|
||||
|
||||
enum class BitsNum : int {
|
||||
eBits8 = 8,
|
||||
|
@ -166,14 +166,14 @@ class MS_CORE_API Type : public Value {
|
|||
/// \param[in] os The ostream to receive the description
|
||||
/// \param[in] type The Type object need to show the description
|
||||
/// \return The ostream with Type object description
|
||||
friend std::ostream &operator<<(std::ostream &os, const Type &type);
|
||||
MS_CORE_API friend std::ostream &operator<<(std::ostream &os, const Type &type);
|
||||
|
||||
/// \brief Get Type object ToString description.
|
||||
///
|
||||
/// \param[in] os The ostream to receive the description
|
||||
/// \param[in] type The TypePtr need to show the description
|
||||
/// \return The ostream with Type object description
|
||||
friend std::ostream &operator<<(std::ostream &os, const TypePtr type);
|
||||
MS_CORE_API friend std::ostream &operator<<(std::ostream &os, const TypePtr type);
|
||||
|
||||
private:
|
||||
TypeId meta_type_;
|
||||
|
|
|
@ -795,4 +795,6 @@ api::FuncGraphPtr api::FuncGraph::GetFuncGraphFromAnfNode(const AnfNodePtr &inpu
|
|||
auto fg = GetValueNode<mindspore::FuncGraphPtr>(input);
|
||||
return fg;
|
||||
}
|
||||
|
||||
FuncGraph::Drawer FuncGraph::drawer_ = nullptr;
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "api/ir/func_graph.h"
|
||||
#include "ir/func_graph_transform.h"
|
||||
#include "ir/func_graph_base.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
using BaseRefCounterMap = OrderedMap<BaseRef, int, BaseRefHash>;
|
||||
|
@ -95,7 +96,7 @@ const char kFuncGraphFlagBackPropEntry[] = "BackPropEntry";
|
|||
const char kFuncGraphFlagReAutoMonad[] = "ReAutoMonad";
|
||||
const char kFuncGraphFlagRecursive[] = "Recursive";
|
||||
|
||||
class FuncGraph : public deprecated::api::FuncGraph, public FuncGraphBase, public EffectInfoHolder {
|
||||
class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGraphBase, public EffectInfoHolder {
|
||||
public:
|
||||
using Drawer = std::function<void(const std::string &, const FuncGraphPtr &)>;
|
||||
|
||||
|
@ -435,7 +436,7 @@ class FuncGraph : public deprecated::api::FuncGraph, public FuncGraphBase, publi
|
|||
// CNode order which relates to origin code order.
|
||||
OrderedSet<CNodePtr> order_;
|
||||
bool stub_;
|
||||
inline static Drawer drawer_ = nullptr;
|
||||
static Drawer drawer_;
|
||||
// Design switch_input and switch_layer_input as a ptr to
|
||||
// share between derived backpropagator and cloned graphs.
|
||||
std::shared_ptr<bool> switch_input_;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
namespace mindspore {
|
||||
class FuncGraphBase;
|
||||
using FuncGraphBasePtr = std::shared_ptr<FuncGraphBase>;
|
||||
class FuncGraphLoopBreaker {
|
||||
class MS_CORE_API FuncGraphLoopBreaker {
|
||||
public:
|
||||
~FuncGraphLoopBreaker();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "ir/func_graph.h"
|
||||
#include "ir/manager.h"
|
||||
#include "utils/hashing.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
class Cloner;
|
||||
|
@ -54,7 +55,7 @@ struct UpdateInfo {
|
|||
|
||||
using UpdateInfoPtr = std::shared_ptr<UpdateInfo>;
|
||||
|
||||
class Cloner {
|
||||
class MS_CORE_API Cloner {
|
||||
public:
|
||||
explicit Cloner(const FuncGraphVector &func_graphs = {}, bool clone_all_valuenodes = false,
|
||||
bool clone_all_child_graphs = true, bool clone_all_used_graphs = false,
|
||||
|
@ -134,17 +135,17 @@ class Cloner {
|
|||
mindspore::HashMap<FuncGraphPtr, AnfNodePtrList> repl_func_graph_params_;
|
||||
};
|
||||
|
||||
AnfNodePtr InlineClone(const FuncGraphPtr &func_graph, const FuncGraphPtr &target_func_graph,
|
||||
const AnfNodePtrList &func_graph_args, const ScopePtr &scope = nullptr);
|
||||
MS_CORE_API AnfNodePtr InlineClone(const FuncGraphPtr &func_graph, const FuncGraphPtr &target_func_graph,
|
||||
const AnfNodePtrList &func_graph_args, const ScopePtr &scope = nullptr);
|
||||
|
||||
FuncGraphPtr LiftingClone(const FuncGraphPtr &func_graph);
|
||||
MS_CORE_API FuncGraphPtr LiftingClone(const FuncGraphPtr &func_graph);
|
||||
|
||||
ClonerPtr SpecializerClone(const FuncGraphPtr &func_graph, const TraceInfoPtr &relation);
|
||||
MS_CORE_API ClonerPtr SpecializerClone(const FuncGraphPtr &func_graph, const TraceInfoPtr &relation);
|
||||
|
||||
FuncGraphPtr TransformableClone(const FuncGraphPtr &func_graph,
|
||||
const TraceInfoPtr &relation = std::make_shared<TraceTransform>());
|
||||
FuncGraphPtr BasicClone(const FuncGraphPtr &func_graph, bool clone_value_nodes = false,
|
||||
const UpdateInfoPtr update_info = nullptr);
|
||||
MS_CORE_API FuncGraphPtr TransformableClone(const FuncGraphPtr &func_graph,
|
||||
const TraceInfoPtr &relation = std::make_shared<TraceTransform>());
|
||||
MS_CORE_API FuncGraphPtr BasicClone(const FuncGraphPtr &func_graph, bool clone_value_nodes = false,
|
||||
const UpdateInfoPtr update_info = nullptr);
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_IR_FUNC_GRAPH_CLONER_H_
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
namespace mindspore {
|
||||
// ANF transform class.
|
||||
// Either a primitive or a func_graph.
|
||||
class FuncGraphTransform {
|
||||
class MS_CORE_API FuncGraphTransform {
|
||||
public:
|
||||
enum Type { kGtPrimitive, kGtFuncGraph };
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "ir/scalar.h"
|
||||
#include "ir/tensor.h"
|
||||
#include "utils/label.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
enum IncludeType { FOLLOW, NOFOLLOW, EXCLUDE };
|
||||
|
@ -46,29 +47,31 @@ using MatchFunc = std::function<bool(const CNodePtr &)>;
|
|||
using NodeVisitFunc = std::function<void(const AnfNodePtr &)>;
|
||||
|
||||
std::vector<AnfNodePtr> SuccDeeper(const AnfNodePtr &node);
|
||||
std::vector<AnfNodePtr> SuccDeeperSimple(const AnfNodePtr &node);
|
||||
std::vector<AnfNodePtr> SuccIncoming(const AnfNodePtr &node);
|
||||
MS_CORE_API std::vector<AnfNodePtr> SuccDeeperSimple(const AnfNodePtr &node);
|
||||
MS_CORE_API std::vector<AnfNodePtr> SuccIncoming(const AnfNodePtr &node);
|
||||
std::vector<AnfNodePtr> SuccIncludeFV(const FuncGraphPtr &fg, const AnfNodePtr &node);
|
||||
|
||||
const std::vector<AnfNodePtr> &GetInputs(const AnfNodePtr &node);
|
||||
MS_CORE_API const std::vector<AnfNodePtr> &GetInputs(const AnfNodePtr &node);
|
||||
|
||||
inline IncludeType AlwaysInclude(const AnfNodePtr &) { return FOLLOW; }
|
||||
IncludeType IncludeBelongGraph(const FuncGraphPtr &fg, const AnfNodePtr &node);
|
||||
MS_CORE_API IncludeType IncludeBelongGraph(const FuncGraphPtr &fg, const AnfNodePtr &node);
|
||||
|
||||
std::vector<AnfNodePtr> DeepScopedGraphSearch(const AnfNodePtr &root, const IncludeFunc &include = AlwaysInclude);
|
||||
MS_CORE_API std::vector<AnfNodePtr> DeepScopedGraphSearch(const AnfNodePtr &root,
|
||||
const IncludeFunc &include = AlwaysInclude);
|
||||
|
||||
std::vector<AnfNodePtr> DeepLinkedGraphSearch(const AnfNodePtr &root, const IncludeFunc &include = AlwaysInclude);
|
||||
MS_CORE_API std::vector<AnfNodePtr> DeepLinkedGraphSearch(const AnfNodePtr &root,
|
||||
const IncludeFunc &include = AlwaysInclude);
|
||||
|
||||
std::vector<AnfNodePtr> DeepScopedGraphSearchWithFilter(const AnfNodePtr &root, const IncludeFunc &include,
|
||||
const FilterFunc &filter);
|
||||
MS_CORE_API std::vector<AnfNodePtr> DeepScopedGraphSearchWithFilter(const AnfNodePtr &root, const IncludeFunc &include,
|
||||
const FilterFunc &filter);
|
||||
|
||||
std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &root, const SuccFunc &succ = SuccIncoming,
|
||||
const IncludeFunc &include = AlwaysInclude);
|
||||
MS_CORE_API std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &root, const SuccFunc &succ = SuccIncoming,
|
||||
const IncludeFunc &include = AlwaysInclude);
|
||||
|
||||
std::vector<CNodePtr> BroadFirstSearchGraphCNodes(const CNodePtr &start);
|
||||
MS_CORE_API std::vector<CNodePtr> BroadFirstSearchGraphCNodes(const CNodePtr &start);
|
||||
std::vector<FuncGraphPtr> BroadFirstSearchGraphUsed(const FuncGraphPtr &root);
|
||||
|
||||
CNodePtr BroadFirstSearchFirstOf(const std::vector<CNodePtr> &starts, const MatchFunc &match_predicate);
|
||||
MS_CORE_API CNodePtr BroadFirstSearchFirstOf(const std::vector<CNodePtr> &starts, const MatchFunc &match_predicate);
|
||||
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -66,11 +66,11 @@ using FuncGraphSetPtr = std::shared_ptr<FuncGraphSet>;
|
|||
// func_graph, be managed graph
|
||||
// manage: if true, created manager will be set in func_graph
|
||||
// FuncGraphManagerPtr: return created manager
|
||||
FuncGraphManagerPtr Manage(FuncGraphPtr func_graph, bool manage = true);
|
||||
MS_CORE_API FuncGraphManagerPtr Manage(FuncGraphPtr func_graph, bool manage = true);
|
||||
|
||||
FuncGraphManagerPtr Manage(const std::vector<FuncGraphPtr> &func_graphs, bool manage = true);
|
||||
MS_CORE_API FuncGraphManagerPtr Manage(const std::vector<FuncGraphPtr> &func_graphs, bool manage = true);
|
||||
|
||||
FuncGraphManagerPtr MakeManager(const std::vector<FuncGraphPtr> &func_graphs = {}, bool manage = true);
|
||||
MS_CORE_API FuncGraphManagerPtr MakeManager(const std::vector<FuncGraphPtr> &func_graphs = {}, bool manage = true);
|
||||
|
||||
struct Signals {
|
||||
Signal<void()> InvalidateComputer;
|
||||
|
@ -277,8 +277,8 @@ class FuncGraphJTotalComputer final : public DepComputer {
|
|||
bool SeekJ(const FuncGraphPtr &fg, size_t seen_num);
|
||||
};
|
||||
|
||||
class FuncGraphManager : public std::enable_shared_from_this<FuncGraphManager>,
|
||||
public deprecated::api::FuncGraphManager {
|
||||
class MS_CORE_API FuncGraphManager : public std::enable_shared_from_this<FuncGraphManager>,
|
||||
public deprecated::api::FuncGraphManager {
|
||||
public:
|
||||
explicit FuncGraphManager(const std::vector<FuncGraphPtr> &roots, bool manage = true);
|
||||
~FuncGraphManager() {
|
||||
|
@ -376,7 +376,7 @@ class FuncGraphManager : public std::enable_shared_from_this<FuncGraphManager>,
|
|||
bool is_manage_;
|
||||
};
|
||||
|
||||
class FuncGraphTransaction {
|
||||
class MS_CORE_API FuncGraphTransaction {
|
||||
public:
|
||||
explicit FuncGraphTransaction(FuncGraphManager *manager) : manager_(manager) {}
|
||||
FuncGraphTransaction() : manager_(nullptr) {}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace mindspore {
|
|||
// Graph generator.
|
||||
// Can be called with a pipeline's resources and a list of argument types to
|
||||
// generate a graph corresponding to these types.
|
||||
class MetaFuncGraph : public FuncGraphBase {
|
||||
class MS_CORE_API MetaFuncGraph : public FuncGraphBase {
|
||||
public:
|
||||
explicit MetaFuncGraph(const std::string &name) : name_(name) { cache_.clear(); }
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ class MS_CORE_API None final : public Named {
|
|||
MS_DECLARE_PARENT(None, Named);
|
||||
abstract::AbstractBasePtr ToAbstract() override;
|
||||
};
|
||||
inline const NamedPtr kNone = std::make_shared<None>();
|
||||
MS_CORE_API inline const NamedPtr kNone = std::make_shared<None>();
|
||||
|
||||
/// \beief Null defines interface for null data.
|
||||
class MS_CORE_API Null final : public Named {
|
||||
|
@ -133,7 +133,7 @@ class MS_CORE_API Null final : public Named {
|
|||
MS_DECLARE_PARENT(Null, Named);
|
||||
abstract::AbstractBasePtr ToAbstract() override;
|
||||
};
|
||||
inline const NamedPtr kNull = std::make_shared<Null>();
|
||||
MS_CORE_API inline const NamedPtr kNull = std::make_shared<Null>();
|
||||
|
||||
/// \beief Ellipsis defines interface for ... data.
|
||||
class MS_CORE_API Ellipsis final : public Named {
|
||||
|
@ -145,6 +145,7 @@ class MS_CORE_API Ellipsis final : public Named {
|
|||
MS_DECLARE_PARENT(Ellipsis, Named);
|
||||
abstract::AbstractBasePtr ToAbstract() override;
|
||||
};
|
||||
inline const NamedPtr kEllipsis = std::make_shared<Ellipsis>();
|
||||
|
||||
MS_CORE_API inline const NamedPtr kEllipsis = std::make_shared<Ellipsis>();
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CORE_IR_NAMED_H_
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ir/primal_attr.h"
|
||||
|
||||
namespace mindspore {
|
||||
PrimalAttrManager &PrimalAttrManager::GetInstance() noexcept {
|
||||
static PrimalAttrManager instance;
|
||||
return instance;
|
||||
}
|
||||
} // namespace mindspore
|
|
@ -20,18 +20,15 @@
|
|||
#include <memory>
|
||||
#include <stack>
|
||||
#include "utils/hash_map.h"
|
||||
#include "ir/anf.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
class Value;
|
||||
using ValuePtr = std::shared_ptr<Value>;
|
||||
|
||||
class PrimalAttrManager {
|
||||
class MS_CORE_API PrimalAttrManager {
|
||||
public:
|
||||
static PrimalAttrManager &GetInstance() noexcept {
|
||||
static PrimalAttrManager instance;
|
||||
return instance;
|
||||
}
|
||||
static PrimalAttrManager &GetInstance() noexcept;
|
||||
PrimalAttrManager(const PrimalAttrManager &) = delete;
|
||||
PrimalAttrManager &operator=(const PrimalAttrManager &) = delete;
|
||||
~PrimalAttrManager() = default;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ir/primal_debug_info.h"
|
||||
|
||||
namespace mindspore {
|
||||
PrimalDebugInfoManager &PrimalDebugInfoManager::GetInstance() noexcept {
|
||||
static PrimalDebugInfoManager instance;
|
||||
return instance;
|
||||
}
|
||||
} // namespace mindspore
|
|
@ -23,14 +23,12 @@
|
|||
#include <set>
|
||||
#include "utils/hash_map.h"
|
||||
#include "utils/info.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
class PrimalDebugInfoManager {
|
||||
class MS_CORE_API PrimalDebugInfoManager {
|
||||
public:
|
||||
static PrimalDebugInfoManager &GetInstance() noexcept {
|
||||
static PrimalDebugInfoManager instance;
|
||||
return instance;
|
||||
}
|
||||
static PrimalDebugInfoManager &GetInstance() noexcept;
|
||||
PrimalDebugInfoManager(const PrimalDebugInfoManager &) = delete;
|
||||
PrimalDebugInfoManager &operator=(const PrimalDebugInfoManager &) = delete;
|
||||
~PrimalDebugInfoManager() = default;
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
namespace mindspore {
|
||||
const ScopePtr kDefaultScope = std::make_shared<Scope>("Default");
|
||||
|
||||
ScopeManager &ScopeManager::GetInstance() noexcept {
|
||||
static ScopeManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void ScopeManager::EnterScope(const ScopePtr &scope) {
|
||||
if (scope != kDefaultScope) {
|
||||
scope_stack_.push(scope);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
namespace mindspore {
|
||||
class Scope;
|
||||
using ScopePtr = std::shared_ptr<Scope>;
|
||||
extern const ScopePtr kDefaultScope;
|
||||
MS_CORE_API extern const ScopePtr kDefaultScope;
|
||||
|
||||
class MS_CORE_API Scope {
|
||||
public:
|
||||
|
@ -50,10 +50,7 @@ class MS_CORE_API ScopeManager {
|
|||
/// \brief Get instance of ScopeManager.
|
||||
///
|
||||
/// \return Instance of ScopeManager.
|
||||
static ScopeManager &GetInstance() noexcept {
|
||||
static ScopeManager instance;
|
||||
return instance;
|
||||
}
|
||||
static ScopeManager &GetInstance() noexcept;
|
||||
|
||||
/// \brief Disable the default constructor.
|
||||
ScopeManager(const ScopeManager &) = delete;
|
||||
|
|
|
@ -488,7 +488,7 @@ class MS_CORE_API AnyValue : public Value {
|
|||
abstract::AbstractBasePtr ToAbstract() override;
|
||||
};
|
||||
|
||||
inline const ValuePtr kAnyValue = std::make_shared<AnyValue>();
|
||||
MS_CORE_API inline const ValuePtr kAnyValue = std::make_shared<AnyValue>();
|
||||
|
||||
/// \brief Monad defines a Value class which is used in side effect.
|
||||
class MS_CORE_API Monad : public Value {
|
||||
|
@ -535,7 +535,7 @@ class MS_CORE_API UMonad final : public Monad {
|
|||
std::string ToString() const override { return "U"; }
|
||||
};
|
||||
using UMonadPtr = std::shared_ptr<UMonad>;
|
||||
extern const ValuePtr kUMonad;
|
||||
MS_CORE_API extern const ValuePtr kUMonad;
|
||||
|
||||
/// \brief IOMonad defines a Value class which related to IO side effect.
|
||||
class MS_CORE_API IOMonad final : public Monad {
|
||||
|
@ -564,7 +564,7 @@ class MS_CORE_API IOMonad final : public Monad {
|
|||
std::string ToString() const override { return "IO"; }
|
||||
};
|
||||
using IOMonadPtr = std::shared_ptr<IOMonad>;
|
||||
extern const ValuePtr kIOMonad;
|
||||
MS_CORE_API extern const ValuePtr kIOMonad;
|
||||
|
||||
template <>
|
||||
inline const char *GetValue(const ValuePtr &value) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
namespace mindspore {
|
||||
using VisitFuncType = std::function<void(const AnfNodePtr &)>;
|
||||
using PredicateFuncType = std::function<bool(const AnfNodePtr &)>;
|
||||
class AnfIrVisitor {
|
||||
class MS_CORE_API AnfIrVisitor {
|
||||
public:
|
||||
virtual void Visit(const AnfNodePtr &);
|
||||
virtual void Visit(const CNodePtr &);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "ir/anf.h"
|
||||
|
||||
namespace mindspore {
|
||||
bool InferMindir(const FuncGraphPtr &root, const AbstractBasePtrList &args, bool raise_exception = false);
|
||||
MS_CORE_API bool InferMindir(const FuncGraphPtr &root, const AbstractBasePtrList &args, bool raise_exception = false);
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_LOAD_MINDIR_INFER_MINDIR_H
|
||||
|
|
|
@ -55,7 +55,7 @@ class Layout {
|
|||
using LayoutPtr = std::shared_ptr<Layout>;
|
||||
using LayoutMap = std::map<string, LayoutPtr>;
|
||||
|
||||
class MindIRLoader {
|
||||
class MS_CORE_API MindIRLoader {
|
||||
public:
|
||||
MindIRLoader() = default;
|
||||
MindIRLoader(bool is_lite, const unsigned char *dec_key, const size_t key_len, const std::string &dec_mode,
|
||||
|
@ -90,6 +90,6 @@ class MindIRLoader {
|
|||
};
|
||||
|
||||
std::shared_ptr<std::vector<char>> ReadProtoFile(const std::string &file);
|
||||
FuncGraphPtr ConvertStreamToFuncGraph(const char *buf, const size_t buf_size, bool is_lite = false);
|
||||
MS_CORE_API FuncGraphPtr ConvertStreamToFuncGraph(const char *buf, const size_t buf_size, bool is_lite = false);
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CORE_LOAD_MODEL_H
|
||||
|
|
|
@ -35,7 +35,7 @@ class ActorThreadPool;
|
|||
// should be at least greater than 1
|
||||
constexpr uint32_t MAX_ACTOR_RECORD_SIZE = 3;
|
||||
|
||||
class ActorBase {
|
||||
class MS_CORE_API ActorBase {
|
||||
public:
|
||||
inline const AID &GetAID() const { return id; }
|
||||
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
#include <string>
|
||||
|
||||
#include "actor/log.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
constexpr auto MINDRT_TCP = "tcp";
|
||||
constexpr auto MINDRT_UDP = "udp";
|
||||
|
||||
class AID {
|
||||
class MS_CORE_API AID {
|
||||
public:
|
||||
AID() : name(), url() {}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
#include "utils/hash_map.h"
|
||||
#include "utils/visible.h"
|
||||
#include "actor/actor.h"
|
||||
#include "async/uuid_base.h"
|
||||
#include "async/future.h"
|
||||
|
@ -48,13 +49,10 @@ struct OpData {
|
|||
int index_;
|
||||
};
|
||||
|
||||
class RandInt {
|
||||
class MS_CORE_API RandInt {
|
||||
public:
|
||||
int Get() { return rand(); }
|
||||
static RandInt &Instance() {
|
||||
static RandInt instance;
|
||||
return instance;
|
||||
}
|
||||
static RandInt &Instance();
|
||||
|
||||
private:
|
||||
RandInt() { srand(time(NULL)); }
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
namespace mindspore {
|
||||
class ActorBase;
|
||||
class IOMgr;
|
||||
class ActorMgr {
|
||||
class MS_CORE_API ActorMgr {
|
||||
public:
|
||||
static inline ActorMgr *GetActorMgrRef() { return &actorMgr; }
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "actor/op_actor.h"
|
||||
|
||||
namespace mindspore {
|
||||
RandInt &RandInt::Instance() {
|
||||
static RandInt instance;
|
||||
return instance;
|
||||
}
|
||||
} // namespace mindspore
|
|
@ -33,6 +33,8 @@
|
|||
#include <pmmintrin.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
constexpr int kDefaultSpinCount = 300000;
|
||||
constexpr int kMaxCount = 30000;
|
||||
|
@ -122,7 +124,7 @@ class Worker {
|
|||
int max_spin_count_{kMinSpinCount};
|
||||
};
|
||||
|
||||
class ThreadPool {
|
||||
class MS_CORE_API ThreadPool {
|
||||
public:
|
||||
static ThreadPool *CreateThreadPool(size_t thread_num, const std::vector<int> &core_list = {});
|
||||
virtual ~ThreadPool();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
namespace mindspore {
|
||||
namespace ops {
|
||||
constexpr auto kNameMaximumGrad = "MaximumGrad";
|
||||
class MaximumGrad : public PrimitiveC {
|
||||
class MS_CORE_API MaximumGrad : public PrimitiveC {
|
||||
public:
|
||||
MaximumGrad() : PrimitiveC(kNameMaximumGrad) { InitIOName({"x1", "x2", "grads"}, {"y1", "y2"}); }
|
||||
~MaximumGrad() = default;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
namespace mindspore {
|
||||
namespace ops {
|
||||
constexpr auto kNameMinimumGrad = "MinimumGrad";
|
||||
class MinimumGrad : public PrimitiveC {
|
||||
class MS_CORE_API MinimumGrad : public PrimitiveC {
|
||||
public:
|
||||
MinimumGrad() : PrimitiveC(kNameMinimumGrad) { InitIOName({"x1", "x2", "grads"}, {"y1", "y2"}); }
|
||||
~MinimumGrad() = default;
|
||||
|
|
|
@ -30,7 +30,7 @@ constexpr auto kInfer = "DS_Infer";
|
|||
constexpr auto kInit = "DS_Init";
|
||||
constexpr auto kUpdate = "DS_Update";
|
||||
|
||||
class AbstractScope {
|
||||
class MS_CORE_API AbstractScope {
|
||||
public:
|
||||
explicit AbstractScope(std::recursive_mutex *mu);
|
||||
AbstractScope(const AbstractScope &other) = delete;
|
||||
|
@ -43,7 +43,7 @@ class AbstractScope {
|
|||
std::recursive_mutex *mu_;
|
||||
};
|
||||
|
||||
class AnfUtils {
|
||||
class MS_CORE_API AnfUtils {
|
||||
public:
|
||||
using CustomActorCallback = std::function<void(void *args)>;
|
||||
static bool IsDimUnknown(const abstract::ShapePtr &shape);
|
||||
|
|
|
@ -37,7 +37,7 @@ std::string type(const T &t) {
|
|||
return demangle(typeid(t).name());
|
||||
}
|
||||
|
||||
class Any {
|
||||
class MS_CORE_API Any {
|
||||
public:
|
||||
// constructors
|
||||
Any() : m_ptr(nullptr), m_tpIndex(std::type_index(typeid(void))) {}
|
||||
|
|
|
@ -103,7 +103,7 @@ const std::map<CompareRange, std::pair<std::string, std::string>> kCompareRangeT
|
|||
{kIncludeRight, {"in (", "]"}},
|
||||
{kIncludeBoth, {"in [", "]"}}};
|
||||
|
||||
class CheckAndConvertUtils {
|
||||
class MS_CORE_API CheckAndConvertUtils {
|
||||
public:
|
||||
static std::vector<int64_t> CheckPositiveVector(const std::string &arg_name, const std::vector<int64_t> &arg_value,
|
||||
const std::string &prim_name);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "utils/visible.h"
|
||||
|
||||
typedef unsigned char Byte;
|
||||
namespace mindspore {
|
||||
|
@ -26,13 +27,13 @@ constexpr size_t MAX_BLOCK_SIZE = 512 * 1024 * 1024; // Maximum ciphertext segm
|
|||
constexpr size_t RESERVED_BYTE_PER_BLOCK = 50; // Reserved byte per block to save addition info
|
||||
constexpr unsigned int MAGIC_NUM = 0x7F3A5ED8; // Magic number
|
||||
|
||||
std::unique_ptr<Byte[]> Encrypt(size_t *encrypt_len, const Byte *plain_data, size_t plain_len, const Byte *key,
|
||||
size_t key_len, const std::string &enc_mode);
|
||||
std::unique_ptr<Byte[]> Decrypt(size_t *decrypt_len, const std::string &encrypt_data_path, const Byte *key,
|
||||
size_t key_len, const std::string &dec_mode);
|
||||
std::unique_ptr<Byte[]> Decrypt(size_t *decrypt_len, const Byte *model_data, size_t data_size, const Byte *key,
|
||||
size_t key_len, const std::string &dec_mode);
|
||||
bool IsCipherFile(const std::string &file_path);
|
||||
bool IsCipherFile(const Byte *model_data);
|
||||
MS_CORE_API std::unique_ptr<Byte[]> Encrypt(size_t *encrypt_len, const Byte *plain_data, size_t plain_len,
|
||||
const Byte *key, size_t key_len, const std::string &enc_mode);
|
||||
MS_CORE_API std::unique_ptr<Byte[]> Decrypt(size_t *decrypt_len, const std::string &encrypt_data_path, const Byte *key,
|
||||
size_t key_len, const std::string &dec_mode);
|
||||
MS_CORE_API std::unique_ptr<Byte[]> Decrypt(size_t *decrypt_len, const Byte *model_data, size_t data_size,
|
||||
const Byte *key, size_t key_len, const std::string &dec_mode);
|
||||
MS_CORE_API bool IsCipherFile(const std::string &file_path);
|
||||
MS_CORE_API bool IsCipherFile(const Byte *model_data);
|
||||
} // namespace mindspore
|
||||
#endif
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
class FileUtils {
|
||||
class MS_CORE_API FileUtils {
|
||||
public:
|
||||
FileUtils() = default;
|
||||
~FileUtils() = default;
|
||||
|
|
|
@ -26,6 +26,17 @@
|
|||
#include "utils/file_utils.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace {
|
||||
/// \brief Trace context stack for current thread.
|
||||
thread_local std::vector<TraceContext> trace_context_stack_;
|
||||
|
||||
/// \brief Record a debug info for print.
|
||||
thread_local DebugInfoPtr record_debug_info_ = nullptr;
|
||||
|
||||
/// \brief A flag to decide whether record a debug info or not.
|
||||
thread_local bool record_debug_info_flag_ = false;
|
||||
} // namespace
|
||||
|
||||
std::string HighLightLine(const std::string &line, int col_begin, int col_end, SourceLineTip tip) {
|
||||
std::string temp_line = line;
|
||||
if (col_begin < col_end && col_begin != -1 && col_end <= SizeToLong(temp_line.length()) &&
|
||||
|
@ -136,6 +147,13 @@ LocationPtr GraphDebugInfo::location() const {
|
|||
|
||||
void GraphDebugInfo::set_deco_location(const LocationPtr &deco_list_loc) { deco_loc_ = deco_list_loc; }
|
||||
|
||||
TraceContextPtr TraceManager::CurrentContextInfo() {
|
||||
if (!trace_context_stack_.empty()) {
|
||||
return &trace_context_stack_.back();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TraceManager::DebugTrace(const std::string &func_name, const LocationPtr &location) {
|
||||
MS_EXCEPTION_IF_NULL(location);
|
||||
(void)trace_context_stack_.emplace_back(location, func_name);
|
||||
|
@ -143,9 +161,9 @@ void TraceManager::DebugTrace(const std::string &func_name, const LocationPtr &l
|
|||
|
||||
void TraceManager::DebugTrace(const LocationPtr &location) {
|
||||
MS_EXCEPTION_IF_NULL(location);
|
||||
(void)TraceManager::trace_context_stack_.emplace_back(location);
|
||||
(void)trace_context_stack_.emplace_back(location);
|
||||
if (record_debug_info_flag_) {
|
||||
TraceManager::record_debug_info_ = std::make_shared<DebugInfo>(location);
|
||||
record_debug_info_ = std::make_shared<DebugInfo>(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,9 +171,9 @@ void TraceManager::DebugTrace(const TraceInfoPtr &trace_info) {
|
|||
MS_EXCEPTION_IF_NULL(trace_info);
|
||||
auto &debug_info = trace_info->debug_info();
|
||||
MS_EXCEPTION_IF_NULL(debug_info);
|
||||
(void)TraceManager::trace_context_stack_.emplace_back(trace_info);
|
||||
(void)trace_context_stack_.emplace_back(trace_info);
|
||||
if (record_debug_info_flag_) {
|
||||
TraceManager::record_debug_info_ = debug_info;
|
||||
record_debug_info_ = debug_info;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,12 +182,14 @@ void TraceManager::DebugTrace(const DebugInfoPtr &debug_info, const TraceInfoPtr
|
|||
MS_EXCEPTION_IF_NULL(trace_info);
|
||||
auto cloned_info = trace_info->clone();
|
||||
cloned_info->set_debug_info(debug_info);
|
||||
(void)TraceManager::trace_context_stack_.emplace_back(cloned_info);
|
||||
(void)trace_context_stack_.emplace_back(cloned_info);
|
||||
}
|
||||
|
||||
DebugInfoPtr TraceManager::record_debug_info() { return TraceManager::record_debug_info_; }
|
||||
void TraceManager::EndTrace() noexcept { trace_context_stack_.pop_back(); }
|
||||
|
||||
void TraceManager::ClearParseOrResolveDebugInfo() { TraceManager::record_debug_info_ = nullptr; }
|
||||
DebugInfoPtr TraceManager::record_debug_info() { return record_debug_info_; }
|
||||
|
||||
void TraceManager::ClearParseOrResolveDebugInfo() { record_debug_info_ = nullptr; }
|
||||
|
||||
void TraceManager::CloseRecordDebugInfoFlag() { record_debug_info_flag_ = false; }
|
||||
|
||||
|
@ -177,12 +197,6 @@ void TraceManager::OpenRecordDebugInfoFlag() { record_debug_info_flag_ = true; }
|
|||
|
||||
bool TraceManager::record_debug_info_flag() { return record_debug_info_flag_; }
|
||||
|
||||
thread_local std::vector<TraceContext> TraceManager::trace_context_stack_;
|
||||
|
||||
thread_local DebugInfoPtr TraceManager::record_debug_info_ = nullptr;
|
||||
|
||||
thread_local bool TraceManager::record_debug_info_flag_ = false;
|
||||
|
||||
LocationPtr GetFirstLocation(const DebugInfoPtr &debug_info) {
|
||||
auto tmp = debug_info;
|
||||
while (tmp != nullptr) {
|
||||
|
|
|
@ -84,12 +84,7 @@ class MS_CORE_API TraceManager {
|
|||
/// \brief Get current trace context.
|
||||
///
|
||||
/// \return The current trace context.
|
||||
static TraceContextPtr CurrentContextInfo() {
|
||||
if (!trace_context_stack_.empty()) {
|
||||
return &trace_context_stack_.back();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TraceContextPtr CurrentContextInfo();
|
||||
|
||||
/// \brief Debug trace with the given function name and location.
|
||||
///
|
||||
|
@ -114,7 +109,7 @@ class MS_CORE_API TraceManager {
|
|||
static void DebugTrace(const DebugInfoPtr &debug_info, const TraceInfoPtr &trace_info);
|
||||
|
||||
/// \brief End current debug trace.
|
||||
static void EndTrace() noexcept { trace_context_stack_.pop_back(); }
|
||||
static void EndTrace() noexcept;
|
||||
|
||||
/// \brief Clear debug info for parse or resolve.
|
||||
static void ClearParseOrResolveDebugInfo();
|
||||
|
@ -134,16 +129,6 @@ class MS_CORE_API TraceManager {
|
|||
|
||||
/// \brief Set the flag to true for recording a debug info.
|
||||
static void OpenRecordDebugInfoFlag();
|
||||
|
||||
private:
|
||||
/// \brief Trace context stack for current thread.
|
||||
thread_local static std::vector<TraceContext> trace_context_stack_;
|
||||
|
||||
/// \brief Record a debug info for print.
|
||||
thread_local static DebugInfoPtr record_debug_info_;
|
||||
|
||||
/// \brief A flag to decide whether record a debug info or not.
|
||||
thread_local static bool record_debug_info_flag_;
|
||||
};
|
||||
|
||||
class TraceGuard {
|
||||
|
@ -317,7 +302,7 @@ class MS_CORE_API NodeDebugInfo : public DebugInfo {
|
|||
|
||||
using NodeDebugInfoPtr = std::shared_ptr<NodeDebugInfo>;
|
||||
|
||||
class GraphDebugInfo : public DebugInfo {
|
||||
class MS_CORE_API GraphDebugInfo : public DebugInfo {
|
||||
public:
|
||||
GraphDebugInfo() : DebugInfo() {
|
||||
auto top = TraceManager::CurrentContextInfo();
|
||||
|
@ -388,11 +373,11 @@ inline TraceContext::TraceContext(const LocationPtr &loc, const std::string &fun
|
|||
}
|
||||
}
|
||||
|
||||
struct DebugInfoCompare {
|
||||
struct MS_CORE_API DebugInfoCompare {
|
||||
bool operator()(const DebugInfoPtr &left, const DebugInfoPtr &right) const;
|
||||
};
|
||||
|
||||
void UpdateDebugInfo(const FuncGraphPtr &func_graph, const ScopePtr &scope, const DebugInfoPtr &debug_info);
|
||||
MS_CORE_API void UpdateDebugInfo(const FuncGraphPtr &func_graph, const ScopePtr &scope, const DebugInfoPtr &debug_info);
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CORE_UTILS_INFO_H_
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "utils/interpret_node_recorder.h"
|
||||
|
||||
namespace mindspore {
|
||||
InterpretNodeRecorder &InterpretNodeRecorder::GetInstance() {
|
||||
static InterpretNodeRecorder instance;
|
||||
return instance;
|
||||
}
|
||||
} // namespace mindspore
|
|
@ -18,18 +18,17 @@
|
|||
#define MINDSPORE_CORE_UTILS_InterpretNodeRecorder_H_
|
||||
|
||||
#include <string>
|
||||
#include "utils/hash_set.h"
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
class InterpretNodeRecorder {
|
||||
class MS_CORE_API InterpretNodeRecorder {
|
||||
public:
|
||||
explicit InterpretNodeRecorder(InterpretNodeRecorder &&) = delete;
|
||||
explicit InterpretNodeRecorder(const InterpretNodeRecorder &) = delete;
|
||||
void operator=(const InterpretNodeRecorder &) = delete;
|
||||
void operator=(const InterpretNodeRecorder &&) = delete;
|
||||
static InterpretNodeRecorder &GetInstance() {
|
||||
static InterpretNodeRecorder instance;
|
||||
return instance;
|
||||
}
|
||||
static InterpretNodeRecorder &GetInstance();
|
||||
|
||||
void PushLineInfo(const std::string &line) { interpret_nodes_lines_.emplace(line); }
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
namespace mindspore {
|
||||
namespace label_manage {
|
||||
enum class TraceLabelType { kShortSymbol, kFullName, kWithUniqueId };
|
||||
TraceLabelType GetGlobalTraceLabelType();
|
||||
std::string Label(const DebugInfoPtr &debug_info, TraceLabelType trace_type = TraceLabelType::kShortSymbol);
|
||||
MS_CORE_API TraceLabelType GetGlobalTraceLabelType();
|
||||
MS_CORE_API std::string Label(const DebugInfoPtr &debug_info, TraceLabelType trace_type = TraceLabelType::kShortSymbol);
|
||||
} // namespace label_manage
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -115,6 +115,14 @@ static int GetSlogLevel(MsLogLevel level) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void LogWriter::set_exception_handler(const ExceptionHandler &exception_handler) {
|
||||
exception_handler_ = exception_handler;
|
||||
}
|
||||
|
||||
void LogWriter::set_trace_provider(const TraceProvider &trace_provider) { trace_provider_ = trace_provider; }
|
||||
|
||||
LogWriter::TraceProvider LogWriter::trace_provider() { return trace_provider_; }
|
||||
|
||||
void LogWriter::OutputLog(const std::ostringstream &msg) const {
|
||||
#ifdef USE_GLOG
|
||||
#define google mindspore_private
|
||||
|
@ -424,9 +432,9 @@ void InitSubModulesLogLevel() {
|
|||
extern "C" {
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(__APPLE__)
|
||||
#ifdef _MSC_VER
|
||||
void common_log_init(void) {
|
||||
MS_CORE_API void common_log_init(void) {
|
||||
#else
|
||||
__attribute__((constructor)) void common_log_init(void) {
|
||||
__attribute__((constructor)) MS_CORE_API void common_log_init(void) {
|
||||
#endif
|
||||
#else
|
||||
MS_CORE_API void common_log_init(void) {
|
||||
|
|
|
@ -156,6 +156,8 @@ enum SubModuleId : int {
|
|||
/// \return The sub-module name.
|
||||
MS_EXPORT const std::string GetSubModuleName(SubModuleId module_id);
|
||||
|
||||
MS_CORE_API void InitSubModulesLogLevel();
|
||||
|
||||
/// \brief Get current time as a string.
|
||||
///
|
||||
/// \return The string presents current time.
|
||||
|
@ -187,7 +189,7 @@ class TryCatchGuard {
|
|||
#endif
|
||||
|
||||
/// \brief LogWriter defines interface to write log.
|
||||
class LogWriter {
|
||||
class MS_CORE_API LogWriter {
|
||||
public:
|
||||
using ExceptionHandler = std::function<void(ExceptionType, const std::string &msg)>;
|
||||
using TraceProvider = std::function<void(std::ostringstream &oss)>;
|
||||
|
@ -200,18 +202,16 @@ class LogWriter {
|
|||
/// \brief Output log message from the input log stream.
|
||||
///
|
||||
/// \param[in] stream The input log stream.
|
||||
MS_CORE_API void operator<(const LogStream &stream) const noexcept;
|
||||
void operator<(const LogStream &stream) const noexcept;
|
||||
|
||||
/// \brief Output log message from the input log stream and then throw exception.
|
||||
///
|
||||
/// \param[in] stream The input log stream.
|
||||
MS_CORE_API void operator^(const LogStream &stream) const __attribute__((noreturn));
|
||||
void operator^(const LogStream &stream) const __attribute__((noreturn));
|
||||
|
||||
static void set_exception_handler(const ExceptionHandler &exception_handler) {
|
||||
exception_handler_ = exception_handler;
|
||||
}
|
||||
static void set_trace_provider(const TraceProvider &trace_provider) { trace_provider_ = trace_provider; }
|
||||
static TraceProvider trace_provider() { return trace_provider_; }
|
||||
static void set_exception_handler(const ExceptionHandler &exception_handler);
|
||||
static void set_trace_provider(const TraceProvider &trace_provider);
|
||||
static TraceProvider trace_provider();
|
||||
|
||||
private:
|
||||
void OutputLog(const std::ostringstream &msg) const;
|
||||
|
@ -225,18 +225,20 @@ class LogWriter {
|
|||
inline static TraceProvider trace_provider_ = nullptr;
|
||||
};
|
||||
|
||||
#define MSLOG_IF(level, condition, excp_type) \
|
||||
static_cast<void>(0), !(condition) \
|
||||
? void(0) \
|
||||
: mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), level, \
|
||||
SUBMODULE_ID, excp_type) < mindspore::LogStream()
|
||||
#define MSLOG_IF(level, condition, excp_type) \
|
||||
!(condition) ? void(0) \
|
||||
: mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), level, SUBMODULE_ID, \
|
||||
excp_type) < mindspore::LogStream()
|
||||
|
||||
#define MSLOG_THROW(excp_type) \
|
||||
mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), mindspore::EXCEPTION, SUBMODULE_ID, \
|
||||
excp_type) ^ \
|
||||
mindspore::LogStream()
|
||||
|
||||
#define IS_OUTPUT_ON(level) \
|
||||
((level) >= mindspore::g_ms_submodule_log_levels[SUBMODULE_ID] && (level) <= mindspore::this_thread_max_log_level)
|
||||
inline bool IS_OUTPUT_ON(enum MsLogLevel level) {
|
||||
return (static_cast<int>(level) >= mindspore::g_ms_submodule_log_levels[SUBMODULE_ID] &&
|
||||
static_cast<int>(level) <= static_cast<int>(mindspore::this_thread_max_log_level));
|
||||
}
|
||||
|
||||
#define MS_LOG(level) MS_LOG_##level
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
#include "utils/log_adapter.h"
|
||||
|
||||
namespace mindspore {
|
||||
extern const int RET_SUCCESS;
|
||||
extern const int RET_FAILED;
|
||||
extern const int RET_CONTINUE;
|
||||
extern const int RET_BREAK;
|
||||
MS_CORE_API extern const int RET_SUCCESS;
|
||||
MS_CORE_API extern const int RET_FAILED;
|
||||
MS_CORE_API extern const int RET_CONTINUE;
|
||||
MS_CORE_API extern const int RET_BREAK;
|
||||
|
||||
/// \brief Demangle the name to make it human reablable.
|
||||
///
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
namespace mindspore {
|
||||
std::atomic<bool> thread_1_must_end(false);
|
||||
|
||||
MsContext::DeviceSeter MsContext::seter_ = nullptr;
|
||||
MsContext::DeviceTypeSeter MsContext::device_type_seter_ = nullptr;
|
||||
std::shared_ptr<MsContext> MsContext::inst_context_ = nullptr;
|
||||
std::map<std::string, MsBackendPolicy> MsContext::policy_map_ = {{"ge", kMsBackendGePrior},
|
||||
{"vm", kMsBackendVmOnly},
|
||||
|
|
|
@ -141,7 +141,7 @@ enum MsCtxParam : unsigned {
|
|||
NUM_STRING_PARAMS = MS_CTX_TYPE_STRING_END - MS_CTX_TYPE_STRING_BEGIN
|
||||
};
|
||||
|
||||
class MsContext {
|
||||
class MS_CORE_API MsContext {
|
||||
public:
|
||||
MsContext(const std::string &backend_policy, const std::string &target);
|
||||
~MsContext() = default;
|
||||
|
@ -183,8 +183,8 @@ class MsContext {
|
|||
}
|
||||
|
||||
private:
|
||||
inline static DeviceSeter seter_ = nullptr;
|
||||
inline static DeviceTypeSeter device_type_seter_ = nullptr;
|
||||
static DeviceSeter seter_;
|
||||
static DeviceTypeSeter device_type_seter_;
|
||||
static std::shared_ptr<MsContext> inst_context_;
|
||||
static std::map<std::string, MsBackendPolicy> policy_map_;
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "utils/ms_exception.h"
|
||||
|
||||
namespace mindspore {
|
||||
MsException &MsException::Instance() {
|
||||
static MsException instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
StaticAnalysisException &StaticAnalysisException::Instance() {
|
||||
static StaticAnalysisException instance;
|
||||
return instance;
|
||||
}
|
||||
} // namespace mindspore
|
|
@ -18,7 +18,9 @@
|
|||
#define MINDSPORE_CORE_UTILS_MS_EXCEPTION_H_
|
||||
#include <exception>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
#include "utils/ms_utils.h"
|
||||
#include "utils/visible.h"
|
||||
namespace mindspore {
|
||||
class ExceptionListener {
|
||||
public:
|
||||
|
@ -26,12 +28,9 @@ class ExceptionListener {
|
|||
virtual ~ExceptionListener() = default;
|
||||
};
|
||||
|
||||
class MsException {
|
||||
class MS_CORE_API MsException {
|
||||
public:
|
||||
static MsException &Instance() {
|
||||
static MsException instance;
|
||||
return instance;
|
||||
}
|
||||
static MsException &Instance();
|
||||
|
||||
void SetException() {
|
||||
exception_ptr_ = std::current_exception();
|
||||
|
@ -60,12 +59,9 @@ class MsException {
|
|||
std::exception_ptr exception_ptr_{nullptr};
|
||||
};
|
||||
|
||||
class StaticAnalysisException {
|
||||
class MS_CORE_API StaticAnalysisException {
|
||||
public:
|
||||
static StaticAnalysisException &Instance() {
|
||||
static StaticAnalysisException instance;
|
||||
return instance;
|
||||
}
|
||||
static StaticAnalysisException &Instance();
|
||||
|
||||
void ClearException() {
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include "utils/visible.h"
|
||||
|
||||
#define DISABLE_COPY_AND_ASSIGN(ClassType) \
|
||||
ClassType(const ClassType &) = delete; \
|
||||
|
@ -41,7 +42,7 @@ namespace common {
|
|||
// TODO(lzlang): delete
|
||||
constexpr auto kEnableAscendKernelByKernel = false;
|
||||
inline const char *SafeCStr(const std::string &str) { return str.c_str(); }
|
||||
const char *SafeCStr(const std::string &&str);
|
||||
MS_CORE_API const char *SafeCStr(const std::string &&str);
|
||||
|
||||
static inline std::string GetEnv(const std::string &envvar) {
|
||||
const char *value = std::getenv(envvar.c_str());
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "ir/primitive.h"
|
||||
|
||||
namespace mindspore {
|
||||
bool IsInParallelBlackList(const PrimitivePtr &);
|
||||
bool IsInAllGatherNodeList(const CNodePtr &);
|
||||
bool IsInTrivialNodeList(const CNodePtr &);
|
||||
bool IsParallelConsiderCNode(const CNodePtr &);
|
||||
MS_CORE_API bool IsInParallelBlackList(const PrimitivePtr &);
|
||||
MS_CORE_API bool IsInAllGatherNodeList(const CNodePtr &);
|
||||
MS_CORE_API bool IsInTrivialNodeList(const CNodePtr &);
|
||||
MS_CORE_API bool IsParallelConsiderCNode(const CNodePtr &);
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CORE_UTILS_PARALLEL_NODE_CHECK_H_
|
||||
|
|
|
@ -288,6 +288,11 @@ ProfTransaction::~ProfTransaction() {
|
|||
ctx_ = nullptr;
|
||||
}
|
||||
|
||||
DumpTime &DumpTime::GetInstance() {
|
||||
static DumpTime instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DumpTime::Record(const std::string &step_name, const double time, const bool is_start) {
|
||||
file_ss_ << " {" << std::endl;
|
||||
file_ss_ << " \"name\": "
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace mindspore {
|
|||
struct TimeInfo;
|
||||
using TimeInfoMap = std::map<std::string, const TimeInfo *>;
|
||||
|
||||
extern double GetTime();
|
||||
MS_CORE_API double GetTime();
|
||||
|
||||
class ProfileBase;
|
||||
|
||||
|
@ -43,7 +43,7 @@ struct TimeInfo {
|
|||
};
|
||||
|
||||
// Utility class for Profile.
|
||||
class ProfContext {
|
||||
class MS_CORE_API ProfContext {
|
||||
friend class Profile;
|
||||
friend class ProfileBase;
|
||||
friend class ProfTransaction;
|
||||
|
@ -66,7 +66,7 @@ class ProfContext {
|
|||
TimeInfo *time_info_;
|
||||
};
|
||||
|
||||
class ProfileBase {
|
||||
class MS_CORE_API ProfileBase {
|
||||
friend class ProfContext;
|
||||
friend class ProfTransaction;
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ProfileBase {
|
|||
ProfContext *ctx_ptr_ = nullptr;
|
||||
};
|
||||
|
||||
class Profile : public ProfileBase {
|
||||
class MS_CORE_API Profile : public ProfileBase {
|
||||
public:
|
||||
Profile() = default;
|
||||
~Profile() override = default;
|
||||
|
@ -98,7 +98,7 @@ class Profile : public ProfileBase {
|
|||
void Pop(void) noexcept override;
|
||||
};
|
||||
|
||||
class ProfTransaction {
|
||||
class MS_CORE_API ProfTransaction {
|
||||
public:
|
||||
explicit ProfTransaction(const ProfileBase *prof);
|
||||
explicit ProfTransaction(ProfContext *const ctx) : ctx_(ctx) {}
|
||||
|
@ -131,7 +131,7 @@ class NoProfTransaction {
|
|||
}
|
||||
};
|
||||
|
||||
class DumpTime {
|
||||
class MS_CORE_API DumpTime {
|
||||
public:
|
||||
~DumpTime() {
|
||||
try {
|
||||
|
@ -144,10 +144,7 @@ class DumpTime {
|
|||
}
|
||||
DumpTime(const DumpTime &) = delete;
|
||||
DumpTime &operator=(const DumpTime &) = delete;
|
||||
static DumpTime &GetInstance() {
|
||||
static DumpTime instance;
|
||||
return instance;
|
||||
}
|
||||
static DumpTime &GetInstance();
|
||||
void set_file_path(const std::string &save_path) { file_path_ = save_path; }
|
||||
void Record(const std::string &name, const double time, const bool is_start);
|
||||
void Save();
|
||||
|
@ -181,7 +178,7 @@ struct TimeStat {
|
|||
int count_;
|
||||
};
|
||||
|
||||
class MsProfile {
|
||||
class MS_CORE_API MsProfile {
|
||||
public:
|
||||
~MsProfile() { Clear(); }
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ static constexpr uint32 kMaskDelta = 0xa282ead8ul;
|
|||
static const int kRightShift = 15;
|
||||
static const int kLeftShift = (32 - kRightShift);
|
||||
// Provide the Crc32c function
|
||||
class Crc32c {
|
||||
class MS_CORE_API Crc32c {
|
||||
public:
|
||||
Crc32c() = default;
|
||||
~Crc32c() = default;
|
||||
|
|
|
@ -94,7 +94,7 @@ class WriteFile {
|
|||
|
||||
#if defined(SYSTEM_ENV_POSIX)
|
||||
// File system of create or delete directory for posix system
|
||||
class PosixFileSystem : public FileSystem {
|
||||
class MS_CORE_API PosixFileSystem : public FileSystem {
|
||||
public:
|
||||
PosixFileSystem() = default;
|
||||
|
||||
|
@ -200,7 +200,7 @@ class PosixWriteFile : public WriteFile {
|
|||
|
||||
#if defined(SYSTEM_ENV_WINDOWS)
|
||||
// File system of create or delete directory for windows system
|
||||
class WinFileSystem : public FileSystem {
|
||||
class MS_CORE_API WinFileSystem : public FileSystem {
|
||||
public:
|
||||
WinFileSystem() = default;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define MINDSPORE_CORE_UTILS_SYSTEM_SHA256_H_
|
||||
|
||||
#include <string>
|
||||
#include "utils/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace system {
|
||||
|
@ -41,7 +42,7 @@ std::string Encrypt(const std::string &message);
|
|||
|
||||
std::string GetHashFromString(const std::string &data);
|
||||
|
||||
std::string GetHashFromFile(const std::string &path);
|
||||
MS_CORE_API std::string GetHashFromFile(const std::string &path);
|
||||
|
||||
#ifndef _WIN32
|
||||
std::string GetHashFromDir(const std::string &dir);
|
||||
|
|
|
@ -27,7 +27,7 @@ void SetTensorData(void *data, T num, size_t data_length) {
|
|||
MS_EXCEPTION_IF_NULL(tensor_data);
|
||||
std::fill(tensor_data, tensor_data + data_length, num);
|
||||
}
|
||||
class TensorConstructUtils {
|
||||
class MS_CORE_API TensorConstructUtils {
|
||||
public:
|
||||
static tensor::TensorPtr CreateZerosTensor(const TypePtr &type, const std::vector<int64_t> &shape);
|
||||
static tensor::TensorPtr CreateOnesTensor(const TypePtr &type, const std::vector<int64_t> &shape);
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace mindspore {
|
|||
namespace trace {
|
||||
constexpr auto kSectionPrefix = " - ";
|
||||
|
||||
std::string GetDebugInfo(const DebugInfoPtr &info, SourceLineTip tip = kSourceLineTipNextLine);
|
||||
std::string GetDebugInfo(const DebugInfoPtr &info, const std::string &prefix,
|
||||
SourceLineTip tip = kSourceLineTipNextLine);
|
||||
MS_CORE_API std::string GetDebugInfo(const DebugInfoPtr &info, SourceLineTip tip = kSourceLineTipNextLine);
|
||||
MS_CORE_API std::string GetDebugInfo(const DebugInfoPtr &info, const std::string &prefix,
|
||||
SourceLineTip tip = kSourceLineTipNextLine);
|
||||
// Generate the call stack of python source code to a string
|
||||
std::string DumpSourceLines(const AnfNodePtr &node);
|
||||
std::string DumpSourceLines(AnfNode *node);
|
||||
MS_CORE_API std::string DumpSourceLines(const AnfNodePtr &node);
|
||||
MS_CORE_API std::string DumpSourceLines(AnfNode *node);
|
||||
// Generate the call stack of python source code to a vector
|
||||
std::vector<std::string> GetSourceLineList(const AnfNodePtr &node);
|
||||
MS_CORE_API std::vector<std::string> GetSourceLineList(const AnfNodePtr &node);
|
||||
// Get the locations of the call stack of python source code
|
||||
std::vector<LocationPtr> GetSourceLocationList(const AnfNodePtr &node);
|
||||
// Generate the call stack of python source code with relevant trace info
|
||||
|
|
|
@ -31,5 +31,4 @@
|
|||
#define MS_EXPORT __attribute__((visibility("default")))
|
||||
#define MS_LOCAL __attribute__((visibility("hidden")))
|
||||
#endif
|
||||
|
||||
#endif // MINDSPORE_CORE_UTILS_VISIBLE_H_
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
add_definitions(-DPRIMITIVE_WRITEABLE)
|
||||
add_definitions(-DUSE_GLOG)
|
||||
set(USE_GLOG on)
|
||||
|
||||
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../src)
|
||||
|
||||
|
@ -233,7 +234,7 @@ target_link_libraries(converter_lite PRIVATE
|
|||
proto_mid
|
||||
${SECUREC_LIBRARY}
|
||||
mindspore::json
|
||||
-Wl,--whole-archive mindspore_core -Wl,--no-whole-archive
|
||||
mindspore_core
|
||||
mslite_converter_plugin
|
||||
mindspore::glog
|
||||
mindspore::protobuf
|
||||
|
|
|
@ -14,5 +14,6 @@ endif()
|
|||
file(GLOB_RECURSE CXX_ST_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc)
|
||||
add_executable(st_tests ${CXX_ST_SRC})
|
||||
target_link_libraries(st_tests PRIVATE mindspore_shared_lib _c_dataengine mindspore::gtest)
|
||||
target_link_options(st_tests PRIVATE -Wl,--unresolved-symbols=ignore-all)
|
||||
set_target_properties(st_tests PROPERTIES SKIP_BUILD_RPATH TRUE RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
file(COPY ${gtest_LIBPATH}/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR})
|
|
@ -52,7 +52,6 @@ if(ENABLE_MINDDATA)
|
|||
./base/*.cc
|
||||
./dataset/*.cc
|
||||
./ir/dtype/*.cc
|
||||
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/*.cc
|
||||
./device/*.cc
|
||||
./ir/*.cc
|
||||
./kernel/*.cc
|
||||
|
@ -169,7 +168,6 @@ file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
"../../../mindspore/ccsrc/backend/session/kernel_graph.cc"
|
||||
"../../../mindspore/ccsrc/backend/session/session_basic.cc"
|
||||
"../../../mindspore/ccsrc/backend/session/executor.cc"
|
||||
"../../../mindspore/core/ops/*.cc"
|
||||
"../../../mindspore/ccsrc/backend/session/executor_manager.cc"
|
||||
"../../../mindspore/ccsrc/backend/session/session_factory.cc"
|
||||
"../../../mindspore/ccsrc/backend/session/kernel_build_client.cc"
|
||||
|
@ -191,12 +189,6 @@ file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
"../../../mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_util.cc"
|
||||
)
|
||||
|
||||
if(ENABLE_SECURITY)
|
||||
file(GLOB_RECURSE _INFER_SUMMARY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"../../../mindspore/core/ops/*_summary.cc"
|
||||
)
|
||||
list(REMOVE_ITEM MINDSPORE_SRC_LIST ${_INFER_SUMMARY_FILES})
|
||||
endif()
|
||||
list(REMOVE_ITEM MINDSPORE_SRC_LIST
|
||||
"../../../mindspore/ccsrc/frontend/parallel/strategy_checkpoint/parallel_strategy_checkpoint.cc")
|
||||
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/util.cc")
|
||||
|
@ -238,8 +230,13 @@ add_library(_ut_mindspore_obj OBJECT ${MINDSPORE_SRC_LIST})
|
|||
add_library(_ut_ut_obj OBJECT ${UT_SRCS})
|
||||
add_dependencies(_ut_mindspore_obj graph)
|
||||
add_dependencies(_ut_ut_obj engine-cache-server graph)
|
||||
add_executable(ut_tests $<TARGET_OBJECTS:_ut_ut_obj>
|
||||
$<TARGET_OBJECTS:_ut_mindspore_obj>)
|
||||
set(ut_objects $<TARGET_OBJECTS:_ut_ut_obj> $<TARGET_OBJECTS:_ut_mindspore_obj>
|
||||
$<TARGET_OBJECTS:core_obj> $<TARGET_OBJECTS:core_proto_obj> $<TARGET_OBJECTS:mindrt_mid>
|
||||
$<TARGET_OBJECTS:mindspore_gvar> $<TARGET_OBJECTS:mindspore_shared_lib_obj>)
|
||||
if(ENABLE_MINDDATA)
|
||||
set(ut_objects ${ut_objects} ${dataengine_submodules} $<TARGET_OBJECTS:mindrecord_obj>)
|
||||
endif()
|
||||
add_executable(ut_tests ${ut_objects})
|
||||
|
||||
include_directories("${CMAKE_BINARY_DIR}/backend/kernel_compiler/aicpu")
|
||||
file(GLOB_RECURSE PROTO_IN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
@ -266,21 +263,18 @@ endif()
|
|||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore::event mindspore::event_pthreads
|
||||
mindspore::event_openssl mindspore_gvar ${PYTHON_LIBRARIES} pthread util dl)
|
||||
mindspore::event_openssl ${PYTHON_LIBRARIES} pthread util dl)
|
||||
if(ENABLE_MINDDATA)
|
||||
|
||||
# AUX_SOURCE_DIRECTORY(LITE_CV_FILES)
|
||||
# message(STATUS "xxxxxxxxxxxxxxxxx"${LITE_CV_FILES} )
|
||||
# add_library(_live_cv OBJECT ${LITE_CV_FILES})
|
||||
|
||||
target_link_libraries(ut_tests PRIVATE _c_dataengine _c_mindrecord)
|
||||
target_link_libraries(ut_tests PRIVATE mindspore::sqlite mindspore::jpeg_turbo mindspore::turbojpeg
|
||||
mindspore::opencv_core mindspore::opencv_imgcodecs mindspore::opencv_imgproc mindspore::tinyxml2
|
||||
mindspore::sentencepiece mindspore::sentencepiece_train mindspore::icuuc mindspore::icudata
|
||||
mindspore::icui18n)
|
||||
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)
|
||||
endif()
|
||||
|
||||
target_link_libraries(mindspore mindspore_core)
|
||||
target_link_libraries(ut_tests PRIVATE mindspore mindspore_shared_lib securec graph error_manager)
|
||||
target_link_libraries(ut_tests PRIVATE mindspore securec graph error_manager)
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#include "pipeline/jit/pipeline.h"
|
||||
#include "pipeline/jit/resource.h"
|
||||
|
||||
namespace mindspore {
|
||||
extern void InitSubModulesLogLevel();
|
||||
extern "C" {
|
||||
void common_log_init(void);
|
||||
}
|
||||
|
||||
GTEST_API_ int main(int argc, char** argv) {
|
||||
mindspore::InitSubModulesLogLevel();
|
||||
common_log_init();
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
mindspore::pipeline::ClearResAtexit();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue