未验证 提交 dbc2bb33 编写于 作者: L liu zhengxi 提交者: GitHub

improve the performance of capi in PD_PredictorRun (#20665)

上级 a3e641e9
......@@ -29,7 +29,13 @@ bool PD_PredictorRun(const PD_AnalysisConfig* config, PD_Tensor* inputs,
int in_size, PD_Tensor* output_data, int** out_size,
int batch_size) {
PADDLE_ENFORCE_NOT_NULL(config);
auto predictor = paddle::CreatePaddlePredictor(config->config);
static std::map<std::string, std::unique_ptr<paddle::PaddlePredictor>>
predictors;
if (!predictors.count(config->config.model_dir())) {
predictors[config->config.model_dir()] =
paddle::CreatePaddlePredictor(config->config);
}
auto& predictor = predictors[config->config.model_dir()];
std::vector<paddle::PaddleTensor> in;
for (int i = 0; i < in_size; ++i) {
in.emplace_back(inputs->tensor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册