-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcnn.h
98 lines (73 loc) · 3.11 KB
/
cnn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**************************************************************************************************
* Copyright (C) Maxim Integrated Products, Inc. All Rights Reserved.
*
* Maxim Integrated Products, Inc. Default Copyright Notice:
* https://www.maximintegrated.com/en/aboutus/legal/copyrights.html
**************************************************************************************************/
/*
* This header file was automatically generated for the ai85-mnist network from a template.
* Please do not edit; instead, edit the template and regenerate.
*/
#ifndef __CNN_H__
#define __CNN_H__
#include <stdint.h>
typedef int32_t q31_t;
typedef int16_t q15_t;
/* Return codes */
#define CNN_FAIL 0
#define CNN_OK 1
/*
SUMMARY OF OPS
Hardware: 10,883,968 ops (10,751,808 macc; 128,576 comp; 3,584 add; 0 mul; 0 bitwise)
Layer 0: 470,400 ops (423,360 macc; 47,040 comp; 0 add; 0 mul; 0 bitwise)
Layer 1: 8,356,800 ops (8,294,400 macc; 62,400 comp; 0 add; 0 mul; 0 bitwise)
Layer 2: 1,954,304 ops (1,935,360 macc; 18,944 comp; 0 add; 0 mul; 0 bitwise)
Layer 3: 100,544 ops (96,768 macc; 192 comp; 3,584 add; 0 mul; 0 bitwise)
Layer 4: 1,920 ops (1,920 macc; 0 comp; 0 add; 0 mul; 0 bitwise)
RESOURCE USAGE
Weight memory: 70,188 bytes out of 442,368 bytes total (16%)
Bias memory: 10 bytes out of 2,048 bytes total (0%)
*/
/* Number of outputs for this network */
#define CNN_NUM_OUTPUTS 10
/* Port pin actions used to signal that processing is active */
#define CNN_START LED_On(1)
#define CNN_COMPLETE LED_Off(1)
#define SYS_START LED_On(0)
#define SYS_COMPLETE LED_Off(0)
/* Run software SoftMax on unloaded data */
void softmax_q17p14_q15(const q31_t * vec_in, const uint16_t dim_vec, q15_t * p_out);
/* Shift the input, then calculate SoftMax */
void softmax_shift_q17p14_q15(q31_t * vec_in, const uint16_t dim_vec, uint8_t in_shift, q15_t * p_out);
/* Stopwatch - holds the runtime when accelerator finishes */
extern volatile uint32_t cnn_time;
/* Custom memcopy routines used for weights and data */
void memcpy32(uint32_t *dst, const uint32_t *src, int n);
void memcpy32_const(uint32_t *dst, int n);
/* Enable clocks and power to accelerator, enable interrupt */
int cnn_enable(uint32_t clock_source, uint32_t clock_divider);
/* Disable clocks and power to accelerator */
int cnn_disable(void);
/* Perform minimum accelerator initialization so it can be configured */
int cnn_init(void);
/* Configure accelerator for the given network */
int cnn_configure(void);
/* Load accelerator weights */
int cnn_load_weights(void);
/* Verify accelerator weights (debug only) */
int cnn_verify_weights(void);
/* Load accelerator bias values (if needed) */
int cnn_load_bias(void);
/* Start accelerator processing */
int cnn_start(void);
/* Force stop accelerator */
int cnn_stop(void);
/* Continue accelerator after stop */
int cnn_continue(void);
/* Unload results from accelerator */
int cnn_unload(uint32_t *out_buf);
/* Turn on the boost circuit */
int cnn_boost_enable(mxc_gpio_regs_t *port, uint32_t pin);
/* Turn off the boost circuit */
int cnn_boost_disable(mxc_gpio_regs_t *port, uint32_t pin);
#endif // __CNN_H__