CMakeLists.txt 2.7 KB
Newer Older
1
unset(analysis_deps CACHE)
2
set(analysis_deps # analysis_deps can be extended across the project
3 4 5 6 7 8 9 10 11
    framework_proto
    proto_desc
    graph
    pass
    paddle_inference_io
    executor
    pretty_log
    ir_pass_manager
    CACHE INTERNAL "")
12

13 14 15
add_subdirectory(ir_passes)
add_subdirectory(passes)

16 17 18 19
cc_library(
  analysis_helper
  SRCS helper.cc
  DEPS framework_proto proto_desc graph paddle_inference_io)
N
nhzlx 已提交
20

21 22 23 24
cc_library(
  ir_pass_manager
  SRCS ir_pass_manager.cc
  DEPS graph pass ${INFER_IR_PASSES} analysis_helper)
25

26 27 28 29 30 31 32 33
cc_library(
  argument INTERFACE
  SRCS argument.cc
  DEPS scope proto_desc)
cc_library(
  analysis_pass INTERFACE
  SRCS analysis_pass.cc
  DEPS proto_desc)
34

35 36 37 38
cc_library(
  analysis
  SRCS analyzer.cc
  DEPS ${analysis_deps} analysis_helper analysis_pass ${INFER_IR_PASSES})
39

40 41
function(inference_analysis_test_build TARGET)
  if(WITH_TESTING)
42 43 44 45 46 47 48 49 50 51
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs SRCS EXTRA_DEPS)
    cmake_parse_arguments(analysis_test "${options}" "${oneValueArgs}"
                          "${multiValueArgs}" ${ARGN})
    inference_base_test_build(
      ${TARGET}
      SRCS
      ${analysis_test_SRCS}
      DEPS
52
      ${analysis_test_EXTRA_DEPS}
53 54
      analysis
      pass
55
      ${GLOB_PASS_LIB})
56 57 58 59 60
  endif()
endfunction()

function(inference_analysis_test_run TARGET)
  if(WITH_TESTING)
61 62 63 64 65 66 67
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs COMMAND ARGS)
    cmake_parse_arguments(analysis_test "${options}" "${oneValueArgs}"
                          "${multiValueArgs}" ${ARGN})
    inference_base_test_run(${TARGET} COMMAND ${analysis_test_COMMAND} ARGS
                            ${analysis_test_ARGS})
68 69 70
  endif()
endfunction()

71 72
function(inference_analysis_test TARGET)
  if(WITH_TESTING)
73 74 75 76 77 78 79 80 81 82
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs SRCS ARGS EXTRA_DEPS)
    cmake_parse_arguments(analysis_test "${options}" "${oneValueArgs}"
                          "${multiValueArgs}" ${ARGN})
    inference_base_test_build(
      ${TARGET}
      SRCS
      ${analysis_test_SRCS}
      DEPS
83
      ${analysis_test_EXTRA_DEPS}
84 85
      analysis
      pass
86
      ${GLOB_PASS_LIB})
87 88
    inference_base_test_run(${TARGET} COMMAND ${TARGET} ARGS
                            ${analysis_test_ARGS})
89
  endif()
W
Wilber 已提交
90
endfunction()
Y
Yan Chunwei 已提交
91

92 93 94 95 96 97 98 99 100 101
if(NOT APPLE AND NOT WIN32)
  inference_analysis_test(
    test_analyzer
    SRCS
    analyzer_tester.cc
    EXTRA_DEPS
    reset_tensor_array
    paddle_inference_shared
    ARGS
    --inference_model_dir=${WORD2VEC_MODEL_DIR})
102
elseif(WIN32)
103 104 105 106 107 108 109 110 111
  inference_analysis_test(
    test_analyzer
    SRCS
    analyzer_tester.cc
    EXTRA_DEPS
    reset_tensor_array
    paddle_inference_api
    ARGS
    --inference_model_dir=${WORD2VEC_MODEL_DIR})
112
endif()