1load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 2load( 3 "//tensorflow/lite/micro:build_def.bzl", 4 "micro_copts", 5) 6 7package( 8 default_visibility = ["//visibility:public"], 9 features = ["-layering_check"], 10 licenses = ["notice"], 11) 12 13package_group( 14 name = "micro", 15 packages = ["//tensorflow/lite/micro/..."], 16) 17 18cc_library( 19 name = "micro_compatibility", 20 hdrs = [ 21 "compatibility.h", 22 ], 23 copts = micro_copts(), 24) 25 26cc_library( 27 # TODO(b/187093492): Rename to micro_interpreter. 28 name = "micro_framework", 29 srcs = [ 30 "micro_interpreter.cc", 31 ], 32 hdrs = [ 33 "micro_interpreter.h", 34 ], 35 copts = micro_copts(), 36 deps = [ 37 ":memory_helpers", 38 ":micro_allocator", 39 ":micro_error_reporter", 40 ":micro_graph", 41 ":micro_profiler", 42 ":op_resolvers", 43 "//tensorflow/lite:type_to_tflitetype", 44 "//tensorflow/lite/c:common", 45 "//tensorflow/lite/core/api", 46 "//tensorflow/lite/core/api:error_reporter", 47 "//tensorflow/lite/kernels/internal:tensor", 48 "//tensorflow/lite/schema:schema_fbs", 49 "//tensorflow/lite/schema:schema_utils", 50 "@flatbuffers//:runtime_cc", 51 ], 52) 53 54cc_library( 55 name = "micro_graph", 56 srcs = ["micro_graph.cc"], 57 hdrs = ["micro_graph.h"], 58 deps = [ 59 ":memory_helpers", 60 ":micro_allocator", 61 ":micro_error_reporter", 62 ":micro_profiler", 63 "//tensorflow/lite/c:common", 64 "//tensorflow/lite/kernels/internal:compatibility", 65 "//tensorflow/lite/schema:schema_fbs", 66 "@flatbuffers//:runtime_cc", 67 ], 68) 69 70cc_library( 71 name = "mock_micro_graph", 72 srcs = ["mock_micro_graph.cc"], 73 hdrs = ["mock_micro_graph.h"], 74 deps = [ 75 ":micro_allocator", 76 ":micro_graph", 77 ":test_helpers", 78 "//tensorflow/lite/c:common", 79 "//tensorflow/lite/schema:schema_fbs", 80 ], 81) 82 83cc_library( 84 name = "micro_allocator", 85 srcs = [ 86 "micro_allocator.cc", 87 "simple_memory_allocator.cc", 88 ], 89 hdrs = [ 90 "micro_allocator.h", 91 "simple_memory_allocator.h", 92 ], 93 copts = micro_copts(), 94 deps = [ 95 ":flatbuffer_utils", 96 ":memory_helpers", 97 ":micro_compatibility", 98 ":micro_error_reporter", 99 "//tensorflow/lite/c:common", 100 "//tensorflow/lite/core/api", 101 "//tensorflow/lite/core/api:error_reporter", 102 "//tensorflow/lite/core/api:op_resolver", 103 "//tensorflow/lite/kernels/internal:compatibility", 104 "//tensorflow/lite/micro/memory_planner", 105 "//tensorflow/lite/micro/memory_planner:greedy_memory_planner", 106 "//tensorflow/lite/schema:schema_fbs", 107 "//tensorflow/lite/schema:schema_utils", 108 "@flatbuffers//:runtime_cc", 109 ], 110) 111 112cc_library( 113 name = "flatbuffer_utils", 114 srcs = ["flatbuffer_utils.cc"], 115 hdrs = ["flatbuffer_utils.h"], 116 deps = [ 117 "//tensorflow/lite/schema:schema_fbs", 118 "@flatbuffers//:runtime_cc", 119 ], 120) 121 122cc_library( 123 name = "memory_helpers", 124 srcs = ["memory_helpers.cc"], 125 hdrs = ["memory_helpers.h"], 126 deps = [ 127 "//tensorflow/lite/c:common", 128 "//tensorflow/lite/core/api", 129 "//tensorflow/lite/kernels/internal:reference", 130 "//tensorflow/lite/schema:schema_fbs", 131 "@flatbuffers//:runtime_cc", 132 ], 133) 134 135cc_library( 136 name = "test_helpers", 137 srcs = [ 138 "test_helpers.cc", 139 ], 140 hdrs = [ 141 "test_helpers.h", 142 ], 143 copts = micro_copts(), 144 deps = [ 145 ":micro_utils", 146 ":op_resolvers", 147 "//tensorflow/lite:type_to_tflitetype", 148 "//tensorflow/lite/c:common", 149 "//tensorflow/lite/core/api", 150 "//tensorflow/lite/kernels:kernel_util", 151 "//tensorflow/lite/kernels/internal:compatibility", 152 "//tensorflow/lite/kernels/internal:tensor", 153 "//tensorflow/lite/schema:schema_fbs", 154 "@flatbuffers//:runtime_cc", 155 ], 156) 157 158cc_library( 159 name = "op_resolvers", 160 srcs = [ 161 "all_ops_resolver.cc", 162 ], 163 hdrs = [ 164 "all_ops_resolver.h", 165 "micro_mutable_op_resolver.h", 166 "micro_op_resolver.h", 167 ], 168 copts = micro_copts(), 169 deps = [ 170 ":micro_compatibility", 171 "//tensorflow/lite/c:common", 172 "//tensorflow/lite/core/api", 173 "//tensorflow/lite/kernels:op_macros", 174 "//tensorflow/lite/kernels/internal:compatibility", 175 "//tensorflow/lite/micro/kernels:micro_ops", 176 "//tensorflow/lite/schema:schema_fbs", 177 ], 178) 179 180cc_library( 181 name = "debug_log", 182 srcs = [ 183 "debug_log.cc", 184 ], 185 hdrs = [ 186 "debug_log.h", 187 ], 188 copts = micro_copts(), 189) 190 191cc_library( 192 name = "micro_error_reporter", 193 srcs = [ 194 "micro_error_reporter.cc", 195 ], 196 hdrs = [ 197 "micro_error_reporter.h", 198 ], 199 copts = micro_copts(), 200 deps = [ 201 ":debug_log", 202 ":micro_compatibility", 203 ":micro_string", 204 "//tensorflow/lite/core/api", 205 ], 206) 207 208cc_library( 209 name = "micro_string", 210 srcs = [ 211 "micro_string.cc", 212 ], 213 hdrs = [ 214 "micro_string.h", 215 ], 216 copts = micro_copts(), 217) 218 219cc_library( 220 name = "micro_time", 221 srcs = [ 222 "micro_time.cc", 223 ], 224 hdrs = [ 225 "micro_time.h", 226 ], 227 copts = micro_copts() + ["-DTF_LITE_USE_CTIME"], 228 deps = ["//tensorflow/lite/c:common"], 229) 230 231cc_library( 232 name = "micro_profiler", 233 srcs = [ 234 "micro_profiler.cc", 235 ], 236 hdrs = [ 237 "micro_profiler.h", 238 ], 239 copts = micro_copts(), 240 deps = [ 241 ":micro_error_reporter", 242 ":micro_time", 243 "//tensorflow/lite/kernels/internal:compatibility", 244 ], 245) 246 247cc_library( 248 name = "micro_utils", 249 srcs = [ 250 "micro_utils.cc", 251 ], 252 hdrs = [ 253 "micro_utils.h", 254 ], 255 copts = micro_copts(), 256 deps = [ 257 ":micro_error_reporter", 258 "//tensorflow/lite/c:common", 259 "//tensorflow/lite/kernels:op_macros", 260 ], 261) 262 263cc_library( 264 name = "recording_allocators", 265 srcs = [ 266 "recording_micro_allocator.cc", 267 "recording_simple_memory_allocator.cc", 268 ], 269 hdrs = [ 270 "recording_micro_allocator.h", 271 "recording_micro_interpreter.h", 272 "recording_simple_memory_allocator.h", 273 ], 274 copts = micro_copts(), 275 deps = [ 276 ":micro_allocator", 277 ":micro_compatibility", 278 ":micro_framework", 279 "//tensorflow/lite/core/api", 280 "//tensorflow/lite/kernels/internal:compatibility", 281 ], 282) 283 284cc_library( 285 name = "system_setup", 286 srcs = [ 287 "system_setup.cc", 288 ], 289 hdrs = [ 290 "system_setup.h", 291 ], 292 copts = micro_copts(), 293) 294 295cc_test( 296 name = "micro_error_reporter_test", 297 srcs = [ 298 "micro_error_reporter_test.cc", 299 ], 300 deps = [ 301 ":micro_error_reporter", 302 ], 303) 304 305cc_test( 306 name = "micro_mutable_op_resolver_test", 307 srcs = [ 308 "micro_mutable_op_resolver_test.cc", 309 ], 310 deps = [ 311 ":micro_framework", 312 ":op_resolvers", 313 "//tensorflow/lite/micro/testing:micro_test", 314 ], 315) 316 317cc_test( 318 name = "micro_interpreter_test", 319 srcs = [ 320 "micro_interpreter_test.cc", 321 ], 322 deps = [ 323 ":micro_compatibility", 324 ":micro_error_reporter", 325 ":micro_framework", 326 ":micro_profiler", 327 ":micro_utils", 328 ":op_resolvers", 329 ":recording_allocators", 330 ":test_helpers", 331 "//tensorflow/lite/core/api", 332 "//tensorflow/lite/micro/testing:micro_test", 333 ], 334) 335 336cc_test( 337 name = "simple_memory_allocator_test", 338 srcs = [ 339 "simple_memory_allocator_test.cc", 340 ], 341 deps = [ 342 ":micro_framework", 343 ":test_helpers", 344 "//tensorflow/lite/micro/testing:micro_test", 345 ], 346) 347 348cc_test( 349 name = "recording_simple_memory_allocator_test", 350 srcs = [ 351 "recording_simple_memory_allocator_test.cc", 352 ], 353 deps = [ 354 ":micro_framework", 355 ":recording_allocators", 356 ":test_helpers", 357 "//tensorflow/lite/micro/testing:micro_test", 358 ], 359) 360 361cc_test( 362 name = "micro_allocator_test", 363 srcs = [ 364 "micro_allocator_test.cc", 365 ], 366 deps = [ 367 ":memory_helpers", 368 ":micro_allocator", 369 ":micro_error_reporter", 370 ":test_helpers", 371 "//tensorflow/lite/c:common", 372 "//tensorflow/lite/micro/testing:micro_test", 373 "//tensorflow/lite/micro/testing:test_conv_model", 374 ], 375) 376 377cc_test( 378 name = "recording_micro_allocator_test", 379 srcs = [ 380 "recording_micro_allocator_test.cc", 381 ], 382 deps = [ 383 ":micro_allocator", 384 ":micro_error_reporter", 385 ":op_resolvers", 386 ":recording_allocators", 387 ":test_helpers", 388 "//tensorflow/lite/micro/testing:micro_test", 389 "//tensorflow/lite/micro/testing:test_conv_model", 390 ], 391) 392 393cc_test( 394 name = "flatbuffer_utils_test", 395 srcs = [ 396 "flatbuffer_utils_test.cc", 397 ], 398 tags = [ 399 "nomsan", # TODO(b/192311485): See http://b/192311485#comment2 400 ], 401 deps = [ 402 ":flatbuffer_utils", 403 ":test_helpers", 404 "//tensorflow/lite/micro/testing:micro_test", 405 ], 406) 407 408cc_test( 409 name = "memory_helpers_test", 410 srcs = [ 411 "memory_helpers_test.cc", 412 ], 413 deps = [ 414 ":memory_helpers", 415 ":test_helpers", 416 "//tensorflow/lite/micro/testing:micro_test", 417 ], 418) 419 420cc_test( 421 name = "testing_helpers_test", 422 srcs = [ 423 "testing_helpers_test.cc", 424 ], 425 deps = [ 426 ":micro_framework", 427 "//tensorflow/lite/micro:test_helpers", 428 "//tensorflow/lite/micro/testing:micro_test", 429 ], 430) 431 432cc_test( 433 name = "micro_utils_test", 434 srcs = [ 435 "micro_utils_test.cc", 436 ], 437 deps = [ 438 ":micro_utils", 439 "//tensorflow/lite/micro/testing:micro_test", 440 ], 441) 442 443cc_test( 444 name = "micro_string_test", 445 srcs = [ 446 "micro_string_test.cc", 447 ], 448 deps = [ 449 ":micro_string", 450 "//tensorflow/lite/micro/testing:micro_test", 451 ], 452) 453 454cc_test( 455 name = "micro_time_test", 456 srcs = [ 457 "micro_time_test.cc", 458 ], 459 deps = [ 460 ":micro_time", 461 "//tensorflow/lite/micro/testing:micro_test", 462 ], 463) 464 465cc_test( 466 name = "memory_arena_threshold_test", 467 srcs = [ 468 "memory_arena_threshold_test.cc", 469 ], 470 deps = [ 471 ":micro_error_reporter", 472 ":op_resolvers", 473 ":recording_allocators", 474 "//tensorflow/lite/micro/benchmarks:keyword_scrambled_model_data", 475 "//tensorflow/lite/micro/testing:micro_test", 476 "//tensorflow/lite/micro/testing:test_conv_model", 477 ], 478) 479 480bzl_library( 481 name = "build_def_bzl", 482 srcs = ["build_def.bzl"], 483 visibility = [":micro"], 484) 485