精简项目

删除了不需要的文件,并整理了文件夹
This commit is contained in:
Qiea
2024-11-08 21:35:04 +08:00
parent 46403a5c96
commit 27b41dcd56
251 changed files with 206 additions and 42904 deletions

190
PORTING/CNN/cnn_model.h Normal file
View File

@@ -0,0 +1,190 @@
#ifndef _CNNMODEL_H_
#define _CNNMODEL_H_
#include "exfuns.h"
#include "malloc.h"
#include "ff.h"
#include "debug.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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<?; a++)
--------------------------------*/
//u8 sd_read(u16 length)
//{
// u8 res=0;
// char _tmp[11] = "";
// float floatArray[32] = {0};
// int _larr = 0;
// printf("\r\nRead file data is:\r\n");
// res=f_read(file,fatbuf,length,&br);
// if(res) //<2F><><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD>
// {
// printf("\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD>:%d\r\n",res);
// }else
// {
// for(int i=0;i<length;i++){
// if(fatbuf[i]==0x0d){
// DEBUG_PRINTF("<22>س<EFBFBD>[%d] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[string]: %s\r\n",i,_tmp);
// i++;
// float value = atof(_tmp);
// memset(_tmp, 0, sizeof(_tmp));
// floatArray[_larr++] = value;
// DEBUG_PRINTF("<22>س<EFBFBD>[%d] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[float]: %f\r\n",i,value);
// }else{
// char buffer[2];
// sprintf(buffer, "%c", fatbuf[i]);
// strcat(_tmp, buffer);
// DEBUG_PRINTF("[%d]: %c\r\n",i,fatbuf[i]);
// }
// }
// }
// for (int i=0;i<_larr;i++){
// DEBUG_PRINTF("floatArray[%d]: %f\r\n",i,floatArray[i]);
// }
// return res;
//}
//u8 sd_read(u16 length, char* model)
//{
// float* floatArray = NULL;
// if((floatArray = model_init(model)) == NULL)printf("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
// u8 res=0;
// char _tmp[11] = "";
// u32 _larr = 0;
// length = length*11;
// printf("\r\nRead file data is:\r\n");
// for(int i=0;i<length/512;i++){
// res=f_read(file,fatbuf,512,&br);
// if(res)printf("\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD>:%d\r\n",res);
// else{
// for(int i=0;i<br;i++){
// if(fatbuf[i]==0x0d){
// DEBUG_PRINTF("<22>س<EFBFBD>[%d] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[string]: %s\r\n",i,_tmp);
// i++;
// float value = atof(_tmp);
// memset(_tmp, 0, sizeof(_tmp));
// floatArray[_larr++] = value;
// DEBUG_PRINTF("<22>س<EFBFBD>[%d] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[float]: %f\r\n",i,value);
// }else{
// char buffer[2];
// sprintf(buffer, "%c", fatbuf[i]);
// strcat(_tmp, buffer);
// DEBUG_PRINTF("[%d]: %c\r\n",i,fatbuf[i]);
// }
// }
// }
// }
// if(length%512){
// res=f_read(file,fatbuf,length%512,&br);
// if(res)printf("\r\nRead Error:%d\r\n",res);
// else{
// for(int i=0;i<br;i++){
// if(fatbuf[i]==0x0d){
// DEBUG_PRINTF("<22>س<EFBFBD>[%d] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[string]: %s\r\n",i,_tmp);
// i++;
// float value = atof(_tmp);
// memset(_tmp, 0, sizeof(_tmp));
// floatArray[_larr++] = value;
// DEBUG_PRINTF("<22>س<EFBFBD>[%d] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[float]: %f\r\n",i,value);
// }else{
// char buffer[2];
// sprintf(buffer, "%c", fatbuf[i]);
// strcat(_tmp, buffer);
// DEBUG_PRINTF("[%d]: %c\r\n",i,fatbuf[i]);
// }
// }
// }
// }
// for (int i=0;i<_larr/10;i++){
// printf("floatArray[%d]: %f\r\n",i*10,floatArray[i*10]);
// }
// return res;
//}
#endif