#ifndef _CNNMODEL_H_ #define _CNNMODEL_H_ #include "exfuns.h" #include "malloc.h" #include "ff.h" #include "debug.h" #include #include #include typedef struct { char* name; char* dname; float* array; u32 maxlength; u32 realength; } Model; #define READLENGTH 11*10 #define CONV1_BIAS_ARRSIZE 32 #define CONV1_WEIGHT_ARRSIZE 32*1*3*3 //288 #define CONV2_BIAS_ARRSIZE 64 #define CONV2_WEIGHT_ARRSIZE 64*32*3*3 //18432 #define CONV3_BIAS_ARRSIZE 128 #define CONV3_WEIGHT_ARRSIZE 128*64*3*3 //73728 #define FC1_BIAS_ARRSIZE 128 #define FC1_WEIGHT_ARRSIZE 128*18432 //2359296 #define FC2_BIAS_ARRSIZE 7 #define FC2_WEIGHT_ARRSIZE 7*128 //896 #define DATA_ARRSIZE 1250000 //1250000 extern Model conv1_bias; extern Model conv1_weight; extern Model conv2_bias; extern Model conv2_weight; extern Model conv3_bias; extern Model conv3_weight; extern Model fc1_bias; extern Model fc1_weight; extern Model fc2_bias; extern Model fc2_weight; extern Model data; float* modelmym_init(char* model_name); u8 modelmym_free(char* model_name); u8 model_write(char* model_name); u8 model_read(char* model_name, u32 start, u32 end, u32 gap); u8 model_switchdata(char* model_name); void model_dataset(void); u8 model_info(char* model_name); void* model(char* model_name); void model_init(void); u8 sd_read(u32 length, char* model_name,u32 gap); //conv1_bias[a*1] a:0~31 //conv1_weight[a*9+b*9+c*3+d*1] a:0~31 b:0 c:0~2 d:0~2 //conv2_bias[a*1] a:0~63 //conv2_weight[a*288+b*9+c*3+d*1] a:0~63 b:0~31 c:0~2 d:0~2 //conv3_bias[a*1] a:0~127 //conv3_weight[a*576+b*9+c*3+d*1] a:0~127 b:0~63 c:0~2 d:0~2 //fc1_bias[a*1] a:0~127 //fc1_weight[a*18432+b*1] a:0~127 b:0~18431 //fc2_bias[a*1] a:0~6 //fc2_weight[a*128+b*1] a:0~6 b:0~127 /*-------------------------------- for(u8 a; a