From 5023530a8a21bbbcd6705fbd5fafafd950fe2617 Mon Sep 17 00:00:00 2001 From: Yan Chunwei Date: Mon, 10 Sep 2018 14:07:45 +0800 Subject: [PATCH] Refactor/remove sensitive (#13314) --- .../fluid/inference/analysis/CMakeLists.txt | 16 ++++---- .../inference/analysis/analyzer_tester.cc | 40 ++++++------------- 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/paddle/fluid/inference/analysis/CMakeLists.txt b/paddle/fluid/inference/analysis/CMakeLists.txt index a115bc8f4a3..11a7509feb0 100644 --- a/paddle/fluid/inference/analysis/CMakeLists.txt +++ b/paddle/fluid/inference/analysis/CMakeLists.txt @@ -48,18 +48,18 @@ function (inference_download_and_uncompress install_dir url gz_filename) message(STATUS "finish downloading ${gz_filename}") endfunction(inference_download_and_uncompress) -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) -if (NOT EXISTS ${DITU_INSTALL_DIR} AND WITH_TESTING) - 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") +set(RNN1_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/rnn1%2Fmodel.tar.gz") +set(RNN1_DATA_URL "http://paddle-inference-dist.bj.bcebos.com/rnn1%2Fdata.txt.tar.gz") +set(RNN1_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/rnn1" CACHE PATH "RNN1 model and data root." FORCE) +if (NOT EXISTS ${RNN1_INSTALL_DIR} AND WITH_TESTING) + inference_download_and_uncompress(${RNN1_INSTALL_DIR} ${RNN1_MODEL_URL} "rnn1%2Fmodel.tar.gz") + inference_download_and_uncompress(${RNN1_INSTALL_DIR} ${RNN1_DATA_URL} "rnn1%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_predictor - ARGS --infer_ditu_rnn_model=${DITU_INSTALL_DIR}/model - --infer_ditu_rnn_data=${DITU_INSTALL_DIR}/data.txt) + ARGS --infer_model=${RNN1_INSTALL_DIR}/model + --infer_data=${RNN1_INSTALL_DIR}/data.txt) 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) diff --git a/paddle/fluid/inference/analysis/analyzer_tester.cc b/paddle/fluid/inference/analysis/analyzer_tester.cc index dc1b03b2d16..cc4b390495c 100644 --- a/paddle/fluid/inference/analysis/analyzer_tester.cc +++ b/paddle/fluid/inference/analysis/analyzer_tester.cc @@ -26,8 +26,8 @@ #include "paddle/fluid/inference/api/paddle_inference_pass.h" #include "paddle/fluid/inference/utils/singleton.h" -DEFINE_string(infer_ditu_rnn_model, "", "model path for ditu RNN"); -DEFINE_string(infer_ditu_rnn_data, "", "data path for ditu RNN"); +DEFINE_string(infer_model, "", "model path"); +DEFINE_string(infer_data, "", "data path"); DEFINE_int32(batch_size, 10, "batch size."); DEFINE_int32(repeat, 1, "Running the inference program repeat times."); DEFINE_int32(num_threads, 1, "Running the inference program in multi-threads."); @@ -223,17 +223,6 @@ void PrepareInputs(std::vector *input_slots, DataRecord *data, } // namespace -const float ditu_rnn_target_data[] = { - 104.711, 11.2431, 1.35422, 0, 0, 0, 0, 0, - 27.7039, 1.41486, 7.09526, 0, 0, 0, 0, 0, - 7.6481, 6.5324, 56.383, 2.88018, 8.92918, 132.007, 4.27429, 2.02934, - 14.1727, 10.7461, 25.0616, 16.0197, 14.4163, 16.9199, 6.75517, 0, - 80.0249, 4.77739, 0, 0, 0, 0, 0, 0, - 47.5643, 2.67029, 8.76252, 0, 0, 0, 0, 0, - 51.8822, 4.4411, 0, 0, 0, 0, 0, 0, - 10.7286, 12.0595, 10.6672, 0, 0, 0, 0, 0, - 93.5771, 3.84641, 0, 0, 0, 0, 0, 0, - 169.426, 0, 0, 0, 0, 0, 0, 0}; void CompareResult(const std::vector &outputs, const std::vector &base_outputs) { PADDLE_ENFORCE_GT(outputs.size(), 0); @@ -255,11 +244,10 @@ void CompareResult(const std::vector &outputs, } } // Test with a really complicate model. -void TestDituRNNPrediction(bool use_analysis, bool activate_ir, - int num_threads) { +void TestRNN1Prediction(bool use_analysis, bool activate_ir, int num_threads) { AnalysisConfig config; - config.prog_file = FLAGS_infer_ditu_rnn_model + "/__model__"; - config.param_file = FLAGS_infer_ditu_rnn_model + "/param"; + config.prog_file = FLAGS_infer_model + "/__model__"; + config.param_file = FLAGS_infer_model + "/param"; config.use_gpu = false; config.device = 0; config.specify_input_name = true; @@ -277,7 +265,7 @@ void TestDituRNNPrediction(bool use_analysis, bool activate_ir, CreatePaddlePredictor( config); std::vector input_slots; - DataRecord data(FLAGS_infer_ditu_rnn_data, batch_size); + DataRecord data(FLAGS_infer_data, batch_size); // Prepare inputs. PrepareInputs(&input_slots, &data, batch_size); std::vector outputs, base_outputs; @@ -307,7 +295,7 @@ void TestDituRNNPrediction(bool use_analysis, bool activate_ir, threads.emplace_back([&, tid]() { // Each thread should have local input_slots and outputs. std::vector input_slots; - DataRecord data(FLAGS_infer_ditu_rnn_data, batch_size); + DataRecord data(FLAGS_infer_data, batch_size); PrepareInputs(&input_slots, &data, batch_size); std::vector outputs; Timer timer; @@ -354,24 +342,22 @@ void TestDituRNNPrediction(bool use_analysis, bool activate_ir, } // Inference with analysis and IR, easy for profiling independently. -TEST(Analyzer, DituRNN) { - TestDituRNNPrediction(true, true, FLAGS_num_threads); -} +TEST(Analyzer, rnn1) { TestRNN1Prediction(true, true, FLAGS_num_threads); } -// Other unit-tests of DituRNN, test different options of use_analysis, +// Other unit-tests of RNN1, test different options of use_analysis, // activate_ir and multi-threads. -TEST(Analyzer, DituRNN_tests) { +TEST(Analyzer, RNN_tests) { int num_threads[2] = {1, 4}; for (auto i : num_threads) { // Directly infer with the original model. - TestDituRNNPrediction(false, false, i); + TestRNN1Prediction(false, false, i); // Inference with the original model with the analysis turned on, the // analysis // module will transform the program to a data flow graph. - TestDituRNNPrediction(true, false, i); + TestRNN1Prediction(true, false, i); // Inference with analysis and IR. The IR module will fuse some large // kernels. - TestDituRNNPrediction(true, true, i); + TestRNN1Prediction(true, true, i); } } -- GitLab