37 if (strcmp(oprd->
name, input_name) == 0) {
64 if (strcmp(oprd->
name, input_name) == 0) {
95 for (uint32_t
i = 0;
i < nb_output; ++
i) {
96 const char *output_name = output_names[
i];
99 if (strcmp(oprd->
name, output_name) == 0) {
119 char header_expected[] =
"FFMPEGDNNNATIVE";
122 int version, header_size, major_version_expected = 1;
125 int file_size, dnn_size, parsed_size;
138 file_size =
avio_size(model_file_context);
143 size =
sizeof(header_expected);
154 if (strncmp(buf, header_expected, size) != 0) {
164 if (version != major_version_expected) {
173 header_size = dnn_size;
181 model->
model = (
void *)network;
183 avio_seek(model_file_context, file_size - 8, SEEK_SET);
187 avio_seek(model_file_context, header_size, SEEK_SET);
203 for (layer = 0; layer < network->
layers_num; ++layer){
220 dnn_size += parsed_size;
229 oprd = &network->
operands[operand_index];
234 dnn_size += name_len;
252 if (dnn_size != file_size){
274 for (layer = 0; layer < network->
layers_num; ++layer){
282 for (uint32_t
i = 0;
i < nb; ++
i) {
297 for (
int i = 0;
i < 4; ++
i)
298 result *= oprd->
dims[
i];
306 return oprd->
dims[0] * oprd->
dims[1] * oprd->
dims[2] * oprd->
dims[3] *
sizeof(float);
328 for (uint32_t operand = 0; operand < network->
operands_num; ++operand)
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int8_t isNHWC
NHWC if 1, otherwise NCHW.
int64_t avio_size(AVIOContext *s)
Get the filesize.
DNN inference functions interface for native backend.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
int32_t calculate_operand_dims_count(const DnnOperand *oprd)
DNNOperandType type
input/output/intermediate operand of the network
int32_t input_operand_indexes[4]
a layer can have multiple inputs and one output.
LayerFunc layer_funcs[DLT_COUNT]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
DNNDataType data_type
support different kinds of data type such as float, half float, int8 etc, first support float now...
DNNReturnType(* get_input)(void *model, DNNData *input, const char *input_name)
#define i(width, name, range_min, range_max)
unsigned int avio_rl32(AVIOContext *s)
void * data
data pointer with data length in bytes.
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int32_t dims[4]
there are two memory layouts, NHWC or NCHW, so we use dims, dims[0] is Number.
char name[128]
to avoid possible memory leak, do not use char *name
static DNNReturnType set_input_output_native(void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output)
DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData *outputs, uint32_t nb_output)
void ff_dnn_free_model_native(DNNModel **model)
static const AVFilterPad outputs[]
static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
DNNLayerType
the enum value of DNNLayerType should not be changed, the same values are used in convert_from_tensor...
int32_t calculate_operand_data_length(const DnnOperand *oprd)
DNNModel * ff_dnn_load_model_native(const char *model_filename)
DNNReturnType(* set_input_output)(void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
int32_t output_operand_index
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().