Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -33,30 +33,37 @@ · 32 unmodified lines | ||
| 33 | 33 | static DNNReturnType set_input_output_native(void *model, DNNInputData *input, const char *input_name, const char **output_names, uint32_t nb_output) |
| 34 | 34 | { |
| 35 | 35 | ConvolutionalNetwork *network = (ConvolutionalNetwork *)model; |
| 36 | + DnnOperand *oprd = NULL; | |
| 36 | 37 | |
| 37 | 38 | if (network->layers_num <= 0 || network->operands_num <= 0) |
| 38 | 39 | return DNN_ERROR; |
| 39 | 40 | |
| 40 | 41 | av_assert0(input->dt == DNN_FLOAT); |
| 42 | + for (int i = 0; i < network->operands_num; ++i) { | |
| 43 | + oprd = &network->operands[i]; | |
| 44 | + if (strcmp(oprd->name, input_name) == 0) { | |
| 45 | + if (oprd->type != DOT_INPUT) | |
| 46 | + return DNN_ERROR; | |
| 47 | + break; | |
| 48 | + } | |
| 49 | + oprd = NULL; | |
| 50 | + } | |
| 41 | 51 | |
| 42 | − /** | |
| 43 | − * as the first step, suppose network->operands[0] is the input operand. | |
| 44 | − */ | |
| 45 | − network->operands[0].dims[0] = 1; | |
| 46 | − network->operands[0].dims[1] = input->height; | |
| 47 | − network->operands[0].dims[2] = input->width; | |
| 48 | − network->operands[0].dims[3] = input->channels; | |
| 49 | − network->operands[0].type = DOT_INPUT; | |
| 50 | − network->operands[0].data_type = DNN_FLOAT; | |
| 51 | − network->operands[0].isNHWC = 1; | |
| 52 | − | |
| 53 | − av_freep(&network->operands[0].data); | |
| 54 | − network->operands[0].length = calculate_operand_data_length(&network->operands[0]); | |
| 55 | − network->operands[0].data = av_malloc(network->operands[0].length); | |
| 56 | − if (!network->operands[0].data) | |
| 52 | + if (!oprd) | |
| 53 | + return DNN_ERROR; | |
| 54 | + | |
| 55 | + oprd->dims[0] = 1; | |
| 56 | + oprd->dims[1] = input->height; | |
| 57 | + oprd->dims[2] = input->width; | |
| 58 | + oprd->dims[3] = input->channels; | |
| 59 | + | |
| 60 | + av_freep(&oprd->data); | |
| 61 | + oprd->length = calculate_operand_data_length(oprd); | |
| 62 | + oprd->data = av_malloc(oprd->length); | |
| 63 | + if (!oprd->data) | |
| 57 | 64 | return DNN_ERROR; |
| 58 | 65 | |
| 59 | − input->data = network->operands[0].data; | |
| 66 | + input->data = oprd->data; | |
| 60 | 67 | return DNN_SUCCESS; |
| 61 | 68 | } |
| 62 | 69 | |