CMakeLists.txt 3.0 KB
Newer Older
L
luotao1 已提交
1 2 3 4 5
set(INFERENCE_URL "http://paddle-inference-dist.bj.bcebos.com")
set(INFERENCE_DEMO_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo")
set(INFERENCE_EXTRA_DEPS paddle_inference_api paddle_fluid_api ir_pass_manager analysis_predictor)
function (inference_download_and_uncompress install_dir filename)
    message(STATUS "Download inference test stuff from ${INFERENCE_URL}/${filename}")
6
    execute_process(COMMAND bash -c "mkdir -p ${install_dir}")
L
luotao1 已提交
7
    execute_process(COMMAND bash -c "cd ${install_dir} && wget -q ${INFERENCE_URL}/${filename}")
8 9
    execute_process(COMMAND bash -c "cd ${install_dir} && tar xzf ${filename}")
    message(STATUS "finish downloading ${filename}")
10 11
endfunction(inference_download_and_uncompress)

L
luotao1 已提交
12
function(download_model_and_data install_dir model_name data_name)
13
    if (NOT EXISTS ${install_dir} AND WITH_INFERENCE)
L
luotao1 已提交
14 15
        inference_download_and_uncompress(${install_dir} ${model_name})
        inference_download_and_uncompress(${install_dir} ${data_name})
16 17 18 19
    endif()
endfunction()

# RNN1
L
luotao1 已提交
20 21 22 23
set(RNN1_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/rnn1")
download_model_and_data(${RNN1_INSTALL_DIR} "rnn1%2Fmodel.tar.gz" "rnn1%2Fdata.txt.tar.gz")
inference_analysis_test(test_analyzer_rnn1 SRCS analyzer_rnn1_tester.cc 
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
24 25 26
    ARGS --infer_model=${RNN1_INSTALL_DIR}/model
         --infer_data=${RNN1_INSTALL_DIR}/data.txt)

L
luotao1 已提交
27 28 29 30 31 32 33 34
# RNN2
set(RNN2_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/rnn2")
download_model_and_data(${RNN2_INSTALL_DIR} "rnn2_model.tar.gz" "rnn2_data.txt.tar.gz")
inference_analysis_test(test_analyzer_rnn2 SRCS analyzer_rnn2_tester.cc
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
    ARGS --infer_model=${RNN2_INSTALL_DIR}/model
         --infer_data=${RNN2_INSTALL_DIR}/data.txt)

35
# chinese_ner
L
luotao1 已提交
36 37
set(CHINESE_NER_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/chinese_ner")
download_model_and_data(${CHINESE_NER_INSTALL_DIR} "chinese_ner_model.tar.gz" "chinese_ner-data.txt.tar.gz")
38
inference_analysis_test(test_analyzer_ner SRCS analyzer_ner_tester.cc
L
luotao1 已提交
39
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
40 41 42 43
    ARGS --infer_model=${CHINESE_NER_INSTALL_DIR}/model
        --infer_data=${CHINESE_NER_INSTALL_DIR}/data.txt)

# lac
L
luotao1 已提交
44 45
set(LAC_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/lac")
download_model_and_data(${LAC_INSTALL_DIR} "lac_model.tar.gz" "lac_data.txt.tar.gz")
46
inference_analysis_test(test_analyzer_lac SRCS analyzer_lac_tester.cc
L
luotao1 已提交
47
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
48 49 50 51
    ARGS --infer_model=${LAC_INSTALL_DIR}/model
        --infer_data=${LAC_INSTALL_DIR}/data.txt)

# text_classification
L
luotao1 已提交
52 53
set(TEXT_CLASSIFICATION_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/text_classification")
download_model_and_data(${TEXT_CLASSIFICATION_INSTALL_DIR} "text-classification-Senta.tar.gz" "text_classification_data.txt.tar.gz")
54
inference_analysis_test(test_text_classification SRCS analyzer_text_classification_tester.cc
L
luotao1 已提交
55
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
56 57 58 59
    ARGS --infer_model=${TEXT_CLASSIFICATION_INSTALL_DIR}/text-classification-Senta
         --infer_data=${TEXT_CLASSIFICATION_INSTALL_DIR}/data.txt
         --topn=1 # Just run top 1 batch.
         )