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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/dnn/dnn_backend_openvino.c+48−18
@@ -58,6 +58,8 @@ typedef struct OVModel{ · 57 unmodified lines
5858 SafeQueue *request_queue; // holds OVRequestItem
5959 Queue *task_queue; // holds TaskItem
6060 Queue *lltask_queue; // holds LastLevelTaskItem
61+ const char *all_input_names;
62+ const char *all_output_names;
6163 } OVModel;
6264
6365 // one request for one call to openvino
@@ -211,19 +213,9 @@ static void infer_completion_callback(void *args) · 147 unmodified lines
211213
212214 status = ie_infer_request_get_blob(request->infer_request, task->output_names[0], &output_blob);
213215 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− }
224216 av_log(ctx, AV_LOG_ERROR,
225217 "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);
227219 return;
228220 }
229221
@@ -336,13 +328,23 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * · 106 unmodified lines
336328 // while we pass NHWC data from FFmpeg to openvino
337329 status = ie_network_set_input_layout(ov_model->network, input_name, NHWC);
338330 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+ }
340337 ret = DNN_GENERIC_ERROR;
341338 goto err;
342339 }
343340 status = ie_network_set_output_layout(ov_model->network, output_name, NHWC);
344341 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+ }
346348 ret = DNN_GENERIC_ERROR;
347349 goto err;
348350 }
@@ -505,7 +507,6 @@ static int get_input_ov(void *model, DNNData *input, const char *input_name) · 156 unmodified lines
505507 OVModel *ov_model = model;
506508 OVContext *ctx = &ov_model->ctx;
507509 char *model_input_name = NULL;
508− char *all_input_names = NULL;
509510 IEStatusCode status;
510511 size_t model_input_count = 0;
511512 dimensions_t dims;
@@ -538,15 +539,12 @@ static int get_input_ov(void *model, DNNData *input, const char *input_name) · 26 unmodified lines
538539 input->width = input_resizable ? -1 : dims.dims[3];
539540 input->dt = precision_to_datatype(precision);
540541 return 0;
541− } else {
542− //incorrect input name
543− APPEND_STRING(all_input_names, model_input_name)
544542 }
545543
546544 ie_network_name_free(&model_input_name);
547545 }
548546
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);
550548 return AVERROR(EINVAL);
551549 }
552550
@@ -729,6 +727,8 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 176 unmodified lines
729727 OVModel *ov_model = NULL;
730728 OVContext *ctx = NULL;
731729 IEStatusCode status;
730+ size_t node_count = 0;
731+ char *node_name = NULL;
732732
733733 model = av_mallocz(sizeof(DNNModel));
734734 if (!model){
@@ -744,6 +744,8 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 9 unmodified lines
744744 ov_model->model = model;
745745 ov_model->ctx.class = &dnn_openvino_class;
746746 ctx = &ov_model->ctx;
747+ ov_model->all_input_names = NULL;
748+ ov_model->all_output_names = NULL;
747749
748750 //parse options
749751 av_opt_set_defaults(ctx);
@@ -767,6 +769,34 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_ · 17 unmodified lines
767769 goto err;
768770 }
769771
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+
770800 model->get_input = &get_input_ov;
771801 model->get_output = &get_output_ov;
772802 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