Skip to content

Commit 5023530

Browse files
authored
Refactor/remove sensitive (#13314)
1 parent 478a4e8 commit 5023530

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

paddle/fluid/inference/analysis/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ function (inference_download_and_uncompress install_dir url gz_filename)
4848
message(STATUS "finish downloading ${gz_filename}")
4949
endfunction(inference_download_and_uncompress)
5050

51-
set(DITU_RNN_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/ditu_rnn_fluid%2Fmodel.tar.gz")
52-
set(DITU_RNN_DATA_URL "http://paddle-inference-dist.bj.bcebos.com/ditu_rnn_fluid%2Fdata.txt.tar.gz")
53-
set(DITU_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/ditu_rnn" CACHE PATH "Ditu RNN model and data root." FORCE)
54-
if (NOT EXISTS ${DITU_INSTALL_DIR} AND WITH_TESTING)
55-
inference_download_and_uncompress(${DITU_INSTALL_DIR} ${DITU_RNN_MODEL_URL} "ditu_rnn_fluid%2Fmodel.tar.gz")
56-
inference_download_and_uncompress(${DITU_INSTALL_DIR} ${DITU_RNN_DATA_URL} "ditu_rnn_fluid%2Fdata.txt.tar.gz")
51+
set(RNN1_MODEL_URL "http://paddle-inference-dist.bj.bcebos.com/rnn1%2Fmodel.tar.gz")
52+
set(RNN1_DATA_URL "http://paddle-inference-dist.bj.bcebos.com/rnn1%2Fdata.txt.tar.gz")
53+
set(RNN1_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/rnn1" CACHE PATH "RNN1 model and data root." FORCE)
54+
if (NOT EXISTS ${RNN1_INSTALL_DIR} AND WITH_TESTING)
55+
inference_download_and_uncompress(${RNN1_INSTALL_DIR} ${RNN1_MODEL_URL} "rnn1%2Fmodel.tar.gz")
56+
inference_download_and_uncompress(${RNN1_INSTALL_DIR} ${RNN1_DATA_URL} "rnn1%2Fdata.txt.tar.gz")
5757
endif()
5858

5959
inference_analysis_test(test_analyzer SRCS analyzer_tester.cc
6060
EXTRA_DEPS paddle_inference_api paddle_fluid_api ir_pass_manager analysis_predictor
61-
ARGS --infer_ditu_rnn_model=${DITU_INSTALL_DIR}/model
62-
--infer_ditu_rnn_data=${DITU_INSTALL_DIR}/data.txt)
61+
ARGS --infer_model=${RNN1_INSTALL_DIR}/model
62+
--infer_data=${RNN1_INSTALL_DIR}/data.txt)
6363

6464
inference_analysis_test(test_data_flow_graph SRCS data_flow_graph_tester.cc)
6565
inference_analysis_test(test_data_flow_graph_to_fluid_pass SRCS data_flow_graph_to_fluid_pass_tester.cc)

paddle/fluid/inference/analysis/analyzer_tester.cc

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "paddle/fluid/inference/api/paddle_inference_pass.h"
2727
#include "paddle/fluid/inference/utils/singleton.h"
2828

29-
DEFINE_string(infer_ditu_rnn_model, "", "model path for ditu RNN");
30-
DEFINE_string(infer_ditu_rnn_data, "", "data path for ditu RNN");
29+
DEFINE_string(infer_model, "", "model path");
30+
DEFINE_string(infer_data, "", "data path");
3131
DEFINE_int32(batch_size, 10, "batch size.");
3232
DEFINE_int32(repeat, 1, "Running the inference program repeat times.");
3333
DEFINE_int32(num_threads, 1, "Running the inference program in multi-threads.");
@@ -223,17 +223,6 @@ void PrepareInputs(std::vector<PaddleTensor> *input_slots, DataRecord *data,
223223

224224
} // namespace
225225

226-
const float ditu_rnn_target_data[] = {
227-
104.711, 11.2431, 1.35422, 0, 0, 0, 0, 0,
228-
27.7039, 1.41486, 7.09526, 0, 0, 0, 0, 0,
229-
7.6481, 6.5324, 56.383, 2.88018, 8.92918, 132.007, 4.27429, 2.02934,
230-
14.1727, 10.7461, 25.0616, 16.0197, 14.4163, 16.9199, 6.75517, 0,
231-
80.0249, 4.77739, 0, 0, 0, 0, 0, 0,
232-
47.5643, 2.67029, 8.76252, 0, 0, 0, 0, 0,
233-
51.8822, 4.4411, 0, 0, 0, 0, 0, 0,
234-
10.7286, 12.0595, 10.6672, 0, 0, 0, 0, 0,
235-
93.5771, 3.84641, 0, 0, 0, 0, 0, 0,
236-
169.426, 0, 0, 0, 0, 0, 0, 0};
237226
void CompareResult(const std::vector<PaddleTensor> &outputs,
238227
const std::vector<PaddleTensor> &base_outputs) {
239228
PADDLE_ENFORCE_GT(outputs.size(), 0);
@@ -255,11 +244,10 @@ void CompareResult(const std::vector<PaddleTensor> &outputs,
255244
}
256245
}
257246
// Test with a really complicate model.
258-
void TestDituRNNPrediction(bool use_analysis, bool activate_ir,
259-
int num_threads) {
247+
void TestRNN1Prediction(bool use_analysis, bool activate_ir, int num_threads) {
260248
AnalysisConfig config;
261-
config.prog_file = FLAGS_infer_ditu_rnn_model + "/__model__";
262-
config.param_file = FLAGS_infer_ditu_rnn_model + "/param";
249+
config.prog_file = FLAGS_infer_model + "/__model__";
250+
config.param_file = FLAGS_infer_model + "/param";
263251
config.use_gpu = false;
264252
config.device = 0;
265253
config.specify_input_name = true;
@@ -277,7 +265,7 @@ void TestDituRNNPrediction(bool use_analysis, bool activate_ir,
277265
CreatePaddlePredictor<AnalysisConfig, PaddleEngineKind::kAnalysis>(
278266
config);
279267
std::vector<PaddleTensor> input_slots;
280-
DataRecord data(FLAGS_infer_ditu_rnn_data, batch_size);
268+
DataRecord data(FLAGS_infer_data, batch_size);
281269
// Prepare inputs.
282270
PrepareInputs(&input_slots, &data, batch_size);
283271
std::vector<PaddleTensor> outputs, base_outputs;
@@ -307,7 +295,7 @@ void TestDituRNNPrediction(bool use_analysis, bool activate_ir,
307295
threads.emplace_back([&, tid]() {
308296
// Each thread should have local input_slots and outputs.
309297
std::vector<PaddleTensor> input_slots;
310-
DataRecord data(FLAGS_infer_ditu_rnn_data, batch_size);
298+
DataRecord data(FLAGS_infer_data, batch_size);
311299
PrepareInputs(&input_slots, &data, batch_size);
312300
std::vector<PaddleTensor> outputs;
313301
Timer timer;
@@ -354,24 +342,22 @@ void TestDituRNNPrediction(bool use_analysis, bool activate_ir,
354342
}
355343

356344
// Inference with analysis and IR, easy for profiling independently.
357-
TEST(Analyzer, DituRNN) {
358-
TestDituRNNPrediction(true, true, FLAGS_num_threads);
359-
}
345+
TEST(Analyzer, rnn1) { TestRNN1Prediction(true, true, FLAGS_num_threads); }
360346

361-
// Other unit-tests of DituRNN, test different options of use_analysis,
347+
// Other unit-tests of RNN1, test different options of use_analysis,
362348
// activate_ir and multi-threads.
363-
TEST(Analyzer, DituRNN_tests) {
349+
TEST(Analyzer, RNN_tests) {
364350
int num_threads[2] = {1, 4};
365351
for (auto i : num_threads) {
366352
// Directly infer with the original model.
367-
TestDituRNNPrediction(false, false, i);
353+
TestRNN1Prediction(false, false, i);
368354
// Inference with the original model with the analysis turned on, the
369355
// analysis
370356
// module will transform the program to a data flow graph.
371-
TestDituRNNPrediction(true, false, i);
357+
TestRNN1Prediction(true, false, i);
372358
// Inference with analysis and IR. The IR module will fuse some large
373359
// kernels.
374-
TestDituRNNPrediction(true, true, i);
360+
TestRNN1Prediction(true, true, i);
375361
}
376362
}
377363

0 commit comments

Comments
 (0)