CMakeLists.txt 4.0 KB
Newer Older
1
cc_library(ir_pass_manager SRCS ir_pass_manager.cc DEPS graph pass)
Y
Yan Chunwei 已提交
2
cc_library(analysis SRCS pass_manager.cc dot.cc node.cc data_flow_graph.cc graph_traits.cc subgraph_splitter.cc
3 4 5
  analyzer.cc
  helper.cc
  # passes
Y
Yan Chunwei 已提交
6 7 8
  fluid_to_data_flow_graph_pass.cc
  data_flow_graph_to_fluid_pass.cc
  dfg_graphviz_draw_pass.cc
9 10
  tensorrt_subgraph_pass.cc
  tensorrt_subgraph_node_mark_pass.cc
11 12 13 14 15
  fluid_to_ir_pass.cc
  model_store_pass.cc
  DEPS framework_proto proto_desc ir_pass_manager graph pass)

cc_test(test_node SRCS node_tester.cc DEPS analysis)
16
cc_test(test_dot SRCS dot_tester.cc DEPS analysis)
Y
Yan Chunwei 已提交
17
cc_binary(inference_analyzer SRCS analyzer_main.cc DEPS analysis)
18 19 20

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

Y
Yan Chunwei 已提交
21
function (inference_analysis_test TARGET)
S
update  
superjomn 已提交
22 23 24
    if(WITH_TESTING)
        set(options "")
        set(oneValueArgs "")
25
        set(multiValueArgs SRCS EXTRA_DEPS)
S
update  
superjomn 已提交
26
        cmake_parse_arguments(analysis_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
27

28 29 30 31
        set(mem_opt "")
        if(WITH_GPU)
            set(mem_opt "--fraction_of_gpu_memory_to_use=0.5")
        endif()
S
update  
superjomn 已提交
32 33
        cc_test(${TARGET}
                SRCS "${analysis_test_SRCS}"
34
                DEPS analysis graph fc_fuse_pass graph_viz_pass infer_clean_graph_pass graph_pattern_detecter pass ${analysis_test_EXTRA_DEPS}
35
                ARGS --inference_model_dir=${PYTHON_TESTS_DIR}/book/word2vec.inference.model ${mem_opt})
S
update  
superjomn 已提交
36 37
        set_tests_properties(${TARGET} PROPERTIES DEPENDS test_word2vec)
    endif(WITH_TESTING)
Y
Yan Chunwei 已提交
38
endfunction(inference_analysis_test)
Y
Yan Chunwei 已提交
39

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
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}/install/ditu_rnn" CACHE PATH "Ditu RNN model and data root." FORCE)
set(DITU_RNN_MODEL ${DITU_INSTALL_DIR}/model)
set(DITU_RNN_DATA ${DITU_INSTALL_DIR}/data.txt)

function (inference_download_and_uncompress target url gz_filename)
    message(STATUS "Download inference test stuff ${gz_filename} from ${url}")
    execute_process(COMMAND bash -c "mkdir -p ${DITU_INSTALL_DIR}")
    execute_process(COMMAND bash -c "cd ${DITU_INSTALL_DIR} && wget -q ${url}")
    execute_process(COMMAND bash -c "cd ${DITU_INSTALL_DIR} && tar xzf ${gz_filename}")
    message(STATUS "finish downloading ${gz_filename}")
endfunction(inference_download_and_uncompress)

if (NOT EXISTS ${DITU_INSTALL_DIR})
    inference_download_and_uncompress(ditu_rnn_model ${DITU_RNN_MODEL_URL} "ditu_rnn_fluid%2Fmodel.tar.gz")
    inference_download_and_uncompress(ditu_rnn_data ${DITU_RNN_DATA_URL} "ditu_rnn_fluid%2Fdata.txt.tar.gz")
endif()

inference_analysis_test(test_analyzer SRCS analyzer_tester.cc
    EXTRA_DEPS paddle_inference_api paddle_fluid_api ir_pass_manager analysis
		# ir
		fc_fuse_pass
		graph_viz_pass
		infer_clean_graph_pass
		graph_pattern_detecter
        infer_clean_graph_pass
		pass
    ARGS --inference_model_dir=${PYTHON_TESTS_DIR}/book/word2vec.inference.model
        --infer_ditu_rnn_model=${DITU_INSTALL_DIR}/model
        --infer_ditu_rnn_data=${DITU_INSTALL_DIR}/data.txt)
71

Y
Yan Chunwei 已提交
72 73
inference_analysis_test(test_data_flow_graph SRCS data_flow_graph_tester.cc)
inference_analysis_test(test_data_flow_graph_to_fluid_pass SRCS data_flow_graph_to_fluid_pass_tester.cc)
74
inference_analysis_test(test_fluid_to_ir_pass SRCS fluid_to_ir_pass_tester.cc)
Y
Yan Chunwei 已提交
75 76 77
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)
78
inference_analysis_test(test_tensorrt_subgraph_pass SRCS tensorrt_subgraph_pass_tester.cc)
Y
Yan Chunwei 已提交
79
inference_analysis_test(test_pass_manager SRCS pass_manager_tester.cc)
80
inference_analysis_test(test_tensorrt_subgraph_node_mark_pass SRCS tensorrt_subgraph_node_mark_pass_tester.cc)
Y
Yan Chunwei 已提交
81
inference_analysis_test(test_model_store_pass SRCS model_store_pass_tester.cc)