1message("build ut testcases...") 2 3# virtual project for common include and library file path. 4project(ut) 5 6set(PROJECT_DIR "${PROJECT_SOURCE_DIR}/../../..") 7if(ENABLE_DUMP_IR) 8 add_compile_definitions(ENABLE_DUMP_IR) 9endif() 10if(ENABLE_D) 11 add_compile_definitions(ENABLE_D) 12endif() 13if(NOT ENABLE_GLIBCXX) 14 add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) 15endif() 16 17#add python lib and include for all ut executables; 18message("PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}") 19message("PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}") 20include_directories(${PYTHON_INCLUDE_DIRS}) 21include_directories(${MS_CCSRC_PATH}) 22include_directories(${CMAKE_SOURCE_DIR}/mindspore/core) 23include_directories(${CMAKE_SOURCE_DIR}/mindspore/core/mindrt/include) 24include_directories(${CMAKE_SOURCE_DIR}/mindspore/core/mindrt/src) 25include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 26include_directories(${CMAKE_CURRENT_SOURCE_DIR}/stub/runtime/) 27include_directories(${CMAKE_BINARY_DIR}) 28include_directories(${CMAKE_BINARY_DIR}/proto/graphengine_protos) 29include_directories(${CMAKE_BINARY_DIR}/proto/metadef_protos) 30include_directories(${CUDA_INCLUDE_DIRS}) 31include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc/backend/kernel_compiler/cpu) 32MESSAGE("check ut_test ${CMAKE_BINARY_DIR}") 33 34link_directories(${MS_CCSRC_BUILD_PATH}) 35 36if(ENABLE_MINDDATA) 37 add_definitions(-D ENABLE_MINDDATA) 38 link_directories(${MS_CCSRC_BUILD_PATH}/minddata/dataset) 39 link_directories(${MS_CCSRC_BUILD_PATH}/minddata/mindrecord) 40endif() 41# fetch ut test files 42if(ENABLE_MINDDATA) 43 include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset) 44 include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/kernels/image) 45 file(GLOB_RECURSE UT_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 46 ./stub/*.cc 47 ./common/*.cc 48 ./abstract/*.cc 49 ./base/*.cc 50 ./dataset/*.cc 51 ./ir/dtype/*.cc 52 ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/*.cc 53 ./device/*.cc 54 ./ir/*.cc 55 ./kernel/*.cc 56 ./mindrecord/*.cc 57 ./operator/*.cc 58 ./optimizer/*.cc 59 ./parallel/*.cc 60 ./pipeline/*.cc 61 ./pre_activate/*.cc 62 ./pynative/*.cc 63 ./session/*.cc 64 ./transform/*.cc 65 ./utils/*.cc 66 ./vm/*.cc 67 ./ps/*.cc 68 ./fl/*.cc 69 ./cxx_api/*.cc 70 ./tbe/*.cc 71 ) 72 if(NOT ENABLE_SECURITY) 73 file(GLOB_RECURSE UT_SRCS_DEBUG RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 74 ./debug/*.cc) 75 list(APPEND UT_SRCS ${UT_SRCS_DEBUG}) 76 endif() 77 if(NOT ENABLE_PYTHON) 78 set(PYTHON_RELATED_SRCS 79 dataset/filter_op_test.cc 80 dataset/voc_op_test.cc 81 dataset/manifest_op_test.cc 82 dataset/sentence_piece_vocab_op_test.cc 83 ) 84 list(REMOVE_ITEM UT_SRCS ${PYTHON_RELATED_SRCS}) 85 endif() 86 87 if(NOT ENABLE_ACL) 88 set(ASCEND310_RELATED_SRCS 89 dataset/dvpp_decode_jpeg_test.cc 90 ) 91 list(REMOVE_ITEM UT_SRCS ${ASCEND310_RELATED_SRCS}) 92 endif() 93else() 94 file(GLOB_RECURSE TEMP_UT_SRCS ./*.cc) 95 foreach(OBJ ${TEMP_UT_SRCS}) 96 if(NOT ${OBJ} MATCHES "./dataset/" AND NOT ${OBJ} MATCHES "./mindrecord/") 97 list(APPEND UT_SRCS ${OBJ}) 98 endif() 99 endforeach() 100endif() 101 102file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 103 "../../../mindspore/ccsrc/pybind_api/*.cc" 104 "../../../mindspore/ccsrc/frontend/optimizer/*.cc" 105 "../../../mindspore/ccsrc/frontend/parallel/*.cc" 106 "../../../mindspore/ccsrc/frontend/operator/*.cc" 107 # dont remove the 4 lines above 108 "../../../mindspore/ccsrc/debug/data_dump/dump_json_parser.cc" 109 "../../../mindspore/ccsrc/debug/common.cc" 110 "../../../mindspore/ccsrc/runtime/hccl_adapter/all_to_all_v_calc_param.cc" 111 "../../../mindspore/ccsrc/runtime/device/kernel_runtime.cc" 112 "../../../mindspore/ccsrc/runtime/device/memory_manager.cc" 113 "../../../mindspore/ccsrc/runtime/device/kernel_runtime_manager.cc" 114 "../../../mindspore/ccsrc/runtime/device/kernel_info.cc" 115 "../../../mindspore/ccsrc/runtime/device/bucket.cc" 116 "../../../mindspore/ccsrc/runtime/device/launch_kernel.cc" 117 "../../../mindspore/ccsrc/runtime/device/ascend/profiling/*.cc" 118 "../../../mindspore/ccsrc/runtime/device/ascend/ge_runtime/*.cc" 119 "../../../mindspore/ccsrc/runtime/device/ascend/kernel_select_ascend.cc" 120 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_launch_kernel.cc" 121 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_launch_mul.cc" 122 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_launch_atomic_clean.cc" 123 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_launch_transdata.cc" 124 "../../../mindspore/ccsrc/runtime/device/ascend/kernel_select_graph_kernel.cc" 125 "../../../mindspore/ccsrc/runtime/device/convert_tensor_utils.cc" 126 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_bucket.cc" 127 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_event.cc" 128 "../../../mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc" 129 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc" 130 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_memory_manager.cc" 131 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc" 132 "../../../mindspore/ccsrc/runtime/device/ascend/ascend_memory_pool.cc" 133 "../../../mindspore/ccsrc/runtime/device/ascend/lic_manager.cc" 134 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/cpu_kernel.cc" 135 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/cpu_kernel_factory.cc" 136 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_adam_cpu_kernel.cc" 137 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_ftrl_cpu_kernel.cc" 138 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_lazy_adam_cpu_kernel.cc" 139 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_proximal_adagrad_cpu_kernel.cc" 140 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/unique_cpu_kernel.cc" 141 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/unique_with_pad_cpu_kernel.cc" 142 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/adam_delta_cpu_kernel.cc" 143 "../../../mindspore/ccsrc/backend/kernel_compiler/akg/*.cc" 144 "../../../mindspore/ccsrc/backend/kernel_compiler/rts/*.cc" 145 "../../../mindspore/ccsrc/backend/kernel_compiler/hccl/*.cc" 146 "../../../mindspore/ccsrc/backend/kernel_compiler/kernel_query.cc" 147 "../../../mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_metadata.cc" 148 "../../../mindspore/ccsrc/backend/kernel_compiler/rts/rt_kernel_info.cc" 149 "../../../mindspore/ccsrc/backend/kernel_compiler/tbe/*.cc" 150 "../../../mindspore/ccsrc/backend/optimizer/ascend/*.cc" 151 "../../../mindspore/ccsrc/backend/optimizer/graph_kernel/*.cc" 152 "../../../mindspore/ccsrc/backend/optimizer/graph_kernel/model/*.cc" 153 "../../../mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc" 154 "../../../mindspore/ccsrc/backend/session/ascend_session.cc" 155 "../../../mindspore/ccsrc/backend/session/ascend_auto_monad.cc" 156 "../../../mindspore/ccsrc/backend/session/ascend_control_parser.cc" 157 "../../../mindspore/ccsrc/backend/session/kernel_graph.cc" 158 "../../../mindspore/ccsrc/backend/session/session_basic.cc" 159 "../../../mindspore/ccsrc/backend/session/executor.cc" 160 "../../../mindspore/core/ops/*.cc" 161 "../../../mindspore/ccsrc/backend/session/executor_manager.cc" 162 "../../../mindspore/ccsrc/backend/session/session_factory.cc" 163 "../../../mindspore/ccsrc/backend/session/kernel_build_client.cc" 164 "../../../mindspore/ccsrc/transform/graph_ir/*.cc" 165 "../../../mindspore/ccsrc/transform/graph_ir/op_declare/*.cc" 166 "../../../mindspore/ccsrc/ps/*.cc" 167 "../../../mindspore/ccsrc/fl/*.cc" 168 "../../../mindspore/ccsrc/profiler/device/ascend/*.cc" 169 "../../../mindspore/ccsrc/profiler/device/profiling.cc" 170 "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/adam_fp32.c" 171 ) 172 173if(ENABLE_SECURITY) 174 file(GLOB_RECURSE _INFER_SUMMARY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 175 "../../../mindspore/core/ops/*_summary.cc" 176 ) 177 list(REMOVE_ITEM MINDSPORE_SRC_LIST ${_INFER_SUMMARY_FILES}) 178endif() 179list(REMOVE_ITEM MINDSPORE_SRC_LIST 180 "../../../mindspore/ccsrc/frontend/parallel/strategy_checkpoint/parallel_strategy_checkpoint.cc") 181list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/util.cc") 182list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/scheduler.cc") 183list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/optimizer_info.cc") 184list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/optimizer_info_builder.cc") 185list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/worker.cc") 186list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/parameter_server.cc") 187list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/ps_cache/gpu/gpu_ps_cache.cc") 188list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/ps_cache/ascend/ascend_ps_cache.cc") 189list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc") 190list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/fl/server/kernel/apply_momentum_kernel.cc") 191list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/fl/server/kernel/sgd_kernel.cc") 192list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/backend/optimizer/gpu/batch_norm_add_relu_fusion.cc") 193list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/backend/optimizer/gpu/post_batch_norm_add_relu_fusion.cc") 194list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/backend/optimizer/gpu/batch_norm_add_relu_grad_fusion.cc") 195list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/backend/optimizer/gpu/batch_norm_relu_fusion.cc") 196list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/backend/optimizer/gpu/batch_norm_relu_grad_fusion.cc") 197list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/backend/kernel_compiler/tbe/ascend_kernel_compile.cc") 198if(ENABLE_SECURITY) 199 list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/profiler/device/profiling.cc") 200 list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/profiler/device/ascend/memory_profiling.cc") 201 list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/profiler/device/ascend/ascend_profiling.cc") 202 list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/data_dump/dump_json_parser.cc") 203endif() 204 205add_library(_ut_mindspore_obj OBJECT ${MINDSPORE_SRC_LIST}) 206add_library(_ut_ut_obj OBJECT ${UT_SRCS}) 207add_dependencies(_ut_mindspore_obj graph) 208add_dependencies(_ut_ut_obj engine-cache-server graph) 209add_executable(ut_tests $<TARGET_OBJECTS:_ut_ut_obj> 210 $<TARGET_OBJECTS:_ut_mindspore_obj>) 211 212if(ENABLE_GE) 213 if(ENABLE_TRAIN) 214 target_link_libraries(ut_tests PRIVATE graph ge_runner) 215 else() 216 target_link_libraries(ut_tests PRIVATE graph ge_client) 217 endif() 218 219 target_link_libraries(mindspore PRIVATE tsdclient) 220endif() 221 222if(CMAKE_SYSTEM_NAME MATCHES "Linux") 223 target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore::event mindspore::event_pthreads 224 mindspore::event_openssl mindspore_gvar ${PYTHON_LIBRARIES} pthread util dl) 225 if(ENABLE_MINDDATA) 226 227 # AUX_SOURCE_DIRECTORY(LITE_CV_FILES) 228 # message(STATUS "xxxxxxxxxxxxxxxxx"${LITE_CV_FILES} ) 229 # add_library(_live_cv OBJECT ${LITE_CV_FILES}) 230 231 target_link_libraries(ut_tests PRIVATE _c_dataengine _c_mindrecord) 232 endif() 233else() 234 target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES}) 235endif() 236if(USE_GLOG) 237 target_link_libraries(ut_tests PRIVATE mindspore::glog) 238endif() 239 240target_link_libraries(mindspore mindspore_core) 241target_link_libraries(ut_tests PRIVATE mindspore mindspore_shared_lib securec graph error_manager) 242