diff --git a/tensorflow/lite/micro/benchmarks/Makefile.inc b/tensorflow/lite/micro/benchmarks/Makefile.inc index d9dfba265ed..b50a51758c0 100644 --- a/tensorflow/lite/micro/benchmarks/Makefile.inc +++ b/tensorflow/lite/micro/benchmarks/Makefile.inc @@ -27,8 +27,15 @@ tensorflow/lite/micro/examples/person_detection_experimental/person_detect_model $(eval $(call microlite_test,keyword_benchmark,\ $(KEYWORD_BENCHMARK_SRCS),$(KEYWORD_BENCHMARK_HDRS))) +# We can not build the person detection benchmarks for STM32F4 due to +# insufficient flash (see issue #43743 for more details). Currently disabling +# this benchmark for STM32F4 but we can revisit this later. +ifneq ($(TARGET), stm32f4) + $(eval $(call microlite_test,person_detection_benchmark,\ $(PERSON_DETECTION_BENCHMARK_SRCS),$(PERSON_DETECTION_BENCHMARK_HDRS))) $(eval $(call microlite_test,person_detection_experimental_benchmark,\ $(PERSON_DETECTION_EXPERIMENTAL_BENCHMARK_SRCS),$(PERSON_DETECTION_EXPERIMENTAL_BENCHMARK_HDRS))) + +endif diff --git a/tensorflow/lite/micro/benchmarks/micro_benchmark.h b/tensorflow/lite/micro/benchmarks/micro_benchmark.h index 5da9d9ccb91..83b5cbbdd5c 100644 --- a/tensorflow/lite/micro/benchmarks/micro_benchmark.h +++ b/tensorflow/lite/micro/benchmarks/micro_benchmark.h @@ -43,22 +43,22 @@ extern tflite::ErrorReporter* reporter; return 0; \ } -#define TF_LITE_MICRO_BENCHMARK(func) \ - if (tflite::ticks_per_second() == 0) { \ - TF_LITE_REPORT_ERROR(micro_benchmark::reporter, \ - "no timer implementation found"); \ - return 0; \ - } \ - start_ticks = tflite::GetCurrentTimeTicks(); \ - func; \ - duration_ticks = tflite::GetCurrentTimeTicks() - start_ticks; \ - if (duration_ticks > INT_MAX / 1000) { \ - duration_ms = duration_ticks / (tflite::ticks_per_second() / 1000); \ - } else { \ - duration_ms = (duration_ticks * 1000) / tflite::ticks_per_second(); \ - } \ - TF_LITE_REPORT_ERROR(micro_benchmark::reporter, "%s took %d ticks (%d ms)", \ - #func, duration_ticks, duration_ms); +#define TF_LITE_MICRO_BENCHMARK(func) \ + if (tflite::ticks_per_second() == 0) { \ + TF_LITE_REPORT_ERROR(micro_benchmark::reporter, \ + "no timer implementation found"); \ + return 0; \ + } \ + start_ticks = tflite::GetCurrentTimeTicks(); \ + func; \ + duration_ticks = tflite::GetCurrentTimeTicks() - start_ticks; \ + if (duration_ticks > INT_MAX / 1000) { \ + duration_ms = duration_ticks / (tflite::ticks_per_second() / 1000); \ + } else { \ + duration_ms = (duration_ticks * 1000) / tflite::ticks_per_second(); \ + } \ + micro_benchmark::reporter->Report("%s took %d ticks (%d ms)", #func, \ + duration_ticks, duration_ms); template class MicroBenchmarkRunner { diff --git a/tensorflow/lite/micro/tools/ci_build/test_sparkfun.sh b/tensorflow/lite/micro/tools/ci_build/test_sparkfun.sh index 87ff8537311..88367cd9c11 100755 --- a/tensorflow/lite/micro/tools/ci_build/test_sparkfun.sh +++ b/tensorflow/lite/micro/tools/ci_build/test_sparkfun.sh @@ -24,10 +24,13 @@ cd "${ROOT_DIR}" source tensorflow/lite/micro/tools/ci_build/helper_functions.sh -readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean - TARGET=sparkfun_edge # TODO(b/143715361): downloading first to allow for parallel builds. readable_run make -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} third_party_downloads + +readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} build + +readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean +readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} TAGS=cmsis-nn build diff --git a/tensorflow/lite/micro/tools/make/helper_functions.inc b/tensorflow/lite/micro/tools/make/helper_functions.inc index a2127e4bdca..6ff5fd1e3d5 100644 --- a/tensorflow/lite/micro/tools/make/helper_functions.inc +++ b/tensorflow/lite/micro/tools/make/helper_functions.inc @@ -459,6 +459,7 @@ define microlite_test ifeq (,$(findstring _test, $(1))) $(eval $(call generate_project_third_party_parsing)) endif + $(1)_LOCAL_SRCS := $(2) $(1)_LOCAL_SRCS := $$(call specialize,$$($(1)_LOCAL_SRCS)) ALL_SRCS += $$($(1)_LOCAL_SRCS) @@ -476,10 +477,23 @@ $(1)_bin: $$($(1)_BINARY).bin test_$(1): $$($(1)_BINARY) @test -f $$(TEST_SCRIPT) || (echo 'Unable to find the test script. Is the software emulation available in $$(TARGET)?'; exit 1) $$(TEST_SCRIPT) $$($(1)_BINARY) '~~~ALL TESTS PASSED~~~' + ifneq (,$(findstring _test,$(1))) MICROLITE_TEST_TARGETS += test_$(1) MICROLITE_BUILD_TARGETS += $$($(1)_BINARY) endif + +# The ifneq can make is seem that the body of the if block is executed when +# _benchmark is not found in $(1). Actually, the check is saying that if +# findstring does not return empty, i.e. if _benchmark is found in $(1), we +# should add something to the MICROLITE_BUILD_TARGETS. +# +# This ensures that a `make build` command will builds all the tests and +# benchmarks, though `make test` will only run the tests. +ifneq (,$(findstring _benchmark,$(1))) + MICROLITE_BUILD_TARGETS += $$($(1)_BINARY) +endif + $(eval $(call generate_microlite_projects,$(1),$(call specialize,$(2)),$(3))) endef