C++多线程预测,使用brpc包装,QPS太低
Created by: dancingpipi
fluid 1.4 代码如下:
int Classifier::predict(paddle::PaddleTensor &image_tensor, paddle::PaddleTensor &audio_tensor, std::vector<float> &output, const int index){
int ret_code = 0;
try {
std::vector<paddle::PaddleTensor> tensor_feeds;
std::vector<paddle::PaddleTensor> outputs;
tensor_feeds.emplace_back(std::move(image_tensor));
tensor_feeds.emplace_back(std::move(audio_tensor));
auto predictor = _main_predictor->Clone();
predictor->Run(tensor_feeds, &outputs, 1);
const size_t num_elements = outputs.front().data.length() / sizeof(float);
auto *output_data = static_cast<float *>(outputs.front().data.data());
output.assign(output_data, output_data + num_elements);
} catch (const std::exception &err){
LOG(ERROR) << "error occur in predict : " << err.what();
ret_code = -1;
}
return ret_code;
}
QPS特别低,请问下原因,我的使用姿势正确吗?