CMakeLists.txt 6.1 KB
Newer Older
1
cc_library(ir_pass_manager SRCS ir_pass_manager.cc DEPS graph pass)
2 3 4 5
set(analysis_deps
    framework_proto proto_desc ir_pass_manager graph pass paddle_fluid_api executor)

cc_library(analysis SRCS pass_manager.cc node.cc data_flow_graph.cc graph_traits.cc subgraph_splitter.cc
6 7 8
  analyzer.cc
  helper.cc
  # passes
X
Xin Pan 已提交
9
  analysis_pass.cc
Y
Yan Chunwei 已提交
10 11 12
  fluid_to_data_flow_graph_pass.cc
  data_flow_graph_to_fluid_pass.cc
  dfg_graphviz_draw_pass.cc
13 14
  tensorrt_subgraph_pass.cc
  tensorrt_subgraph_node_mark_pass.cc
15 16
  fluid_to_ir_pass.cc
  model_store_pass.cc
17
  DEPS ${analysis_deps})
18 19

cc_test(test_node SRCS node_tester.cc DEPS analysis)
20
cc_test(test_dot SRCS dot_tester.cc DEPS analysis)
21
cc_binary(inference_analyzer SRCS analyzer_main.cc DEPS analysis paddle_fluid)
22 23 24

set(PYTHON_TESTS_DIR ${PADDLE_BINARY_DIR}/python/paddle/fluid/tests)

Y
Yan Chunwei 已提交
25
function (inference_analysis_test TARGET)
S
update  
superjomn 已提交
26 27 28
    if(WITH_TESTING)
        set(options "")
        set(oneValueArgs "")
T
tensor-tang 已提交
29
        set(multiValueArgs SRCS ARGS EXTRA_DEPS)
