codegen: Remove make helpers for codegen (#2378) This partially reverts commit 1e9b4c5d849a65f5a8b52686ab1db5ceb4e40d18. The make helpers for running the inference code generator were somewhat of a hack due to the desire to integrate a target-specific preprocessor binary as part of the process. Since that is no longer necessary, we can now switch over to just using Bazel for running the code generator. BUG=b/294230402
diff --git a/codegen/examples/hello_world/Makefile.inc b/codegen/examples/hello_world/Makefile.inc deleted file mode 100644 index 6dfcf18..0000000 --- a/codegen/examples/hello_world/Makefile.inc +++ /dev/null
@@ -1,10 +0,0 @@ -CODEGEN_HELLO_WORLD_MODEL := \ -$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_world/models/hello_world_int8.tflite - -CODEGEN_HELLO_WORLD_SRCS := \ -$(TENSORFLOW_ROOT)codegen/examples/hello_world/hello_world.cc - -# Builds a standalone binary. -$(eval $(call codegen_model_binary,codegen_hello_world,hello_world_model,\ -$(CODEGEN_HELLO_WORLD_MODEL),$(CODEGEN_HELLO_WORLD_SRCS),,)) -
diff --git a/codegen/examples/hello_world/README.md b/codegen/examples/hello_world/README.md index eb68b1b..62afee5 100644 --- a/codegen/examples/hello_world/README.md +++ b/codegen/examples/hello_world/README.md
@@ -25,4 +25,3 @@ ``` ./codegen/examples/hello_world/update_example_source.sh ``` -
diff --git a/tensorflow/lite/micro/tools/make/Makefile b/tensorflow/lite/micro/tools/make/Makefile index 9e550f2..8f6c002 100644 --- a/tensorflow/lite/micro/tools/make/Makefile +++ b/tensorflow/lite/micro/tools/make/Makefile
@@ -21,10 +21,6 @@ TENSORFLOW_ROOT := RELATIVE_MAKEFILE_DIR := tensorflow/lite/micro/tools/make MAKEFILE_DIR := $(TENSORFLOW_ROOT)$(RELATIVE_MAKEFILE_DIR) -BAZEL_ROOT := $(TENSORFLOW_ROOT) -ifeq ($(BAZEL_ROOT),) - BAZEL_ROOT = . -endif # Pull in some convenience functions. include $(MAKEFILE_DIR)/helper_functions.inc @@ -303,8 +299,6 @@ $(wildcard $(TENSORFLOW_ROOT)tensorflow/lite/micro/benchmarks/*benchmark.cc) \ $(wildcard $(TENSORFLOW_ROOT)tensorflow/lite/micro/tools/benchmarking/*benchmark.cc) -MICRO_LITE_CODEGEN_EXAMPLES := $(shell find $(TENSORFLOW_ROOT)codegen/examples/ -name Makefile.inc) - MICROLITE_TEST_SRCS := \ $(TENSORFLOW_ROOT)tensorflow/lite/micro/fake_micro_context_test.cc \ $(TENSORFLOW_ROOT)tensorflow/lite/micro/flatbuffer_utils_test.cc \ @@ -574,11 +568,7 @@ MICROLITE_CC_SRCS := $(filter-out $(MICROLITE_TEST_SRCS), $(MICROLITE_CC_BASE_SRCS)) MICROLITE_CC_SRCS := $(filter-out $(MICROLITE_BENCHMARK_SRCS), $(MICROLITE_CC_SRCS)) -CODEGEN_RUNTIME_CC_SRCS := \ -$(TENSORFLOW_ROOT)codegen/runtime/micro_codegen_context.cc -CODEGEN_RUNTIME_CC_HDRS := \ -$(TENSORFLOW_ROOT)codegen/runtime/micro_codegen_context.h # The download scripts require that the downloads directory already exist for # improved error checking. To accomodate that, we first create a downloads @@ -736,9 +726,6 @@ # Load the examples. include $(MICRO_LITE_EXAMPLE_TESTS) -# Load codegen examples. -include $(MICRO_LITE_CODEGEN_EXAMPLES) - # Load the integration tests. include $(MICRO_LITE_INTEGRATION_TESTS)
diff --git a/tensorflow/lite/micro/tools/make/helper_functions.inc b/tensorflow/lite/micro/tools/make/helper_functions.inc index e98c64b..ad3d44c 100644 --- a/tensorflow/lite/micro/tools/make/helper_functions.inc +++ b/tensorflow/lite/micro/tools/make/helper_functions.inc
@@ -117,76 +117,3 @@ # 2 - File pattern, e.g: *.h recursive_find = $(wildcard $(1)$(2)) $(foreach dir,$(wildcard $(1)*),$(call recursive_find,$(dir)/,$(2))) -# Generates code capable of performing inference without an interpreter. -# -# Arguments are: -# 1 - Name of target -# 2 - Generated source basename -# 3 - Model -# Calling eval on the output will create the targets that you need. -define codegen_model -# Filter out targets that currently don't support codegen: -# Hexagon: Docker container doesn't have Bazel support. -ifneq ($(TARGET), $(filter $(TARGET), hexagon)) - -$(1)_MODEL := $(3) - -$(1)_GENERATED_SRCS := $(GENERATED_SRCS_DIR)$(2).cc -$(1)_GENERATED_HDRS := $(GENERATED_SRCS_DIR)$(2).h - -$$($(1)_GENERATED_SRCS) $$($(1)_GENERATED_HDRS): $$($(1)_MODEL) - cd $(BAZEL_ROOT) && bazel run //codegen:code_generator -- \ - --model $(abspath $$($(1)_MODEL)) \ - --output_dir $(abspath $(GENERATED_SRCS_DIR)) --output_name $(2) - -$(1): $$($(1)_GENERATED_SRCS) $$($(1)_GENERATED_HDRS) - -endif -endef # codegen_model - -# Generates and compiles code capable of performing inference without an -# interpreter. -# -# Users can use `make run_<target>` to execute the binary in the appropriate -# simulator. -# -# Arguments are: -# 1 - Name of target -# 2 - Generated source basename -# 3 - Model -# 4 - C/C++ source files -# 5 - C/C++ header files -# Calling eval on the output will create the targets that you need. -define codegen_model_binary -# Filter out targets that currently don't support codegen: -# Hexagon: Docker container doesn't have Bazel support. -ifneq ($(TARGET), $(filter $(TARGET), hexagon)) - -$(1)_CODEGEN_SRCS := $(4) $$(CODEGEN_RUNTIME_CC_SRCS) -$(1)_CODEGEN_HDRS := $(5) $$(CODEGEN_RUNTIME_CC_HDRS) - -$(call codegen_model,$(1)_codegen,$(2),$(3)) - -$(1)_CODEGEN_SRCS += $$($(1)_codegen_GENERATED_SRCS) -$(1)_CODEGEN_HDRS += $$($(1)_codegen_GENERATED_HDRS) - -$(1)_CODEGEN_OBJS := $$(addprefix $$(CORE_OBJDIR), \ -$$(patsubst %.S,%.o,$$(patsubst %.cc,%.o,$$(patsubst %.c,%.o,$$($(1)_CODEGEN_SRCS))))) - -$(1)_BINARY := $$(BINDIR)$(1) -$$($(1)_BINARY): $$($(1)_CODEGEN_OBJS) $$(MICROLITE_LIB_PATH) - @mkdir -p $$(dir $$@) - $$(CXX) $$(CXXFLAGS) $$(INCLUDES) \ - -o $$($(1)_BINARY) $$($(1)_CODEGEN_OBJS) \ - $$(MICROLITE_LIB_PATH) $$(LDFLAGS) $$(MICROLITE_LIBS) - -$(1): $$($(1)_BINARY) -$(1)_bin: $$($(1)_BINARY).bin - -MICROLITE_BUILD_TARGETS += $$($(1)_BINARY) - -run_$(1): $$($(1)_BINARY) - $$(RUN_COMMAND) $$($(1)_BINARY) - -endif -endef # codegen_model_binary
diff --git a/tensorflow/lite/micro/tools/make/targets/cortex_m_qemu_makefile.inc b/tensorflow/lite/micro/tools/make/targets/cortex_m_qemu_makefile.inc index 8a0edfe..a83fc18 100644 --- a/tensorflow/lite/micro/tools/make/targets/cortex_m_qemu_makefile.inc +++ b/tensorflow/lite/micro/tools/make/targets/cortex_m_qemu_makefile.inc
@@ -44,4 +44,3 @@ MICROLITE_TEST_SRCS := $(filter-out $(EXCLUDED_TESTS), $(MICROLITE_TEST_SRCS)) TEST_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/test_with_qemu.sh arm $(TARGET_ARCH) -RUN_COMMAND := qemu-arm -cpu $(TARGET_ARCH)
diff --git a/tensorflow/lite/micro/tools/make/targets/hexagon_makefile.inc b/tensorflow/lite/micro/tools/make/targets/hexagon_makefile.inc index a6249a4..6fe7be7 100644 --- a/tensorflow/lite/micro/tools/make/targets/hexagon_makefile.inc +++ b/tensorflow/lite/micro/tools/make/targets/hexagon_makefile.inc
@@ -123,4 +123,3 @@ TEST_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/test_hexagon_binary.sh SIZE_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/size_hexagon_binary.sh -RUN_COMMAND := hexagon-sim
diff --git a/tensorflow/lite/micro/tools/make/targets/riscv32_generic_makefile.inc b/tensorflow/lite/micro/tools/make/targets/riscv32_generic_makefile.inc index ecdf6b4..661f762 100644 --- a/tensorflow/lite/micro/tools/make/targets/riscv32_generic_makefile.inc +++ b/tensorflow/lite/micro/tools/make/targets/riscv32_generic_makefile.inc
@@ -45,6 +45,5 @@ LDFLAGS += -mno-relax TEST_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/test_with_qemu.sh riscv32 rv32 SIZE_SCRIPT := ${TENSORFLOW_ROOT}tensorflow/lite/micro/testing/size_riscv32_binary.sh -RUN_COMMAND := qemu-riscv32 -cpu rv32 include $(MAKEFILE_DIR)/ext_libs/eyalroz_printf.inc
diff --git a/tensorflow/lite/micro/tools/make/targets/xtensa_makefile.inc b/tensorflow/lite/micro/tools/make/targets/xtensa_makefile.inc index 6fda996..8d970c7 100644 --- a/tensorflow/lite/micro/tools/make/targets/xtensa_makefile.inc +++ b/tensorflow/lite/micro/tools/make/targets/xtensa_makefile.inc
@@ -72,7 +72,6 @@ TEST_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/test_xtensa_binary.sh SIZE_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/size_xtensa_binary.sh -RUN_COMMAND := xt-run # TODO(b/158651472): Fix the memory_arena_threshold_test # TODO(b/174707181): Fix the micro_interpreter_test