-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (115 loc) · 3.63 KB
/
Copy pathMakefile
File metadata and controls
145 lines (115 loc) · 3.63 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright (C) 2017 GreenWaves Technologies
# All rights reserved.
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
ifndef GAP_SDK_HOME
$(error Source sourceme in gap_sdk first)
endif
MODEL_PREFIX=face_detection
ifndef QUANTIZATION_BITS
QUANTIZATION_BITS=16
endif
$(info Building GAP8 mode with $(QUANTIZATION_BITS) bit quantization)
## Mute printf in source code
#SILENT=1
## Enable image grub from camera and disaply output to lcd
#FROM_CAMERA=1
# The training of the model is slightly different depending on
# the quantization. This is because in 8 bit mode we used signed
# 8 bit so the input to the model needs to be shifted 1 bit
ifeq ($(QUANTIZATION_BITS),8)
MODEL_SQ8=1
GAP_FLAGS += -DQUANTIZATION_8BIT
NNTOOL_SCRIPT=model/nntool_script8
MODEL_SUFFIX = _8BIT
else
ifeq ($(QUANTIZATION_BITS),16)
MODEL_POW2=1
GAP_FLAGS += -DQUANTIZATION_16BIT
NNTOOL_SCRIPT=model/nntool_script16
MODEL_SUFFIX = _16BIT
else
$(error Don't know how to build with this bit width)
endif
endif
include model_decl.mk
# Here we set the memory allocation for the generated kernels
# REMEMBER THAT THE L1 MEMORY ALLOCATION MUST INCLUDE SPACE
# FOR ALLOCATED STACKS!
# FC stack size:
MAIN_STACK_SIZE=2048
# Cluster PE0 stack size:
CLUSTER_STACK_SIZE=4096
# Cluster PE1-PE7 stack size:
CLUSTER_SLAVE_STACK_SIZE=1024
TOTAL_STACK_SIZE=$(shell expr $(CLUSTER_STACK_SIZE) \+ $(CLUSTER_SLAVE_STACK_SIZE) \* 8)
ifeq '$(TARGET_CHIP_FAMILY)' 'GAP9'
FREQ_CL?=50
FREQ_FC?=50
MODEL_L1_MEMORY=$(shell expr 125000 \- $(TOTAL_STACK_SIZE))
MODEL_L2_MEMORY=1300000
MODEL_L3_MEMORY=8388608
else
ifeq '$(TARGET_CHIP)' 'GAP8_V3'
FREQ_CL?=175
else
FREQ_CL?=50
endif
FREQ_FC?=250
MODEL_L1_MEMORY=$(shell expr 60000 \- $(TOTAL_STACK_SIZE))
MODEL_L2_MEMORY=150000
MODEL_L3_MEMORY=8388608
endif
# hram - HyperBus RAM
# qspiram - Quad SPI RAM
MODEL_L3_EXEC=hram
# hflash - HyperBus Flash
# qpsiflash - Quad SPI Flash
MODEL_L3_CONST=hflash
APP=face_detection
APP_SRCS += main.c ImgIO.c ImageDraw.c SSDKernels.c SSDBasicKernels.c SSDParams.c $(MODEL_SRCS) $(CNN_LIB)
APP_CFLAGS += -w -O2 -s -mno-memcpy -fno-tree-loop-distribute-patterns
APP_CFLAGS += -I. -I./helpers $(CNN_LIB_INCLUDE) -I$(TILER_EMU_INC) -I$(TILER_INC) -I$(GEN_PATH) -I$(MODEL_BUILD)
APP_CFLAGS += -DCLUSTER_STACK_SIZE=$(CLUSTER_STACK_SIZE) -DCLUSTER_SLAVE_STACK_SIZE=$(CLUSTER_SLAVE_STACK_SIZE)
ifeq ($(SILENT),1)
APP_CFLAGS += -DSILENT=1
endif
ifeq ($(FROM_CAMERA),1)
APP_CFLAGS += -DFROM_CAMERA=1
endif
ifeq ($(platform),gvsoc)
$(info Platform is GVSOC)
READFS_FILES=$(MODEL_TENSORS)
else
PLPBRIDGE_FLAGS = -f
READFS_FILES=$(MODEL_TENSORS)
endif
io=host
#####Here we add cutom kernels that are not yet integrated into AT libraries
SSD_MODEL_GEN = SSDKernels
SSD_MODEL_GEN_C = $(addsuffix .c, $(SSD_MODEL_GEN))
SSD_MODEL_GEN_CLEAN = $(SSD_MODEL_GEN_C) $(addsuffix .h, $(SSD_MODEL_GEN))
GenSSDTile: SSDModel.c
gcc -g -o GenSSDTile -I$(TILER_EMU_INC) -I"$(TILER_INC)" SSDModel.c $(TILER_LIB) #-lSDL2 -lSDL2_ttf -DAT_DISPLAY
$(SSD_MODEL_GEN_C): GenSSDTile
./GenSSDTile
SSDParams.c: $(SSD_MODEL_GEN_C)
cd SSDParamsGenerator && $(MAKE) all run
SSD_model: SSDParams.c
#################
# build depends on the model
build:: SSD_model model
clean_at_model:
rm -rf BUILD
rm -rf GenTile
clean:: #clean_model
rm -rf BUILD
rm -rf GenTile
rm -rf $(MODEL_BUILD)/face_detectionKernels.*
cd SSDParamsGenerator && $(MAKE) clean
rm -rf SSDParams.c SSDParams.h
rm -rf GenSSDTile $(SSD_MODEL_GEN_CLEAN)
clean_all: clean clean_model #clean_train
.PHONY: clean_all
include model_rules.mk
include $(RULES_DIR)/pmsis_rules.mk