Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Cindy Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 2 | # Build the mlir bytecode modules with iree-translate. Note the last three flags |
| 3 | # are for RVV support. |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 4 | #------------------------------------------------------------------------------- |
| 5 | |
Cindy Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 6 | springbok_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 Dong | b7990a2 | 2021-09-17 21:46:30 +0000 | [diff] [blame] | 21 | springbok_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 Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 36 | if(${BUILD_INTERNAL_MODELS}) |
Cindy Liu | 398be4b | 2021-09-01 14:20:07 -0700 | [diff] [blame] | 37 | |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 38 | if(NOT ${BUILD_WITH_SPRINGBOK}) |
| 39 | springbok_bytecode_module( |
| 40 | NAME |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 41 | 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 Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 53 | |
Cindy Liu | e3240e2 | 2021-10-07 17:24:21 -0700 | [diff] [blame] | 54 | 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 | ) |
| 68 | endif() |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 69 | |
| 70 | springbok_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 | |
| 85 | springbok_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 | |
| 100 | springbok_bytecode_module( |
| 101 | NAME |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 102 | 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 | |
| 115 | springbok_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 | |
| 130 | springbok_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 Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 145 | endif(${BUILD_INTERNAL_MODELS}) |
| 146 | |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 147 | #------------------------------------------------------------------------------- |
Lun Dong | db85fd7 | 2021-11-02 02:39:48 -0700 | [diff] [blame^] | 148 | # Binaries to execute the IREE model input |
| 149 | #------------------------------------------------------------------------------- |
| 150 | |
| 151 | iree_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 | |
| 161 | if(${BUILD_INTERNAL_MODELS}) |
| 162 | |
| 163 | iree_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 | |
| 173 | endif(${BUILD_INTERNAL_MODELS}) |
| 174 | |
| 175 | #------------------------------------------------------------------------------- |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 176 | # 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 Dong | a563511 | 2021-09-01 11:33:30 -0700 | [diff] [blame] | 187 | # Currently only the person_detection model can run with springbok (b/196910893) |
| 188 | |
Cindy Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 189 | iree_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 Dong | db85fd7 | 2021-11-02 02:39:48 -0700 | [diff] [blame^] | 196 | ::mobilenet_input_c |
Cindy Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 197 | samples::util::util |
| 198 | LINKOPTS |
| 199 | "LINKER:--defsym=__stack_size__=100k" |
| 200 | ) |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 201 | |
Lun Dong | b7990a2 | 2021-09-17 21:46:30 +0000 | [diff] [blame] | 202 | iree_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 Liu | fd819bf | 2021-09-01 23:40:21 -0700 | [diff] [blame] | 214 | if(NOT ${BUILD_INTERNAL_MODELS}) |
| 215 | return() |
| 216 | endif() |
| 217 | |
| 218 | if(NOT ${BUILD_WITH_SPRINGBOK}) |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 219 | 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 Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 228 | |
Cindy Liu | e3240e2 | 2021-10-07 17:24:21 -0700 | [diff] [blame] | 229 | 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 | ) |
| 240 | endif() |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 241 | |
| 242 | iree_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 | |
| 254 | iree_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 | |
| 266 | iree_cc_binary( |
| 267 | NAME |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 268 | person_detection_embedded_sync |
| 269 | SRCS |
| 270 | "person_detection.c" |
| 271 | DEPS |
| 272 | ::person_detection_bytecode_module_dylib_c |
Lun Dong | db85fd7 | 2021-11-02 02:39:48 -0700 | [diff] [blame^] | 273 | ::person_detection_input_c |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 274 | samples::util::util |
| 275 | LINKOPTS |
| 276 | "LINKER:--defsym=__stack_size__=100k" |
| 277 | ) |
| 278 | |
| 279 | iree_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 Dong | b7990a2 | 2021-09-17 21:46:30 +0000 | [diff] [blame] | 287 | LINKOPTS |
| 288 | "LINKER:--defsym=__stack_size__=100k" |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 289 | ) |
| 290 | |
| 291 | iree_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 Dong | b7990a2 | 2021-09-17 21:46:30 +0000 | [diff] [blame] | 299 | LINKOPTS |
| 300 | "LINKER:--defsym=__stack_size__=100k" |
Lun Dong | 9ee4510 | 2021-08-30 10:02:50 -0700 | [diff] [blame] | 301 | ) |