Skip to content

Commit 5245ca9

Browse files
authored
Updates to Xtensa makefiles (#3154)
@tensorflow/micro Reorganize Xtensa makefiles such that all references to optimized kernel sources are moved to the Xtensa target makefile. Move hifimini kernel sources to the parent directory, and rename them so they do not interfere with the target overlay mechanism of the root makefile. bug=fixes #3153
1 parent a0cb185 commit 5245ca9

File tree

6 files changed

+43
-48
lines changed

6 files changed

+43
-48
lines changed

tensorflow/lite/micro/kernels/xtensa/hifimini/fully_connected.cc renamed to tensorflow/lite/micro/kernels/xtensa/fully_connected_hifimini.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
1+
/* Copyright 2025 The TensorFlow Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@ limitations under the License.
1414
==============================================================================*/
1515

1616
#if defined(HIFIMINI)
17-
#include "tensorflow/lite/micro/kernels/fully_connected.h"
1817

1918
#include "tensorflow/lite/c/builtin_op_data.h"
2019
#include "tensorflow/lite/c/common.h"
@@ -24,8 +23,9 @@ limitations under the License.
2423
#include "tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h"
2524
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
2625
#include "tensorflow/lite/kernels/kernel_util.h"
26+
#include "tensorflow/lite/micro/kernels/fully_connected.h"
2727
#include "tensorflow/lite/micro/kernels/kernel_util.h"
28-
#include "tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h"
28+
#include "tensorflow/lite/micro/kernels/xtensa/fixedpoint_utils_hifimini.h"
2929
#include "tensorflow/lite/micro/kernels/xtensa/xtensa.h"
3030

3131
namespace tflite {

tensorflow/lite/micro/kernels/xtensa/hifimini/svdf.cc renamed to tensorflow/lite/micro/kernels/xtensa/svdf_hifimini.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
1+
/* Copyright 2025 The TensorFlow Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@ limitations under the License.
1414
==============================================================================*/
1515

1616
#if defined(HIFIMINI)
17-
#include "tensorflow/lite/micro/kernels/svdf.h"
1817

1918
#include <cmath>
2019

@@ -27,7 +26,8 @@ limitations under the License.
2726
#include "tensorflow/lite/kernels/op_macros.h"
2827
#include "tensorflow/lite/micro/kernels/activation_utils.h"
2928
#include "tensorflow/lite/micro/kernels/kernel_util.h"
30-
#include "tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h"
29+
#include "tensorflow/lite/micro/kernels/svdf.h"
30+
#include "tensorflow/lite/micro/kernels/xtensa/fixedpoint_utils_hifimini.h"
3131
#include "tensorflow/lite/micro/kernels/xtensa/xtensa.h"
3232
#include "tensorflow/lite/micro/kernels/xtensa/xtensa_svdf.h"
3333

tensorflow/lite/micro/kernels/xtensa/xtensa.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
1+
/* Copyright 2025 The TensorFlow Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ limitations under the License.
1919
#if defined(HIFIMINI)
2020
#include <xtensa/tie/xt_hifi2.h>
2121

22-
#include "tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h"
22+
#include "tensorflow/lite/micro/kernels/xtensa/fixedpoint_utils_hifimini.h"
2323
#endif // defined(HIFMINI)
2424

2525
#if defined(HIFI3) || defined(HIFI4) || defined(HIFI5)

tensorflow/lite/micro/tools/make/ext_libs/xtensa.inc

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
11

2-
# Explicitly add kernel sources specific to the Xtensa optimized
3-
# implementations.
4-
MICROLITE_CC_KERNEL_SRCS += \
5-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/add_vision.cc \
6-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_common_xtensa.cc \
7-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_hifi.cc \
8-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int16_reference.cc \
9-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int8_int16.cc \
10-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int8_reference.cc \
11-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_vision.cc \
12-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/depthwise_conv_hifi.cc \
13-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/depthwise_conv_vision.cc \
14-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_common_xtensa.cc \
15-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_int8.cc \
16-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_vision.cc \
17-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pad_vision.cc \
18-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pooling_int8.cc \
19-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pooling_vision.cc \
20-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/reduce_vision.cc \
21-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/reshape_vision.cc \
22-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/softmax_int8_int16.cc \
23-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/softmax_vision.cc
24-
252
ifeq ($(TARGET_ARCH), hifimini)
26-
# hifimini optimizations are implemented in the TFLM repository itself.
27-
THIRD_PARTY_KERNEL_CC_SRCS += \
28-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/hifimini/svdf.cc \
29-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/hifimini/fully_connected.cc
30-
313
FFT_PATH := $(MAKEFILE_DIR)/downloads/hifi_fft
324
INCLUDES += -I$(FFT_PATH)/
335

tensorflow/lite/micro/tools/make/targets/xtensa_makefile.inc

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,43 @@ EXCLUDED_EXAMPLE_TESTS := \
9191
MICRO_LITE_EXAMPLE_TESTS := $(filter-out $(EXCLUDED_EXAMPLE_TESTS), $(MICRO_LITE_EXAMPLE_TESTS))
9292
MICRO_LITE_EXAMPLE_TESTS += $(shell find $(TENSORFLOW_ROOT)third_party/xtensa/examples/ -name Makefile.inc)
9393

94-
# Needed for LSTM support.
95-
MICROLITE_CC_KERNEL_SRCS := $(MICROLITE_CC_KERNEL_SRCS) \
96-
$(TENSORFLOW_ROOT)tensorflow/lite/kernels/internal/reference/portable_tensor_utils.cc \
97-
$(TENSORFLOW_ROOT)tensorflow/lite/kernels/kernel_util.cc
98-
9994
ifeq ($(OPTIMIZED_KERNEL_DIR), xtensa)
100-
MICROLITE_CC_KERNEL_SRCS := $(MICROLITE_CC_KERNEL_SRCS) \
101-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/lstm_eval.cc \
102-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/lstm_eval_hifi.cc \
103-
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/unidirectional_sequence_lstm.cc
95+
# Explicitly add kernel sources specific to the Xtensa optimized
96+
# implementations.
97+
#
98+
# Do not include overlays for reference kernel files.
99+
MICROLITE_CC_KERNEL_SRCS += \
100+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/add_vision.cc \
101+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_common_xtensa.cc \
102+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_hifi.cc \
103+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int16_reference.cc \
104+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int8_int16.cc \
105+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int8_reference.cc \
106+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_vision.cc \
107+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/depthwise_conv_hifi.cc \
108+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/depthwise_conv_vision.cc \
109+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_common_xtensa.cc \
110+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_hifimini.cc \
111+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_int8.cc \
112+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_vision.cc \
113+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/lstm_eval_hifi.cc \
114+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pad_vision.cc \
115+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pooling_int8.cc \
116+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pooling_vision.cc \
117+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/reduce_vision.cc \
118+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/reshape_vision.cc \
119+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/softmax_int8_int16.cc \
120+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/softmax_vision.cc \
121+
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/svdf_hifimini.cc
122+
123+
# Needed for LSTM support.
124+
MICROLITE_CC_KERNEL_SRCS += \
125+
$(TENSORFLOW_ROOT)tensorflow/lite/kernels/internal/reference/portable_tensor_utils.cc \
126+
$(TENSORFLOW_ROOT)tensorflow/lite/kernels/kernel_util.cc
127+
endif
104128

105-
# override KERNEL_OPTIMIZATION_LEVEL to enable higher performance
106-
# Xtensa intrinsics.
129+
# override KERNEL_OPTIMIZATION_LEVEL to enable higher performance
130+
# Xtensa intrinsics.
107131
$(KERNEL_OBJDIR)$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/decompress.o: $(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/decompress.cc
108132
@mkdir -p $(dir $@)
109133
$(CXX) $(CXXFLAGS) -O3 -LNO:simd $(INCLUDES) -c $< -o $@
110-
endif

0 commit comments

Comments
 (0)