S
update  
superjomn 已提交
30
        cmake_parse_arguments(analysis_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
31 32 33 34
        set(mem_opt "")
        if(WITH_GPU)
            set(mem_opt "--fraction_of_gpu_memory_to_use=0.5")
        endif()
S
update  
superjomn 已提交
35 36
        cc_test(${TARGET}
                SRCS "${analysis_test_SRCS}"
L
luotao1 已提交
37
                DEPS analysis pass ${GLOB_PASS_LIB} ${analysis_test_EXTRA_DEPS}
T
tensor-tang 已提交
38
                ARGS --inference_model_dir=${PYTHON_TESTS_DIR}/book/word2vec.inference.model ${mem_opt} ${analysis_test_ARGS})
S
update  
superjomn 已提交
39 40
        set_tests_properties(${TARGET} PROPERTIES DEPENDS test_word2vec)
    endif(WITH_TESTING)
Y
Yan Chunwei 已提交
41
endfunction(inference_analysis_test)
Y
Yan Chunwei 已提交
42

L
luotao1 已提交
43
function (inference_download_and_uncompress install_dir url gz_filename)
44
    message(STATUS "Download inference test stuff ${gz_filename} from ${url}")
L
luotao1 已提交
45 46 47
    execute_process(COMMAND bash -c "mkdir -p ${install_dir}")
    execute_process(COMMAND bash -c "cd ${install_dir} && wget -q ${url}")
    execute_process(COMMAND bash -c "cd ${install_dir} && tar xzf ${gz_filename}")
48 49 50
    message(STATUS "finish downloading ${gz_filename}")
endfunction(inference_download_and_uncompress)

L
luotao1 已提交
51 52 53
set(DITU_RNN_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/ditu_rnn_fluid%2Fmodel.tar.gz")
set(DITU_RNN_DATA_URL "http://paddle-inference-dist.bj.bcebos.com/ditu_rnn_fluid%2Fdata.txt.tar.gz")
set(DITU_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/ditu_rnn" CACHE PATH "Ditu RNN model and data root." FORCE)
T
tensor-tang 已提交
54
if (NOT EXISTS ${DITU_INSTALL_DIR} AND WITH_TESTING)
L
luotao1 已提交
55 56
  inference_download_and_uncompress(${DITU_INSTALL_DIR} ${DITU_RNN_MODEL_URL} "ditu_rnn_fluid%2Fmodel.tar.gz")
  inference_download_and_uncompress(${DITU_INSTALL_DIR} ${DITU_RNN_DATA_URL} "ditu_rnn_fluid%2Fdata.txt.tar.gz")
57 58 59
endif()

inference_analysis_test(test_analyzer SRCS analyzer_tester.cc
L
luotao1 已提交
60
    EXTRA_DEPS paddle_inference_api paddle_fluid_api ir_pass_manager analysis_predictor
T
tensor-tang 已提交
61
    ARGS --infer_ditu_rnn_model=${DITU_INSTALL_DIR}/model
62
         --infer_ditu_rnn_data=${DITU_INSTALL_DIR}/data.txt)
63

Y
Yan Chunwei 已提交
64
inference_analysis_test(test_data_flow_graph SRCS data_flow_graph_tester.cc)
L
luotao1 已提交
65 66
inference_analysis_test(test_data_flow_graph_to_fluid_pass SRCS data_flow_graph_to_fluid_pass_tester.cc)
inference_analysis_test(test_fluid_to_ir_pass SRCS fluid_to_ir_pass_tester.cc)
Y
Yan Chunwei 已提交
67 68 69
inference_analysis_test(test_fluid_to_data_flow_graph_pass SRCS fluid_to_data_flow_graph_pass_tester.cc)
inference_analysis_test(test_subgraph_splitter SRCS subgraph_splitter_tester.cc)
inference_analysis_test(test_dfg_graphviz_draw_pass SRCS dfg_graphviz_draw_pass_tester.cc)
70
inference_analysis_test(test_tensorrt_subgraph_pass SRCS tensorrt_subgraph_pass_tester.cc)
Y
Yan Chunwei 已提交
71
inference_analysis_test(test_pass_manager SRCS pass_manager_tester.cc)
72
inference_analysis_test(test_tensorrt_subgraph_node_mark_pass SRCS tensorrt_subgraph_node_mark_pass_tester.cc)
Y
Yan Chunwei 已提交
73
inference_analysis_test(test_model_store_pass SRCS model_store_pass_tester.cc)
L
luotao1 已提交
74 75 76 77

set(CHINESE_NER_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/chinese_ner_model.tar.gz")
set(CHINESE_NER_DATA_URL "http://paddle-inference-dist.bj.bcebos.com/chinese_ner-data.txt.tar.gz")
set(CHINESE_NER_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/chinese_ner" CACHE PATH "Chinese ner model and data root." FORCE)
78
if (NOT EXISTS ${CHINESE_NER_INSTALL_DIR} AND WITH_TESTING AND WITH_INFERENCE)
L
luotao1 已提交
79 80 81 82
  inference_download_and_uncompress(${CHINESE_NER_INSTALL_DIR} ${CHINESE_NER_MODEL_URL} "chinese_ner_model.tar.gz")
  inference_download_and_uncompress(${CHINESE_NER_INSTALL_DIR} ${CHINESE_NER_DATA_URL} "chinese_ner-data.txt.tar.gz")
endif()

T
tensor-tang 已提交
83
inference_analysis_test(test_analyzer_ner SRCS analyzer_ner_tester.cc
L
luotao1 已提交
84
    EXTRA_DEPS paddle_inference_api paddle_fluid_api
T
tensor-tang 已提交
85
    ARGS --infer_model=${CHINESE_NER_INSTALL_DIR}/model
L
luotao1 已提交
86
        --infer_data=${CHINESE_NER_INSTALL_DIR}/data.txt)
T
tensor-tang 已提交
87 88 89 90

set(LAC_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/lac_model.tar.gz")
set(LAC_DATA_URL "http://paddle-inference-dist.bj.bcebos.com/lac_data.txt.tar.gz")
set(LAC_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/lac" CACHE PATH "LAC model and data root." FORCE)
91
if (NOT EXISTS ${LAC_INSTALL_DIR} AND WITH_TESTING AND WITH_INFERENCE)
T
tensor-tang 已提交
92 93 94 95 96 97 98 99
    inference_download_and_uncompress(${LAC_INSTALL_DIR} ${LAC_MODEL_URL} "lac_model.tar.gz")
    inference_download_and_uncompress(${LAC_INSTALL_DIR} ${LAC_DATA_URL} "lac_data.txt.tar.gz")
endif()

inference_analysis_test(test_analyzer_lac SRCS analyzer_lac_tester.cc
    EXTRA_DEPS paddle_inference_api paddle_fluid_api
    ARGS --infer_model=${LAC_INSTALL_DIR}/model
        --infer_data=${LAC_INSTALL_DIR}/data.txt)
100 101 102 103 104 105 106 107 108 109 110 111


set(TEXT_CLASSIFICATION_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/text-classification-Senta.tar.gz")
set(TEXT_CLASSIFICATION_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/text_classification" CACHE PATH "Text Classification model and data root." FORCE)

if (NOT EXISTS ${TEXT_CLASSIFICATION_INSTALL_DIR} AND WITH_TESTING AND WITH_INFERENCE)
  inference_download_and_uncompress(${TEXT_CLASSIFICATION_INSTALL_DIR} ${TEXT_CLASSIFICATION_MODEL_URL} "text-classification-Senta.tar.gz")
endif()

inference_analysis_test(test_text_classification SRCS test_text_classification.cc
    EXTRA_DEPS paddle_inference_api paddle_fluid_api analysis_predictor
    ARGS --infer_model=${TEXT_CLASSIFICATION_INSTALL_DIR}/text-classification-Senta)