@@ -24,8 +24,8 @@ limitations under the License. */
24
24
#include < omp.h>
25
25
#endif
26
26
27
- DEFINE_string (modelpath , " " , " Directory of the inference model." );
28
- DEFINE_string (datafile , " " , " File of input index data." );
27
+ DEFINE_string (model_path , " " , " Directory of the inference model." );
28
+ DEFINE_string (data_file , " " , " File of input index data." );
29
29
DEFINE_int32 (repeat, 100 , " Running the inference program repeat times" );
30
30
DEFINE_bool (use_mkldnn, false , " Use MKLDNN to run inference" );
31
31
DEFINE_bool (prepare_vars, true , " Prepare variables before executor" );
@@ -65,6 +65,7 @@ size_t LoadData(std::vector<paddle::framework::LoDTensor>* out,
65
65
ids.push_back (stoi (field));
66
66
}
67
67
if (ids.size () >= 1024 ) {
68
+ // Synced with NLP guys, they will ignore input larger then 1024
68
69
continue ;
69
70
}
70
71
@@ -142,18 +143,18 @@ void ThreadRunInfer(
142
143
}
143
144
144
145
TEST (inference, nlp) {
145
- if (FLAGS_modelpath .empty ()) {
146
- LOG (FATAL) << " Usage: ./example --modelpath =path/to/your/model" ;
146
+ if (FLAGS_model_path .empty ()) {
147
+ LOG (FATAL) << " Usage: ./example --model_path =path/to/your/model" ;
147
148
}
148
- if (FLAGS_datafile .empty ()) {
149
- LOG (WARNING) << " Not data file provided, will use dummy data!"
149
+ if (FLAGS_data_file .empty ()) {
150
+ LOG (WARNING) << " No data file provided, will use dummy data!"
150
151
<< " Note: if you use nlp model, please provide data file." ;
151
152
}
152
- LOG (INFO) << " Model Path: " << FLAGS_modelpath ;
153
- LOG (INFO) << " Data File: " << FLAGS_datafile ;
153
+ LOG (INFO) << " Model Path: " << FLAGS_model_path ;
154
+ LOG (INFO) << " Data File: " << FLAGS_data_file ;
154
155
155
156
std::vector<paddle::framework::LoDTensor> datasets;
156
- size_t num_total_words = LoadData (&datasets, FLAGS_datafile );
157
+ size_t num_total_words = LoadData (&datasets, FLAGS_data_file );
157
158
LOG (INFO) << " Number of samples (seq_len<1024): " << datasets.size ();
158
159
LOG (INFO) << " Total number of words: " << num_total_words;
159
160
@@ -168,7 +169,7 @@ TEST(inference, nlp) {
168
169
// 2. Initialize the inference_program and load parameters
169
170
std::unique_ptr<paddle::framework::ProgramDesc> inference_program;
170
171
inference_program =
171
- InitProgram (&executor, scope.get (), FLAGS_modelpath , model_combined);
172
+ InitProgram (&executor, scope.get (), FLAGS_model_path , model_combined);
172
173
if (FLAGS_use_mkldnn) {
173
174
EnableMKLDNN (inference_program);
174
175
}
0 commit comments