diff --git a/CMakeLists.txt b/CMakeLists.txt index 29208b6139e790dc9f8bd031b773aa14fdaf7d7a..0dcf7699d47906e5feac34cac94c9264b774ece6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,6 @@ option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) if (ENABLE_OPEN_SRC) set(HI_PYTHON python3) - include(cmake/external_libs/protobuf_shared.cmake) include(cmake/external_libs/protobuf_static.cmake) include(cmake/external_libs/protoc.cmake) @@ -19,37 +18,6 @@ if (ENABLE_OPEN_SRC) include(cmake/external_libs/json.cmake) include(cmake/FindModule.cmake) include(cmake/intf_pub_linux.cmake) - - if(DEFINED ENV{D_LINK_PATH}) - # D_LINK_PATH is set - set(GE_LIB_PATH $ENV{D_LINK_PATH}) - set(GE_SYS_ARCH "") - if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64") - # x86 ubuntu - set(GE_SYS_ARCH "x86_64") - elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") - # arm euleros - set(GE_SYS_ARCH "aarch64") - else() - message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") - endif() - set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) - find_module(slog libalog.so ${GE_LIB_PATH}) - find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) - elseif(DEFINED ENV{ASCEND_CUSTOM_PATH}) - set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) - set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) - find_module(slog libalog.so ${ASCEND_ATC_DIR}) - find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) - endif() - - if(ENABLE_GE_COV OR ENABLE_GE_UT) - message(STATUS "Runing on llt mode, no need to depend other component") - elseif(ENABLE_METADEF_UT OR ENABLE_METADEF_COV) - include(cmake/external_libs/gtest.cmake) - add_subdirectory(tests) - endif() - endif() set(METADEF_PROTO_LIST @@ -148,3 +116,13 @@ if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) add_subdirectory(register) endif () +if(ENABLE_GE_COV OR ENABLE_GE_UT) + message(STATUS "Runing on llt mode, no need to depend other component") +elseif(ENABLE_METADEF_UT OR ENABLE_METADEF_COV) + include(cmake/external_libs/gtest.cmake) + include(cmake/init_test_depends.cmake) + add_subdirectory(tests) +else() + include(cmake/init_depends.cmake) +endif() + diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/cmake/init_depends.cmake b/cmake/init_depends.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c48da040d9616b57cc8e6167c8dbed9b359dca4e --- /dev/null +++ b/cmake/init_depends.cmake @@ -0,0 +1,33 @@ +if (ENABLE_OPEN_SRC) + if(DEFINED ENV{D_LINK_PATH}) + # D_LINK_PATH is set + set(GE_LIB_PATH $ENV{D_LINK_PATH}) + set(GE_SYS_ARCH "") + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64") + # x86 ubuntu + set(GE_SYS_ARCH "x86_64") + elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") + # arm euleros + set(GE_SYS_ARCH "aarch64") + else() + message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") + endif() + set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) + find_module(slog libalog.so ${GE_LIB_PATH}) + find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) + elseif(DEFINED ENV{ASCEND_CUSTOM_PATH}) + set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) + set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) + find_module(slog libalog.so ${ASCEND_ATC_DIR}) + find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) + endif() +endif() + + +target_link_libraries(graph_static PRIVATE + ascend_protobuf_static +) + +target_link_libraries(register_static PRIVATE + ascend_protobuf_static +) diff --git a/cmake/init_test_depends.cmake b/cmake/init_test_depends.cmake new file mode 100644 index 0000000000000000000000000000000000000000..cc0c2b02960f52be1f6081e4ae81ac4a00f2c59d --- /dev/null +++ b/cmake/init_test_depends.cmake @@ -0,0 +1,13 @@ +target_link_libraries(graph_static PRIVATE + ascend_protobuf +) + +target_link_libraries(register_static PRIVATE + ascend_protobuf) + +target_compile_options(graph_static PRIVATE + -g --coverage -fprofile-arcs -fPIC -O0 -ftest-coverage) + + +target_compile_options(register_static PRIVATE + -g --coverage -fprofile-arcs -fPIC -O0 -ftest-coverage) \ No newline at end of file diff --git a/graph/CMakeLists.txt b/graph/CMakeLists.txt index 7dbb2ca49b1fdfc6aa8e9b0dbd5d9bdad8c71b77..610a8de7abf2a0c73a01d5bae87d32c92b3538b5 100755 --- a/graph/CMakeLists.txt +++ b/graph/CMakeLists.txt @@ -155,6 +155,13 @@ target_compile_definitions(graph_static PRIVATE LOG_CPP ) +target_include_directories(graph_static PUBLIC + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/graph + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph +) + target_include_directories(graph_static PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_BINARY_DIR} @@ -204,7 +211,6 @@ target_link_libraries(graph_static PRIVATE $ $<$>:$> $<$>:$> - ascend_protobuf_static c_sec $<$>:-lrt> -ldl diff --git a/register/CMakeLists.txt b/register/CMakeLists.txt index 0961b8100433d3ed53b790feaefa67bab3ed4c36..3e95a2c2ba90aea6d03a4a76de1ecdd9682c0f5d 100755 --- a/register/CMakeLists.txt +++ b/register/CMakeLists.txt @@ -125,6 +125,14 @@ target_compile_definitions(register_static PRIVATE $<$:SECUREC_USING_STD_SECURE_LIB=0 NOMINMAX> LOG_CPP ) + +target_include_directories(register_static PUBLIC + ${METADEF_DIR}/graph + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/register +) + target_include_directories(register_static PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${METADEF_DIR} @@ -163,7 +171,6 @@ target_include_directories(register_static PRIVATE ) target_link_libraries(register_static PRIVATE - ascend_protobuf_static c_sec json $ diff --git a/tests/ut/graph/CMakeLists.txt b/tests/ut/graph/CMakeLists.txt index 370a4fc9419865aa9120ec89a423ebbd4f472763..5cc923fa593a595f9b16197cc9204fb51add2188 100644 --- a/tests/ut/graph/CMakeLists.txt +++ b/tests/ut/graph/CMakeLists.txt @@ -17,46 +17,8 @@ project(ut_graph) set(CMAKE_CXX_STANDARD 11) -set(PROTO_LIST - "${METADEF_DIR}/proto/om.proto" - "${METADEF_DIR}/proto/ge_ir.proto" - "${METADEF_DIR}/proto/insert_op.proto" - "${METADEF_DIR}/proto/task.proto" - "${METADEF_DIR}/proto/dump_task.proto" - "${METADEF_DIR}/proto/fwk_adapter.proto" - "${METADEF_DIR}/proto/op_mapping.proto" - "${METADEF_DIR}/proto/onnx/ge_onnx.proto" -) - -protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) - -############ libut_metadef_proto.a ############ -add_library(ut_metadef_proto STATIC - ${PROTO_HDRS} - ${PROTO_SRCS} -) - -target_compile_definitions(ut_metadef_proto PRIVATE - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - google=ascend_private -) - -target_compile_options(ut_metadef_proto PRIVATE - -O2 - -fno-common -) - -target_link_libraries(ut_metadef_proto PRIVATE - $ - ascend_protobuf -) - # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${METADEF_DIR}/inc) -include_directories(${METADEF_DIR}/inc/graph) -include_directories(${METADEF_DIR}/inc/external) -include_directories(${METADEF_DIR}/inc/external/graph) include_directories(${METADEF_DIR}/graph) include_directories(${METADEF_DIR}/third_party) include_directories(${METADEF_DIR}/third_party/graphengine/inc) @@ -95,79 +57,7 @@ set(UT_FILES "testcase/constant_utils_unittest.cc" ) -set(GRAPH_SRC_FILES - "${METADEF_DIR}/graph/aligned_ptr.cc" - "${METADEF_DIR}/graph/anchor.cc" - "${METADEF_DIR}/graph/ascend_string.cc" - "${METADEF_DIR}/graph/attr_value.cc" - "${METADEF_DIR}/graph/buffer.cc" - "${METADEF_DIR}/graph/compute_graph.cc" - "${METADEF_DIR}/graph/debug/graph_debug.cc" - "${METADEF_DIR}/graph/detail/attributes_holder.cc" - "${METADEF_DIR}/graph/format_refiner.cc" - "${METADEF_DIR}/graph/ge_attr_define.cc" - "${METADEF_DIR}/graph/ge_attr_value.cc" - "${METADEF_DIR}/graph/ge_tensor.cc" - "${METADEF_DIR}/graph/gnode.cc" - "${METADEF_DIR}/graph/graph.cc" - "${METADEF_DIR}/graph/inference_context.cc" - "${METADEF_DIR}/graph/model.cc" - "${METADEF_DIR}/graph/model_serialize.cc" - "${METADEF_DIR}/graph/node.cc" - "${METADEF_DIR}/graph/op_desc.cc" - "${METADEF_DIR}/graph/operator.cc" - "${METADEF_DIR}/graph/operator_factory.cc" - "${METADEF_DIR}/graph/operator_factory_impl.cc" - "${METADEF_DIR}/graph/opsproto/opsproto_manager.cc" - "${METADEF_DIR}/graph/option/ge_context.cc" - "${METADEF_DIR}/graph/option/ge_local_context.cc" - "${METADEF_DIR}/graph/ref_relation.cc" - "${METADEF_DIR}/graph/runtime_inference_context.cc" - "${METADEF_DIR}/graph/shape_refiner.cc" - "${METADEF_DIR}/graph/tensor.cc" - "${METADEF_DIR}/graph/types.cc" - "${METADEF_DIR}/graph/resource_context_mgr.cc" - "${METADEF_DIR}/graph/utils/anchor_utils.cc" - "${METADEF_DIR}/graph/utils/ge_ir_utils.cc" - "${METADEF_DIR}/graph/utils/graph_utils.cc" - "${METADEF_DIR}/graph/utils/ffts_graph_utils.cc" - "${METADEF_DIR}/graph/utils/dumper/ge_graph_dumper.cc" - "${METADEF_DIR}/graph/utils/node_utils.cc" - "${METADEF_DIR}/graph/utils/op_desc_utils.cc" - "${METADEF_DIR}/graph/utils/tensor_utils.cc" - "${METADEF_DIR}/graph/utils/transformer_utils.cc" - "${METADEF_DIR}/graph/utils/tuning_utils.cc" - "${METADEF_DIR}/graph/utils/type_utils.cc" - "${METADEF_DIR}/graph/utils/constant_utils.cc" - "${METADEF_DIR}/ops/op_imp.cpp" - "${METADEF_DIR}/third_party/transformer/src/axis_util.cc" - "${METADEF_DIR}/third_party/transformer/src/expand_dimension.cc" - "${METADEF_DIR}/third_party/transformer/src/transfer_shape_according_to_format.cc" -) - -############ libut_metadef_graph.a ############ -add_library(ut_metadef_graph STATIC - ${GRAPH_SRC_FILES} ${PROTO_HDRS} -) - -target_compile_definitions(ut_metadef_graph PRIVATE - google=ascend_private -) - -target_compile_options(ut_metadef_graph PRIVATE - -g --coverage -fprofile-arcs -ftest-coverage - -Werror=format -) - -target_link_libraries(ut_metadef_graph PRIVATE - $ - c_sec - ascend_protobuf - #json -) - - -add_executable(ut_graph ${UT_FILES} ${PROTO_HDRS}) +add_executable(ut_graph ${UT_FILES}) target_compile_options(ut_graph PRIVATE -g --coverage -fprofile-arcs -ftest-coverage @@ -179,6 +69,6 @@ target_compile_definitions(ut_graph PRIVATE target_link_libraries(ut_graph $ - ut_metadef_graph ut_metadef_proto + graph_static gtest gtest_main slog_stub ascend_protobuf c_sec error_manager_stub mmpa_stub -lrt -ldl -lgcov ) diff --git a/tests/ut/register/CMakeLists.txt b/tests/ut/register/CMakeLists.txt index 22c4bd2d0eb3ff2183d9dc1b574679f5ba63ee2c..0af5418c874d9f34c4d2bc6ff94e4577bdf70cd5 100644 --- a/tests/ut/register/CMakeLists.txt +++ b/tests/ut/register/CMakeLists.txt @@ -17,117 +17,21 @@ project(ut_register) set(CMAKE_CXX_STANDARD 11) -set(REGISTER_PROTO_LIST - "${METADEF_DIR}/proto/tensorflow/attr_value.proto" - "${METADEF_DIR}/proto/tensorflow/function.proto" - "${METADEF_DIR}/proto/tensorflow/graph.proto" - "${METADEF_DIR}/proto/tensorflow/graph_library.proto" - "${METADEF_DIR}/proto/tensorflow/node_def.proto" - "${METADEF_DIR}/proto/tensorflow/op_def.proto" - "${METADEF_DIR}/proto/tensorflow/resource_handle.proto" - "${METADEF_DIR}/proto/tensorflow/tensor.proto" - "${METADEF_DIR}/proto/tensorflow/tensor_shape.proto" - "${METADEF_DIR}/proto/tensorflow/types.proto" - "${METADEF_DIR}/proto/tensorflow/versions.proto" -) - - -protobuf_generate(ge REGISTER_PROTO_SRCS REGISTER_PROTO_HDRS ${REGISTER_PROTO_LIST}) - -############ libut_register_proto.a ############ -add_library(ut_register_proto STATIC - ${REGISTER_PROTO_HDRS} - ${REGISTER_PROTO_SRCS} -) - -target_compile_definitions(ut_register_proto PRIVATE - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - google=ascend_private -) - -target_compile_options(ut_register_proto PRIVATE - -O2 - -fno-common -) - -target_link_libraries(ut_register_proto PRIVATE - $ - ascend_protobuf -) - - -set(REGISTER_SRC_FILES - "${METADEF_DIR}/register/auto_mapping_util.cpp" - "${METADEF_DIR}/register/graph_optimizer/buffer_fusion/buffer_fusion_pass_base.cc" - "${METADEF_DIR}/register/graph_optimizer/buffer_fusion/buffer_fusion_pass_registry.cc" - "${METADEF_DIR}/register/graph_optimizer/buffer_fusion/buffer_fusion_pattern.cc" - "${METADEF_DIR}/register/graph_optimizer/fusion_statistic/fusion_statistic_recorder.cc" - "${METADEF_DIR}/register/graph_optimizer/graph_fusion/fusion_pass_registry.cc" - "${METADEF_DIR}/register/graph_optimizer/graph_fusion/fusion_pattern.cc" - "${METADEF_DIR}/register/graph_optimizer/graph_fusion/graph_fusion_pass_base.cc" - "${METADEF_DIR}/register/graph_optimizer/graph_fusion/pattern_fusion_base_pass.cc" - "${METADEF_DIR}/register/graph_optimizer/graph_fusion/pattern_fusion_base_pass_impl.cc" - "${METADEF_DIR}/register/host_cpu_context.cc" - "${METADEF_DIR}/register/infer_data_slice_registry.cc" - "${METADEF_DIR}/register/ops_kernel_builder_registry.cc" - "${METADEF_DIR}/register/op_kernel_registry.cpp" - "${METADEF_DIR}/register/op_tiling.cpp" - "${METADEF_DIR}/register/op_tiling_registry.cpp" - "${METADEF_DIR}/register/register.cpp" - "${METADEF_DIR}/register/register_format_transfer.cc" - "${METADEF_DIR}/register/register_pass.cpp" - "${METADEF_DIR}/register/scope/scope_graph.cc" - "${METADEF_DIR}/register/scope/scope_pass.cc" - "${METADEF_DIR}/register/scope/scope_pass_registry.cc" - "${METADEF_DIR}/register/scope/scope_pattern.cc" - "${METADEF_DIR}/register/scope/scope_util.cc" - "${METADEF_DIR}/register/tensor_assign.cpp" - "${METADEF_DIR}/register/prototype_pass_registry.cc" -) - # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) include_directories(${CMAKE_BINARY_DIR}/proto/ge) include_directories(${METADEF_DIR}) -include_directories(${METADEF_DIR}/graph) -include_directories(${METADEF_DIR}/inc) -include_directories(${METADEF_DIR}/inc/external) -include_directories(${METADEF_DIR}/inc/register) include_directories(${METADEF_DIR}/third_party/fwkacllib/inc) include_directories(${METADEF_DIR}/third_party/graphengine/inc) include_directories(${METADEF_DIR}/third_party/graphengine/inc/external) include_directories(${METADEF_DIR}/third_party/graphengine/inc/framework) - set(REGISTER_UT_FILES "testcase/register_unittest.cc" "testcase/register_prototype_unittest.cc" ) - -############ libut_metadef_register.a ############ -add_library(ut_metadef_register STATIC - ${REGISTER_SRC_FILES} ${REGISTER_PROTO_HDRS} -) - -target_compile_definitions(ut_metadef_register PRIVATE - google=ascend_private -) - -target_compile_options(ut_metadef_register PRIVATE - -g --coverage -fprofile-arcs -ftest-coverage - -Werror=format -) - -target_link_libraries(ut_metadef_register PRIVATE - $ - c_sec - ascend_protobuf - json -) - - add_executable(ut_register - ${REGISTER_UT_FILES} ${REGISTER_PROTO_HDRS} + ${REGISTER_UT_FILES} ) target_compile_options(ut_register PRIVATE @@ -140,7 +44,7 @@ target_compile_definitions(ut_register PRIVATE target_link_libraries(ut_register $ - ut_metadef_register ut_register_proto ut_metadef_graph ut_metadef_proto + register_static graph_static gtest gtest_main slog_stub