Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -52,9 +52,6 @@ typedef struct OVModel{ · 51 unmodified lines | ||
| 52 | 52 | ie_core_t *core; |
| 53 | 53 | ie_network_t *network; |
| 54 | 54 | ie_executable_network_t *exe_network; |
| 55 | − ie_infer_request_t *infer_request; | |
| 56 | − | |
| 57 | − /* for async execution */ | |
| 58 | 55 | SafeQueue *request_queue; // holds RequestItem |
| 59 | 56 | Queue *task_queue; // holds TaskItem |
| 60 | 57 | } OVModel; |
| @@ -269,12 +266,9 @@ static void infer_completion_callback(void *args) · 208 unmodified lines | ||
| 269 | 266 | ie_blob_free(&output_blob); |
| 270 | 267 | |
| 271 | 268 | request->task_count = 0; |
| 272 | − | |
| 273 | − if (task->async) { | |
| 274 | − if (ff_safe_queue_push_back(requestq, request) < 0) { | |
| 275 | − av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n"); | |
| 276 | − return; | |
| 277 | − } | |
| 269 | + if (ff_safe_queue_push_back(requestq, request) < 0) { | |
| 270 | + av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n"); | |
| 271 | + return; | |
| 278 | 272 | } |
| 279 | 273 | } |
| 280 | 274 | |
| @@ -347,11 +341,6 @@ static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, co · 66 unmodified lines | ||
| 347 | 341 | goto err; |
| 348 | 342 | } |
| 349 | 343 | |
| 350 | − // create infer_request for sync execution | |
| 351 | − status = ie_exec_network_create_infer_request(ov_model->exe_network, &ov_model->infer_request); | |
| 352 | − if (status != OK) | |
| 353 | − goto err; | |
| 354 | − | |
| 355 | 344 | // create infer_requests for async execution |
| 356 | 345 | if (ctx->options.nireq <= 0) { |
| 357 | 346 | // the default value is a rough estimation |
| @@ -502,10 +491,9 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu · 144 unmodified lines | ||
| 502 | 491 | OVModel *ov_model = model; |
| 503 | 492 | OVContext *ctx = &ov_model->ctx; |
| 504 | 493 | TaskItem task; |
| 505 | − RequestItem request; | |
| 494 | + RequestItem *request; | |
| 506 | 495 | AVFrame *in_frame = NULL; |
| 507 | 496 | AVFrame *out_frame = NULL; |
| 508 | − TaskItem *ptask = &task; | |
| 509 | 497 | IEStatusCode status; |
| 510 | 498 | input_shapes_t input_shapes; |
| 511 | 499 | |
| @@ -557,11 +545,16 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu · 45 unmodified lines | ||
| 557 | 545 | task.out_frame = out_frame; |
| 558 | 546 | task.ov_model = ov_model; |
| 559 | 547 | |
| 560 | − request.infer_request = ov_model->infer_request; | |
| 561 | − request.task_count = 1; | |
| 562 | − request.tasks = &ptask; | |
| 548 | + request = ff_safe_queue_pop_front(ov_model->request_queue); | |
| 549 | + if (!request) { | |
| 550 | + av_frame_free(&out_frame); | |
| 551 | + av_frame_free(&in_frame); | |
| 552 | + av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n"); | |
| 553 | + return DNN_ERROR; | |
| 554 | + } | |
| 555 | + request->tasks[request->task_count++] = &task; | |
| 563 | 556 | |
| 564 | − ret = execute_model_ov(&request); | |
| 557 | + ret = execute_model_ov(request); | |
| 565 | 558 | *output_width = out_frame->width; |
| 566 | 559 | *output_height = out_frame->height; |
| 567 | 560 | |
| @@ -633,8 +626,7 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n · 65 unmodified lines | ||
| 633 | 626 | OVModel *ov_model = model->model; |
| 634 | 627 | OVContext *ctx = &ov_model->ctx; |
| 635 | 628 | TaskItem task; |
| 636 | − RequestItem request; | |
| 637 | − TaskItem *ptask = &task; | |
| 629 | + RequestItem *request; | |
| 638 | 630 | |
| 639 | 631 | if (!in_frame) { |
| 640 | 632 | av_log(ctx, AV_LOG_ERROR, "in frame is NULL when execute model.\n"); |
| @@ -674,11 +666,14 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n · 33 unmodified lines | ||
| 674 | 666 | task.out_frame = out_frame; |
| 675 | 667 | task.ov_model = ov_model; |
| 676 | 668 | |
| 677 | − request.infer_request = ov_model->infer_request; | |
| 678 | − request.task_count = 1; | |
| 679 | − request.tasks = &ptask; | |
| 669 | + request = ff_safe_queue_pop_front(ov_model->request_queue); | |
| 670 | + if (!request) { | |
| 671 | + av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n"); | |
| 672 | + return DNN_ERROR; | |
| 673 | + } | |
| 674 | + request->tasks[request->task_count++] = &task; | |
| 680 | 675 | |
| 681 | − return execute_model_ov(&request); | |
| 676 | + return execute_model_ov(request); | |
| 682 | 677 | } |
| 683 | 678 | |
| 684 | 679 | DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame, |
| @@ -821,8 +816,6 @@ void ff_dnn_free_model_ov(DNNModel **model) · 136 unmodified lines | ||
| 821 | 816 | } |
| 822 | 817 | ff_queue_destroy(ov_model->task_queue); |
| 823 | 818 | |
| 824 | − if (ov_model->infer_request) | |
| 825 | − ie_infer_request_free(&ov_model->infer_request); | |
| 826 | 819 | if (ov_model->exe_network) |
| 827 | 820 | ie_exec_network_free(&ov_model->exe_network); |
| 828 | 821 | if (ov_model->network) |