Dump all input/output names to OVModel struct. In case other funcs use them for reporting errors or locating issues.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -58,6 +58,8 @@ typedef struct OVModel{ · 57 unmodified lines | ||
| 58 | 58 | SafeQueue *request_queue; // holds OVRequestItem |
| 59 | 59 | Queue *task_queue; // holds TaskItem |
| 60 | 60 | Queue *lltask_queue; // holds LastLevelTaskItem |
| 61 | + const char *all_input_names; | |
| 62 | + const char *all_output_names; | |
| 61 | 63 | } OVModel; |
| 62 | 64 | |
| 63 | 65 | // one request for one call to openvino |
| @@ -211,19 +213,9 @@ static void infer_completion_callback(void *args) · 147 unmodified lines | ||
| 211 | 213 | |
| 212 | 214 | status = ie_infer_request_get_blob(request->infer_request, task->output_names[0], &output_blob); |
| 213 | 215 | if (status != OK) { |
| 214 | − //incorrect output name | |
| 215 | − char *model_output_name = NULL; | |
| 216 | − char *all_output_names = NULL; | |
| 217 | − size_t model_output_count = 0; | |
| 218 | − av_log(ctx, AV_LOG_ERROR, "Failed to get model output data\n"); | |
| 219 | − status = ie_network_get_outputs_number(ov_model->network, &model_output_count); | |
| 220 | − for (size_t i = 0; i < model_output_count; i++) { | |
| 221 | − status = ie_network_get_output_name(ov_model->network, i, &model_output_name); | |
| 222 | − APPEND_STRING(all_output_names, model_output_name) | |
| 223 | − } | |
| 224 | 216 | av_log(ctx, AV_LOG_ERROR, |
| 225 | 217 | "output \"%s\" may not correct, all output(s) are: \"%s\"\n", |
| 226 | − task->output_names[0], all_output_names); | |
| 218 | + task->output_names[0], ov_model->all_output_names); | |
| 227 | 219 | return; |
| 228 | 220 | } |
| 229 | 221 | |
| @@ -336,13 +328,23 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * · 106 unmodified lines | ||
| 336 | 328 | // while we pass NHWC data from FFmpeg to openvino |
| 337 | 329 | status = ie_network_set_input_layout(ov_model->network, input_name, NHWC); |
| 338 | 330 | if (status != OK) { |
| 339 | − av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for input %s\n", input_name); | |
| 331 | + if (status == NOT_FOUND) { | |
| 332 | + av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model, failed to set input layout as NHWC, "\ | |
| 333 | + "all input(s) are: \"%s\"\n", input_name, ov_model->all_input_names); | |
| 334 | + } else{ | |
| 335 | + av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for input %s\n", input_name); | |
| 336 | + } | |
| 340 | 337 | ret = DNN_GENERIC_ERROR; |
| 341 | 338 | goto err; |
| 342 | 339 | } |
| 343 | 340 | status = ie_network_set_output_layout(ov_model->network, output_name, NHWC); |
| 344 | 341 | if (status != OK) { |
| 345 | − av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for output %s\n", output_name); | |
| 342 | + if (status == NOT_FOUND) { | |
| 343 | + av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model, failed to set output layout as NHWC, "\ | |
| 344 | + "all output(s) are: \"%s\"\n", input_name, ov_model->all_output_names); | |
| 345 | + } else{ | |
| 346 | + av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for output %s\n", output_name); | |
| 347 | + } | |
| 346 | 348 | ret = DNN_GENERIC_ERROR; |
| 347 | 349 | goto err; |
| 348 | 350 | } |
| @@ -505,7 +507,6 @@ static int get_input_ov(void *model, DNNData *input, const char *input_name) · 156 unmodified lines | ||
| 505 | 507 | OVModel *ov_model = model; |
| 506 | 508 | OVContext *ctx = &ov_model->ctx; |
| 507 | 509 | char *model_input_name = NULL; |
| 508 | − char *all_input_names = NULL; | |
| 509 | 510 | IEStatusCode status; |
| 510 | 511 | size_t model_input_count = 0; |
| 511 | 512 | dimensions_t dims; |
| @@ -538,15 +539,12 @@ static int get_input_ov(void *model, DNNData *input, const char *input_name) · 26 unmodified lines | ||
| 538 | 539 | input->width = input_resizable ? -1 : dims.dims[3]; |
| 539 | 540 | input->dt = precision_to_datatype(precision); |
| 540 | 541 | return 0; |
| 541 | − } else { | |
| 542 | − //incorrect input name | |
| 543 | − APPEND_STRING(all_input_names, model_input_name) | |
| 544 | 542 | } |
| 545 | 543 | |
| 546 | 544 | ie_network_name_free(&model_input_name); |
| 547 | 545 | } |
| 548 | 546 | |
| 549 | − av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model, all input(s) are: \"%s\"\n", input_name, all_input_names); | |
| 547 | + av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model, all input(s) are: \"%s\"\n", input_name, ov_model->all_input_names); | |
| 550 | 548 | return AVERROR(EINVAL); |
| 551 | 549 | } |
| 552 | 550 | |
| @@ -729,6 +727,8 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 176 unmodified lines | ||
| 729 | 727 | OVModel *ov_model = NULL; |
| 730 | 728 | OVContext *ctx = NULL; |
| 731 | 729 | IEStatusCode status; |
| 730 | + size_t node_count = 0; | |
| 731 | + char *node_name = NULL; | |
| 732 | 732 | |
| 733 | 733 | model = av_mallocz(sizeof(DNNModel)); |
| 734 | 734 | if (!model){ |
| @@ -744,6 +744,8 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 9 unmodified lines | ||
| 744 | 744 | ov_model->model = model; |
| 745 | 745 | ov_model->ctx.class = &dnn_openvino_class; |
| 746 | 746 | ctx = &ov_model->ctx; |
| 747 | + ov_model->all_input_names = NULL; | |
| 748 | + ov_model->all_output_names = NULL; | |
| 747 | 749 | |
| 748 | 750 | //parse options |
| 749 | 751 | av_opt_set_defaults(ctx); |
| @@ -767,6 +769,34 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 17 unmodified lines | ||
| 767 | 769 | goto err; |
| 768 | 770 | } |
| 769 | 771 | |
| 772 | + //get all the input and output names | |
| 773 | + status = ie_network_get_inputs_number(ov_model->network, &node_count); | |
| 774 | + if (status != OK) { | |
| 775 | + av_log(ctx, AV_LOG_ERROR, "Failed to get input count\n"); | |
| 776 | + goto err; | |
| 777 | + } | |
| 778 | + for (size_t i = 0; i < node_count; i++) { | |
| 779 | + status = ie_network_get_input_name(ov_model->network, i, &node_name); | |
| 780 | + if (status != OK) { | |
| 781 | + av_log(ctx, AV_LOG_ERROR, "Failed to get No.%d input's name\n", (int)i); | |
| 782 | + goto err; | |
| 783 | + } | |
| 784 | + APPEND_STRING(ov_model->all_input_names, node_name) | |
| 785 | + } | |
| 786 | + status = ie_network_get_outputs_number(ov_model->network, &node_count); | |
| 787 | + if (status != OK) { | |
| 788 | + av_log(ctx, AV_LOG_ERROR, "Failed to get output count\n"); | |
| 789 | + goto err; | |
| 790 | + } | |
| 791 | + for (size_t i = 0; i < node_count; i++) { | |
| 792 | + status = ie_network_get_output_name(ov_model->network, i, &node_name); | |
| 793 | + if (status != OK) { | |
| 794 | + av_log(ctx, AV_LOG_ERROR, "Failed to get No.%d output's name\n", (int)i); | |
| 795 | + goto err; | |
| 796 | + } | |
| 797 | + APPEND_STRING(ov_model->all_output_names, node_name) | |
| 798 | + } | |
| 799 | + | |
| 770 | 800 | model->get_input = &get_input_ov; |
| 771 | 801 | model->get_output = &get_output_ov; |
| 772 | 802 | model->options = options; |