text_classification infer performance test#11080
text_classification infer performance test#11080tensor-tang merged 22 commits intoPaddlePaddle:developfrom
Conversation
|
Last failure is: |
| auto start_ms = GetCurrentMs(); | ||
| for (size_t i = 0; i < inputs.size(); ++i) { | ||
| feed_targets[feed_target_names[0]] = inputs[i]; | ||
| executor->Run(*copy_program, scope, &feed_targets, &fetch_targets, true, |
There was a problem hiding this comment.
create a subscope to run the executor
auto sub_scope = scope->NewScope();
executor->Run(sub_scope);
scope->DeleteScope(sub_scope);There was a problem hiding this comment.
feed data into sub_scope if needed.
There was a problem hiding this comment.
Thanks. I will update.
| // 1. Define place, executor, scope | ||
| auto place = paddle::platform::CPUPlace(); | ||
| auto executor = paddle::framework::Executor(place); | ||
| auto* scope = new paddle::framework::Scope(); |
There was a problem hiding this comment.
std::unique_ptrpaddle::framework::Scope scope(new paddle::framework::Scope);
| for (size_t i = 0; i < inputs.size(); ++i) { | ||
| feed_targets[feed_target_names[0]] = inputs[i]; | ||
| executor->Run(*copy_program, &sub_scope, &feed_targets, &fetch_targets, | ||
| true, true, feed_holder_name, fetch_holder_name); |
There was a problem hiding this comment.
add some comments to true such as
true/*use_gpu*/, true/* with_monitor*/and it will be more clear.
| return 1e+3 * time.tv_sec + 1e-3 * time.tv_usec; | ||
| } | ||
|
|
||
| // return size of total words |
There was a problem hiding this comment.
Add some comment to describe the function.
| return sz; | ||
| } | ||
|
|
||
| void SplitData( |
There was a problem hiding this comment.
Add some comment to describe the function.
| return 1e+3 * time.tv_sec + 1e-3 * time.tv_usec; | ||
| } | ||
|
|
||
| // return size of total words |
| return sz; | ||
| } | ||
|
|
||
| void SplitData( |
| for (size_t i = 0; i < inputs.size(); ++i) { | ||
| feed_targets[feed_target_names[0]] = inputs[i]; | ||
| executor->Run(*copy_program, &sub_scope, &feed_targets, &fetch_targets, | ||
| true, true, feed_holder_name, fetch_holder_name); |
| // 1. Define place, executor, scope | ||
| auto place = paddle::platform::CPUPlace(); | ||
| auto executor = paddle::framework::Executor(place); | ||
| auto* scope = new paddle::framework::Scope(); |
|
Done @Superjomn |
| #include <omp.h> | ||
| #endif | ||
|
|
||
| DEFINE_string(modelpath, "", "Directory of the inference model."); |
There was a problem hiding this comment.
Sure, I used to follow dirname before.
| #endif | ||
|
|
||
| DEFINE_string(modelpath, "", "Directory of the inference model."); | ||
| DEFINE_string(datafile, "", "File of input index data."); |
| size_t LoadData(std::vector<paddle::framework::LoDTensor>* out, | ||
| const std::string& filename) { | ||
| if (filename.empty()) { | ||
| return DummyData(out); |
There was a problem hiding this comment.
add a log, such as
LOG(WARN) << "pass empty filename, use some dummy data instead";
There was a problem hiding this comment.
This WARN is added here: https://github.com/PaddlePaddle/Paddle/pull/11080/files#diff-1e4d3b9c8b2730e0dacdaf72e35d597fR149
panyx0718
left a comment
There was a problem hiding this comment.
Please address those small comments
| #inference_test(understand_sentiment ARGS conv) | ||
| inference_test(word2vec) | ||
|
|
||
| # This is an unly work around to make this test run |
| while (getline(iss, field, ' ')) { | ||
| ids.push_back(stoi(field)); | ||
| } | ||
| if (ids.size() >= 1024) { |
There was a problem hiding this comment.
After synced with NLP guys, they say they will ignore the inputs which is larger than 1024.
tensor-tang
left a comment
There was a problem hiding this comment.
Thanks for your inputs, I will update.
| #inference_test(understand_sentiment ARGS conv) | ||
| inference_test(word2vec) | ||
|
|
||
| # This is an unly work around to make this test run |
| #include <omp.h> | ||
| #endif | ||
|
|
||
| DEFINE_string(modelpath, "", "Directory of the inference model."); |
There was a problem hiding this comment.
Sure, I used to follow dirname before.
| #endif | ||
|
|
||
| DEFINE_string(modelpath, "", "Directory of the inference model."); | ||
| DEFINE_string(datafile, "", "File of input index data."); |
| size_t LoadData(std::vector<paddle::framework::LoDTensor>* out, | ||
| const std::string& filename) { | ||
| if (filename.empty()) { | ||
| return DummyData(out); |
There was a problem hiding this comment.
This WARN is added here: https://github.com/PaddlePaddle/Paddle/pull/11080/files#diff-1e4d3b9c8b2730e0dacdaf72e35d597fR149
| while (getline(iss, field, ' ')) { | ||
| ids.push_back(stoi(field)); | ||
| } | ||
| if (ids.size() >= 1024) { |
There was a problem hiding this comment.
After synced with NLP guys, they say they will ignore the inputs which is larger than 1024.
This enabled text_classification model inference test on both single thread and multi threads.
We can get performance result shown below, on CPU 2620 v2: