blob: fbd36b3e542ff37bf8b0350ccf992f81d38d5d85 [file] [log] [blame]
Lun Dong9ee45102021-08-30 10:02:50 -07001#-------------------------------------------------------------------------------
Cindy Liufd819bf2021-09-01 23:40:21 -07002# Build the mlir bytecode modules with iree-translate. Note the last three flags
3# are for RVV support.
Lun Dong9ee45102021-08-30 10:02:50 -07004#-------------------------------------------------------------------------------
5
Cindy Liufd819bf2021-09-01 23:40:21 -07006springbok_bytecode_module(
7 NAME
8 mobilenet_v1_bytecode_module_dylib
9 SRC
10 "$ENV{ROOTDIR}/ml/ml-models-public/float_models/mobilenet_v1_0.25_224_float.tflite"
11 C_IDENTIFIER
12 "samples_float_model_embedding_mobilenet_v1_bytecode_module_dylib"
13 FLAGS
14 "-iree-input-type=tosa"
15 "-riscv-v-vector-bits-min=512"
16 "-riscv-v-fixed-length-vector-lmul-max=8"
17 "-riscv-v-fixed-length-vector-elen-max=32"
18 PUBLIC
19)
20
Lun Dongb7990a22021-09-17 21:46:30 +000021springbok_bytecode_module(
22 NAME
23 mnist_bytecode_module_dylib
24 SRC
25 "$ENV{ROOTDIR}/toolchain/iree/iree/samples/models/mnist.mlir"
26 C_IDENTIFIER
27 "samples_float_model_embedding_mnist_bytecode_module_dylib"
28 FLAGS
29 "-iree-input-type=mhlo"
30 "-riscv-v-vector-bits-min=512"
31 "-riscv-v-fixed-length-vector-lmul-max=8"
32 "-riscv-v-fixed-length-vector-elen-max=32"
33 PUBLIC
34)
35
Cindy Liufd819bf2021-09-01 23:40:21 -070036if(${BUILD_INTERNAL_MODELS})
Cindy Liu398be4b2021-09-01 14:20:07 -070037
Lun Dong9ee45102021-08-30 10:02:50 -070038if(NOT ${BUILD_WITH_SPRINGBOK})
39 springbok_bytecode_module(
40 NAME
Lun Dong9ee45102021-08-30 10:02:50 -070041 scenenet_v2_bytecode_module_dylib
42 SRC
43 "$ENV{ROOTDIR}/ml/ml-models/float_models/scenenet_v2_float.tflite"
44 C_IDENTIFIER
45 "samples_float_model_embedding_scenenet_v2_bytecode_module_dylib"
46 FLAGS
47 "-iree-input-type=tosa"
48 "-riscv-v-vector-bits-min=512"
49 "-riscv-v-fixed-length-vector-lmul-max=8"
50 "-riscv-v-fixed-length-vector-elen-max=32"
51 PUBLIC
52 )
Lun Dong9ee45102021-08-30 10:02:50 -070053
Cindy Liue3240e22021-10-07 17:24:21 -070054 springbok_bytecode_module(
55 NAME
56 barcode_bytecode_module_dylib
57 SRC
58 "$ENV{ROOTDIR}/ml/ml-models/float_models/barcode_float.tflite"
59 C_IDENTIFIER
60 "samples_float_model_embedding_barcode_bytecode_module_dylib"
61 FLAGS
62 "-iree-input-type=tosa"
63 "-riscv-v-vector-bits-min=512"
64 "-riscv-v-fixed-length-vector-lmul-max=8"
65 "-riscv-v-fixed-length-vector-elen-max=32"
66 PUBLIC
67 )
68endif()
Lun Dong9ee45102021-08-30 10:02:50 -070069
70springbok_bytecode_module(
71 NAME
72 daredevil_bytecode_module_dylib
73 SRC
74 "$ENV{ROOTDIR}/ml/ml-models/float_models/daredevil_float.tflite"
75 C_IDENTIFIER
76 "samples_float_model_embedding_daredevil_bytecode_module_dylib"
77 FLAGS
78 "-iree-input-type=tosa"
79 "-riscv-v-vector-bits-min=512"
80 "-riscv-v-fixed-length-vector-lmul-max=8"
81 "-riscv-v-fixed-length-vector-elen-max=32"
82 PUBLIC
83)
84
85springbok_bytecode_module(
86 NAME
87 fssd_25_8bit_v2_bytecode_module_dylib
88 SRC
89 "$ENV{ROOTDIR}/ml/ml-models/float_models/fssd_25_8bit_v2_float.tflite"
90 C_IDENTIFIER
91 "samples_float_model_embedding_fssd_25_8bit_v2_bytecode_module_dylib"
92 FLAGS
93 "-iree-input-type=tosa"
94 "-riscv-v-vector-bits-min=512"
95 "-riscv-v-fixed-length-vector-lmul-max=8"
96 "-riscv-v-fixed-length-vector-elen-max=32"
97 PUBLIC
98)
99
100springbok_bytecode_module(
101 NAME
Lun Dong9ee45102021-08-30 10:02:50 -0700102 person_detection_bytecode_module_dylib
103 SRC
104 "$ENV{ROOTDIR}/ml/ml-models/float_models/person_detection_float.tflite"
105 C_IDENTIFIER
106 "samples_float_model_embedding_person_detection_bytecode_module_dylib"
107 FLAGS
108 "-iree-input-type=tosa"
109 "-riscv-v-vector-bits-min=512"
110 "-riscv-v-fixed-length-vector-lmul-max=8"
111 "-riscv-v-fixed-length-vector-elen-max=32"
112 PUBLIC
113)
114
115springbok_bytecode_module(
116 NAME
117 semantic_lift_bytecode_module_dylib
118 SRC
119 "$ENV{ROOTDIR}/ml/ml-models/float_models/semantic_lift_float.tflite"
120 C_IDENTIFIER
121 "samples_float_model_embedding_semantic_lift_bytecode_module_dylib"
122 FLAGS
123 "-iree-input-type=tosa"
124 "-riscv-v-vector-bits-min=512"
125 "-riscv-v-fixed-length-vector-lmul-max=8"
126 "-riscv-v-fixed-length-vector-elen-max=32"
127 PUBLIC
128)
129
130springbok_bytecode_module(
131 NAME
132 voice_commands_bytecode_module_dylib
133 SRC
134 "$ENV{ROOTDIR}/ml/ml-models/float_models/voice_commands_float.tflite"
135 C_IDENTIFIER
136 "samples_float_model_embedding_voice_commands_bytecode_module_dylib"
137 FLAGS
138 "-iree-input-type=tosa"
139 "-riscv-v-vector-bits-min=512"
140 "-riscv-v-fixed-length-vector-lmul-max=8"
141 "-riscv-v-fixed-length-vector-elen-max=32"
142 PUBLIC
143)
144
Cindy Liufd819bf2021-09-01 23:40:21 -0700145endif(${BUILD_INTERNAL_MODELS})
146
Lun Dong9ee45102021-08-30 10:02:50 -0700147#-------------------------------------------------------------------------------
Lun Dongdb85fd72021-11-02 02:39:48 -0700148# Binaries to execute the IREE model input
149#-------------------------------------------------------------------------------
150
151iree_model_input(
152 NAME
153 mobilenet_input
154 SHAPE
155 "1, 224, 224, 3"
156 SRC
157 "https://storage.googleapis.com/download.tensorflow.org/ \
158 example_images/YellowLabradorLooking_new.jpg"
159)
160
161if(${BUILD_INTERNAL_MODELS})
162
163iree_model_input(
164 NAME
165 person_detection_input
166 SHAPE
167 "1, 96, 96, 1"
168 SRC
169 "https://github.com/tensorflow/tflite-micro/raw/aeac6f39e5c7475cea20c54e86d41e3a38312546/ \
170 tensorflow/lite/micro/examples/person_detection/testdata/person.bmp"
171)
172
173endif(${BUILD_INTERNAL_MODELS})
174
175#-------------------------------------------------------------------------------
Lun Dong9ee45102021-08-30 10:02:50 -0700176# Binaries to execute the MLIR bytecode modules
177#-------------------------------------------------------------------------------
178
179
180# If the program requires a larger stack size, add
181#
182# LINKOPTS
183# "LINKER:--defsym=__stack_size__=<new stack size>"
184#
185# to increase it.
186
Lun Donga5635112021-09-01 11:33:30 -0700187# Currently only the person_detection model can run with springbok (b/196910893)
188
Cindy Liufd819bf2021-09-01 23:40:21 -0700189iree_cc_binary(
190 NAME
191 mobilenet_v1_embedded_sync
192 SRCS
193 "mobilenet_v1.c"
194 DEPS
195 ::mobilenet_v1_bytecode_module_dylib_c
Lun Dongdb85fd72021-11-02 02:39:48 -0700196 ::mobilenet_input_c
Cindy Liufd819bf2021-09-01 23:40:21 -0700197 samples::util::util
198 LINKOPTS
199 "LINKER:--defsym=__stack_size__=100k"
200)
Lun Dong9ee45102021-08-30 10:02:50 -0700201
Lun Dongb7990a22021-09-17 21:46:30 +0000202iree_cc_binary(
203 NAME
204 mnist_embedded_sync
205 SRCS
206 "mnist.c"
207 DEPS
208 ::mnist_bytecode_module_dylib_c
209 samples::util::util
210 LINKOPTS
211 "LINKER:--defsym=__stack_size__=100k"
212)
213
Cindy Liufd819bf2021-09-01 23:40:21 -0700214if(NOT ${BUILD_INTERNAL_MODELS})
215 return()
216endif()
217
218if(NOT ${BUILD_WITH_SPRINGBOK})
Lun Dong9ee45102021-08-30 10:02:50 -0700219 iree_cc_binary(
220 NAME
221 scenenet_v2_embedded_sync
222 SRCS
223 "scenenet_v2.c"
224 DEPS
225 ::scenenet_v2_bytecode_module_dylib_c
226 samples::util::util
227 )
Lun Dong9ee45102021-08-30 10:02:50 -0700228
Cindy Liue3240e22021-10-07 17:24:21 -0700229 iree_cc_binary(
230 NAME
231 barcode_embedded_sync
232 SRCS
233 "barcode.c"
234 DEPS
235 ::barcode_bytecode_module_dylib_c
236 samples::util::util
237 LINKOPTS
238 "LINKER:--defsym=__stack_size__=100k"
239 )
240endif()
Lun Dong9ee45102021-08-30 10:02:50 -0700241
242iree_cc_binary(
243 NAME
244 daredevil_embedded_sync
245 SRCS
246 "daredevil.c"
247 DEPS
248 ::daredevil_bytecode_module_dylib_c
249 samples::util::util
250 LINKOPTS
251 "LINKER:--defsym=__stack_size__=100k"
252)
253
254iree_cc_binary(
255 NAME
256 fssd_25_8bit_v2_embedded_sync
257 SRCS
258 "fssd_25_8bit_v2.c"
259 DEPS
260 ::fssd_25_8bit_v2_bytecode_module_dylib_c
261 samples::util::util
262 LINKOPTS
263 "LINKER:--defsym=__stack_size__=100k"
264)
265
266iree_cc_binary(
267 NAME
Lun Dong9ee45102021-08-30 10:02:50 -0700268 person_detection_embedded_sync
269 SRCS
270 "person_detection.c"
271 DEPS
272 ::person_detection_bytecode_module_dylib_c
Lun Dongdb85fd72021-11-02 02:39:48 -0700273 ::person_detection_input_c
Lun Dong9ee45102021-08-30 10:02:50 -0700274 samples::util::util
275 LINKOPTS
276 "LINKER:--defsym=__stack_size__=100k"
277)
278
279iree_cc_binary(
280 NAME
281 semantic_lift_embedded_sync
282 SRCS
283 "semantic_lift.c"
284 DEPS
285 ::semantic_lift_bytecode_module_dylib_c
286 samples::util::util
Lun Dongb7990a22021-09-17 21:46:30 +0000287 LINKOPTS
288 "LINKER:--defsym=__stack_size__=100k"
Lun Dong9ee45102021-08-30 10:02:50 -0700289)
290
291iree_cc_binary(
292 NAME
293 voice_commands_embedded_sync
294 SRCS
295 "voice_commands.c"
296 DEPS
297 ::voice_commands_bytecode_module_dylib_c
298 samples::util::util
Lun Dongb7990a22021-09-17 21:46:30 +0000299 LINKOPTS
300 "LINKER:--defsym=__stack_size__=100k"
Lun Dong9ee45102021-08-30 10:02:50 -0700301)