History

lavf/dnn: dump OpenVINO model input/output names to OVMdel struct.

Dump all input/output names to OVModel struct. In case other funcs use them for reporting errors or locating issues.

Ting Fu committed 4 years ago

Commit 23953b91 parent 1cb7fd31 file · +48 −18Browse files

Unified · Split

libavfilter/dnn/dnn_backend_openvino.c+48−18
@@ -58,6 +58,8 @@ typedef struct OVModel{ · 57 unmodified lines
58 SafeQueue *request_queue; // holds OVRequestItem58 SafeQueue *request_queue; // holds OVRequestItem
59 Queue *task_queue; // holds TaskItem59 Queue *task_queue; // holds TaskItem
60 Queue *lltask_queue; // holds LastLevelTaskItem60 Queue *lltask_queue; // holds LastLevelTaskItem
61 const char *all_input_names;
62 const char *all_output_names;
61} OVModel;63} OVModel;
62 64
63// one request for one call to openvino65// one request for one call to openvino
@@ -211,19 +213,9 @@ static void infer_completion_callback(void *args) · 147 unmodified lines
211 213
212 status = ie_infer_request_get_blob(request->infer_request, task->output_names[0], &output_blob);214 status = ie_infer_request_get_blob(request->infer_request, task->output_names[0], &output_blob);
213 if (status != OK) {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 av_log(ctx, AV_LOG_ERROR,216 av_log(ctx, AV_LOG_ERROR,
225 "output \"%s\" may not correct, all output(s) are: \"%s\"\n",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 return;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 // while we pass NHWC data from FFmpeg to openvino328 // while we pass NHWC data from FFmpeg to openvino
337 status = ie_network_set_input_layout(ov_model->network, input_name, NHWC);329 status = ie_network_set_input_layout(ov_model->network, input_name, NHWC);
338 if (status != OK) {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 ret = DNN_GENERIC_ERROR;337 ret = DNN_GENERIC_ERROR;
341 goto err;338 goto err;
342 }339 }
343 status = ie_network_set_output_layout(ov_model->network, output_name, NHWC);340 status = ie_network_set_output_layout(ov_model->network, output_name, NHWC);
344 if (status != OK) {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 ret = DNN_GENERIC_ERROR;348 ret = DNN_GENERIC_ERROR;
347 goto err;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 OVModel *ov_model = model;507 OVModel *ov_model = model;
506 OVContext *ctx = &ov_model->ctx;508 OVContext *ctx = &ov_model->ctx;
507 char *model_input_name = NULL;509 char *model_input_name = NULL;
508 char *all_input_names = NULL;
509 IEStatusCode status;510 IEStatusCode status;
510 size_t model_input_count = 0;511 size_t model_input_count = 0;
511 dimensions_t dims;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 input->width = input_resizable ? -1 : dims.dims[3];539 input->width = input_resizable ? -1 : dims.dims[3];
539 input->dt = precision_to_datatype(precision);540 input->dt = precision_to_datatype(precision);
540 return 0;541 return 0;
541 } else {
542 //incorrect input name
543 APPEND_STRING(all_input_names, model_input_name)
544 }542 }
545 543
546 ie_network_name_free(&model_input_name);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 return AVERROR(EINVAL);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 OVModel *ov_model = NULL;727 OVModel *ov_model = NULL;
730 OVContext *ctx = NULL;728 OVContext *ctx = NULL;
731 IEStatusCode status;729 IEStatusCode status;
730 size_t node_count = 0;
731 char *node_name = NULL;
732 732
733 model = av_mallocz(sizeof(DNNModel));733 model = av_mallocz(sizeof(DNNModel));
734 if (!model){734 if (!model){
@@ -744,6 +744,8 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 9 unmodified lines
744 ov_model->model = model;744 ov_model->model = model;
745 ov_model->ctx.class = &dnn_openvino_class;745 ov_model->ctx.class = &dnn_openvino_class;
746 ctx = &ov_model->ctx;746 ctx = &ov_model->ctx;
747 ov_model->all_input_names = NULL;
748 ov_model->all_output_names = NULL;
747 749
748 //parse options750 //parse options
749 av_opt_set_defaults(ctx);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 goto err;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 model->get_input = &get_input_ov;800 model->get_input = &get_input_ov;
771 model->get_output = &get_output_ov;801 model->get_output = &get_output_ov;
772 model->options = options;802 model->options = options;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t