-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
text_classification infer performance test #11080
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feed data into sub_scope if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::unique_ptrpaddle::framework::Scope scope(new paddle::framework::Scope);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure~
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some comments to true
such as
true/*use_gpu*/, true/* with_monitor*/
and it will be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks~
return 1e+3 * time.tv_sec + 1e-3 * time.tv_usec; | ||
} | ||
|
||
// return size of total words |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some comment to describe the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure~
return sz; | ||
} | ||
|
||
void SplitData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some comment to describe the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update
return 1e+3 * time.tv_sec + 1e-3 * time.tv_usec; | ||
} | ||
|
||
// return size of total words |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure~
return sz; | ||
} | ||
|
||
void SplitData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure~
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks~
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure~
Done @Superjomn |
#include <omp.h> | ||
#endif | ||
|
||
DEFINE_string(modelpath, "", "Directory of the inference model."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I used to follow dirname
before.
#endif | ||
|
||
DEFINE_string(modelpath, "", "Directory of the inference model."); | ||
DEFINE_string(datafile, "", "File of input index data."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a log, such as
LOG(WARN) << "pass empty filename, use some dummy data instead";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address those small comments
@@ -38,3 +38,10 @@ inference_test(recommender_system) | |||
#inference_test(rnn_encoder_decoder) | |||
#inference_test(understand_sentiment ARGS conv) | |||
inference_test(word2vec) | |||
|
|||
# This is an unly work around to make this test run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO to clean up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure~
while (getline(iss, field, ' ')) { | ||
ids.push_back(stoi(field)); | ||
} | ||
if (ids.size() >= 1024) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After synced with NLP guys, they say they will ignore the inputs which is larger than 1024.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your inputs, I will update.
@@ -38,3 +38,10 @@ inference_test(recommender_system) | |||
#inference_test(rnn_encoder_decoder) | |||
#inference_test(understand_sentiment ARGS conv) | |||
inference_test(word2vec) | |||
|
|||
# This is an unly work around to make this test run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure~
#include <omp.h> | ||
#endif | ||
|
||
DEFINE_string(modelpath, "", "Directory of the inference model."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I used to follow dirname
before.
#endif | ||
|
||
DEFINE_string(modelpath, "", "Directory of the inference model."); | ||
DEFINE_string(datafile, "", "File of input index data."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while (getline(iss, field, ' ')) { | ||
ids.push_back(stoi(field)); | ||
} | ||
if (ids.size() >= 1024) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: