#ifndef CNNMODEL_H_
#define CNNMODEL_H_
#include "malloc.h"
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>



typedef struct {
	char* 	name;
	char* 	dname;
	float* 	array;
	uint32_t 	maxlength;
	uint32_t		realength;

    uint8_t      channel;
    uint8_t      num_kernels;

} 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 (4)
#define FC2_WEIGHT_ARRSIZE (4*128)			//896

#define DATA_ARRSIZE (1300000)



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);
uint8_t modelmym_free(char* model_name);
uint8_t model_write(char* model_name);
uint8_t model_read(char* model_name, uint32_t start, uint32_t end, uint32_t gap);
uint8_t model_switchdata(char* model_name);
uint8_t model_info(char* model_name);
void* model(char* model_name);
void model_init(void);



//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
#endif
