-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxtensa.inc
More file actions
159 lines (124 loc) · 5.9 KB
/
xtensa.inc
File metadata and controls
159 lines (124 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Explicitly add kernel sources specific to the Xtensa optimized
# implementations.
MICROLITE_CC_KERNEL_SRCS += \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/add_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_hifi.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int16_reference.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_int8_reference.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/conv_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/depthwise_conv_hifi.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/depthwise_conv_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_common_xtensa.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_int8.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/fully_connected_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pad_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pooling_int8.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/pooling_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/reduce_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/reshape_vision.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/softmax_int8_int16.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/softmax_vision.cc
ifeq ($(TARGET_ARCH), hifimini)
# hifimini optimizations are implemented in the TFLM repository itself.
THIRD_PARTY_KERNEL_CC_SRCS += \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/hifimini/svdf.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/hifimini/fully_connected.cc
else ifeq ($(TARGET_ARCH), hifi5)
DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ext_libs/xtensa_download.sh ${DOWNLOADS_DIR} hifi5 $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the xtensa download: $(DOWNLOAD_RESULT))
endif
# TODO(b/161489252): -Wno-shadow is only needed for xannlib. But since we do
# not have separate cflags (or the concept of modular build targets) with the
# Makefile, -Wno-shadow will be used for everything.
PLATFORM_FLAGS = \
-DNNLIB_HIFI5 \
-Wno-shadow
CCFLAGS += $(PLATFORM_FLAGS)
CXXFLAGS += $(PLATFORM_FLAGS)
NNLIB_PATH := $(MAKEFILE_DIR)/downloads/xa_nnlib_hifi5
THIRD_PARTY_KERNEL_CC_SRCS += \
$(shell find $(NNLIB_PATH) -name "*.c")
EXCLUDED_NNLIB_SRCS = \
$(NNLIB_PATH)/algo/layers/cnn/src/xa_nn_cnn_api.c \
$(NNLIB_PATH)/algo/layers/gru/src/xa_nn_gru_api.c \
$(NNLIB_PATH)/algo/layers/lstm/src/xa_nn_lstm_api.c
THIRD_PARTY_KERNEL_CC_SRCS := $(filter-out $(EXCLUDED_NNLIB_SRCS), $(THIRD_PARTY_KERNEL_CC_SRCS))
THIRD_PARTY_CC_HDRS += \
$(shell find $(NNLIB_PATH) -name "*.h")
INCLUDES += \
-I$(NNLIB_PATH)/ \
-I$(NNLIB_PATH)/algo/kernels/ \
-I$(NNLIB_PATH)/include/nnlib/ \
-I$(NNLIB_PATH)/include/ \
-I$(NNLIB_PATH)/algo/common/include/ \
-I$(NNLIB_PATH)/algo/ndsp/hifi5/include/
else ifeq ($(TARGET_ARCH), hifi4)
DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ext_libs/xtensa_download.sh ${DOWNLOADS_DIR} hifi4 $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the xtensa download: $(DOWNLOAD_RESULT))
endif
# TODO(b/161489252): -Wno-shadow is only needed for xannlib. But since we do
# not have separate cflags (or the concept of modular build targets) with the
# Makefile, -Wno-shadow will be used for everything.
PLATFORM_FLAGS = \
-DNNLIB_V2 \
-Wno-shadow
CCFLAGS += $(PLATFORM_FLAGS)
CXXFLAGS += $(PLATFORM_FLAGS)
NNLIB_PATH := $(MAKEFILE_DIR)/downloads/xa_nnlib_hifi4
THIRD_PARTY_KERNEL_CC_SRCS += \
$(shell find $(NNLIB_PATH) -name "*.c")
EXCLUDED_NNLIB_SRCS = \
$(NNLIB_PATH)/algo/layers/cnn/src/xa_nn_cnn_api.c \
$(NNLIB_PATH)/algo/layers/gru/src/xa_nn_gru_api.c \
$(NNLIB_PATH)/algo/layers/lstm/src/xa_nn_lstm_api.c
THIRD_PARTY_KERNEL_CC_SRCS := $(filter-out $(EXCLUDED_NNLIB_SRCS), $(THIRD_PARTY_KERNEL_CC_SRCS))
THIRD_PARTY_CC_HDRS += \
$(shell find $(NNLIB_PATH) -name "*.h")
INCLUDES += \
-I$(NNLIB_PATH)/ \
-I$(NNLIB_PATH)/algo/kernels/ \
-I$(NNLIB_PATH)/include/nnlib/ \
-I$(NNLIB_PATH)/include/ \
-I$(NNLIB_PATH)/algo/common/include/ \
-I$(NNLIB_PATH)/algo/ndsp/hifi4/include/
else ifeq ($(TARGET_ARCH), vision_p6)
DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ext_libs/xtensa_download.sh ${DOWNLOADS_DIR} vision_p6 $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the xtensa download: $(DOWNLOAD_RESULT))
endif
# TODO(b/161489252): -Wno-shadow is only needed for xannlib. But since we do
# not have separate cflags (or the concept of modular build targets) with the
# Makefile, -Wno-shadow will be used for everything.
PLATFORM_FLAGS = \
-DXI_ERROR_LEVEL=XI_ERROR_LEVEL_NO_ERROR \
-DCNNRT_PERF_LEVEL=CNNRT_PERF_LEVEL_NONE \
-DINCLUDE_XI_CNN \
-Wno-shadow
CCFLAGS += $(PLATFORM_FLAGS)
CXXFLAGS += $(PLATFORM_FLAGS)
NNLIB_PATH := $(MAKEFILE_DIR)/downloads/xi_tflmlib_vision_p6
THIRD_PARTY_CC_SRCS += \
$(shell find $(NNLIB_PATH) -name "*.cc")
INCLUDES += \
-I$(NNLIB_PATH)/flk/include \
-I$(NNLIB_PATH)/kernels/include/ \
-I$(NNLIB_PATH)/runtime/include/
LDFLAGS += -lidma
else
$(error Unsupported TARGET_ARCH=$(TARGET_ARCH))
endif
FFT_PATH := $(MAKEFILE_DIR)/downloads/hifi_fft
INCLUDES += -I$(FFT_PATH)/
ifeq ($(TARGET_ARCH), $(filter $(TARGET_ARCH), hifi3 hifi4 hifi5))
THIRD_PARTY_KERNEL_CC_SRCS += \
$(shell find $(FFT_PATH)/hifi3_fft -name "*.c")
THIRD_PARTY_CC_HDRS += \
$(shell find $(FFT_PATH)/hifi3_fft -name "*.h")
else ifeq ($(TARGET_ARCH), hifimini)
THIRD_PARTY_KERNEL_CC_SRCS += \
$(shell find $(FFT_PATH)/hifi2_fft -name "*.c")
THIRD_PARTY_CC_HDRS += \
$(shell find $(FFT_PATH)/hifi2_fft -name "*.h")
endif