Skip to content

Commit 69a296d

Browse files
committed
Update ArmNN and ACL pins to 21.08 and change naming in source from tflite to armnn_tflite where applicable to reflect new repository name.
Remove gpu tuning level as option in gpu execution accelerator params for armnn.
1 parent ccb0d17 commit 69a296d

File tree

9 files changed

+91
-84
lines changed

9 files changed

+91
-84
lines changed

CMakeLists.txt

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
cmake_minimum_required (VERSION 3.18)
22

3-
project(tritontflitebackend LANGUAGES C CXX)
3+
project(tritonarmnntflitebackend LANGUAGES C CXX)
44

55
if(NOT CMAKE_BUILD_TYPE)
66
set(CMAKE_BUILD_TYPE Release)
77
endif()
88

99
set(TARGET_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
1010

11+
# Triton Options
1112
option(TRITON_ENABLE_STATS "Include statistics collections in backend" ON)
1213
option(TRITON_ENABLE_MALI_GPU "Enable Arm MALI GPU support in backend utilities" OFF)
1314

1415
set(TRITON_BACKEND_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/backend repo")
1516
set(TRITON_CORE_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/core repo")
1617
set(TRITON_COMMON_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/common repo")
1718

19+
# TFLite Options
1820
set(TFLITE_TAG "v2.4.1" CACHE STRING "Version of TFLite to build")
21+
option(TFLITE_ENABLE_RUY "Use RUY library in TFLite build" ON)
1922

2023
# ArmNN Options
21-
set(ARMNN_TAG "v21.05" CACHE STRING "Tag for ArmNN repo")
24+
set(ARMNN_TAG "v21.08" CACHE STRING "Tag for ArmNN repo")
2225
set(ARMNN_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set ArmNN build type")
2326
option(ARMNN_DELEGATE_ENABLE "Build ArmNN Delegate" ON)
2427

@@ -56,7 +59,7 @@ if (NOT DEFINED ACL_ARCH)
5659
endif()
5760

5861
# ACL before 21.05 compiled with only gcc7
59-
if (NOT(ACL_TAG STREQUAL "v21.05"))
62+
if (NOT((ACL_TAG STREQUAL "v21.05") OR (ACL_TAG STREQUAL "v21.08")))
6063
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7)
6164
set(ACL_CC_COMPILER "gcc-7")
6265
set(ACL_CXX_COMPILER "g++-7")
@@ -105,7 +108,7 @@ FetchContent_MakeAvailable(repo-common repo-core repo-backend tensorflow-lite)
105108
#
106109
# Shared library implementing the Triton Backend API
107110
#
108-
configure_file(src/libtriton_tflite.ldscript libtriton_tflite.ldscript COPYONLY)
111+
configure_file(src/libtriton_armnn_tflite.ldscript libtriton_armnn_tflite.ldscript COPYONLY)
109112

110113
include(ExternalProject)
111114

@@ -132,6 +135,7 @@ if (ARMNN_DELEGATE_ENABLE)
132135
GIT_REPOSITORY https://review.mlplatform.org/ml/ComputeLibrary
133136
GIT_TAG ${ACL_TAG}
134137
GIT_SHALLOW ON
138+
PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/patches/acl.patch || true
135139
CONFIGURE_COMMAND ""
136140
BUILD_COMMAND CC=${ACL_CC_COMPILER} CXX=${ACL_CXX_COMPILER} scons -j${JOBS} arch=${ACL_ARCH} debug=${ACL_DEBUG} neon=${ACL_ENABLE_NEON} opencl=${ACL_ENABLE_CL} embed_kernels=1 extra_cxx_flags=-fPIC benchmark_tests=0 build=native validation_tests=0 internal_only=0 examples=0
137141
BUILD_IN_SOURCE ON
@@ -156,32 +160,32 @@ endif()
156160
#
157161

158162
add_library(
159-
triton-tflite-backend SHARED
163+
triton-armnn-tflite-backend SHARED
160164
src/tflite.cc
161165
src/tflite_utils.cc
162166
src/tflite_utils.h
163167
)
164168

165169
if (ARMNN_DELEGATE_ENABLE)
166-
add_dependencies(triton-tflite-backend armnn)
170+
add_dependencies(triton-armnn-tflite-backend armnn)
167171
endif()
168172

169173
add_library(
170-
TritonTFLiteBackend::triton-tflite-backend ALIAS triton-tflite-backend
174+
TritonArmNNTFLiteBackend::triton-armnn-tflite-backend ALIAS triton-armnn-tflite-backend
171175
)
172176

173177
target_include_directories(
174-
triton-tflite-backend
178+
triton-armnn-tflite-backend
175179
PRIVATE
176180
${CMAKE_CURRENT_SOURCE_DIR}/src
177181
${CMAKE_CURRENT_BINARY_DIR}/_deps/tensorflow-lite-src
178182
${ARMNN_LOCATION}/include # for armnn headers
179183
${ARMNN_LOCATION}/src/armnn/delegate/include # for delegate headers
180184
)
181185

182-
target_compile_features(triton-tflite-backend PRIVATE cxx_std_11)
186+
target_compile_features(triton-armnn-tflite-backend PRIVATE cxx_std_11)
183187
target_compile_options(
184-
triton-tflite-backend PRIVATE
188+
triton-armnn-tflite-backend PRIVATE
185189
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
186190
-Wall -Wextra -Wno-unused-parameter -Wno-type-limits -Werror>
187191
)
@@ -195,20 +199,20 @@ if(${ARMNN_DELEGATE_ENABLE})
195199
endif() # ARMNN_DELEGATE_ENABLE
196200

197201
set_target_properties(
198-
triton-tflite-backend
202+
triton-armnn-tflite-backend
199203
PROPERTIES
200204
POSITION_INDEPENDENT_CODE ON
201-
OUTPUT_NAME triton_tflite
205+
OUTPUT_NAME triton_armnn_tflite
202206
SKIP_BUILD_RPATH TRUE
203207
BUILD_WITH_INSTALL_RPATH TRUE
204208
INSTALL_RPATH_USE_LINK_PATH FALSE
205209
INSTALL_RPATH "$\{ORIGIN\}"
206-
LINK_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libtriton_tflite.ldscript
207-
LINK_FLAGS "-Wl,--no-as-needed,--version-script libtriton_tflite.ldscript"
210+
LINK_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libtriton_armnn_tflite.ldscript
211+
LINK_FLAGS "-Wl,--no-as-needed,--version-script libtriton_armnn_tflite.ldscript"
208212
)
209213

210214
target_link_libraries(
211-
triton-tflite-backend
215+
triton-armnn-tflite-backend
212216
PRIVATE
213217
triton-core-serverapi # from repo-core
214218
triton-core-backendapi # from repo-core
@@ -220,7 +224,7 @@ target_link_libraries(
220224

221225
if (ARMNN_DELEGATE_ENABLE)
222226
target_link_libraries(
223-
triton-tflite-backend
227+
triton-armnn-tflite-backend
224228
PRIVATE
225229
"-L${ARMNN_LOCATION}/lib" # from armnn
226230
-larmnn
@@ -232,31 +236,31 @@ endif()
232236
# Install
233237
#
234238
include(GNUInstallDirs)
235-
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/TritonTFLiteBackend)
239+
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/TritonArmNNTFLiteBackend)
236240

237241
install(
238242
TARGETS
239-
triton-tflite-backend
243+
triton-armnn-tflite-backend
240244
EXPORT
241-
triton-tflite-backend-targets
242-
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/tflite
243-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/tflite
245+
triton-armnn-tflite-backend-targets
246+
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/armnn_tflite
247+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/armnn_tflite
244248
)
245249

246250
if (ARMNN_DELEGATE_ENABLE)
247251
# Install ArmNN libraries and license
248252
install(
249253
DIRECTORY
250254
${ARMNN_LOCATION}/lib/
251-
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/tflite
255+
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/armnn_tflite
252256
FILES_MATCHING PATTERN "*.so*"
253257
)
254258

255259
install(
256260
FILES
257261
${ARMNN_LOCATION}/src/armnn/LICENSE
258262
RENAME armnn.LICENSE
259-
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/tflite
263+
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/armnn_tflite
260264
)
261265
endif()
262266

@@ -265,40 +269,40 @@ install(
265269
FILES
266270
${CMAKE_CURRENT_BINARY_DIR}/_deps/tensorflow-lite-src/LICENSE
267271
RENAME tensorflow.LICENSE
268-
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/tflite
272+
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/armnn_tflite
269273
)
270274

271275
install(
272276
EXPORT
273-
triton-tflite-backend-targets
277+
triton-armnn-tflite-backend-targets
274278
FILE
275-
TritonTFLiteBackendTargets.cmake
279+
TritonArmNNTFLiteBackendTargets.cmake
276280
NAMESPACE
277-
TritonTFLiteBackend::
281+
TritonArmNNTFLiteBackend::
278282
DESTINATION
279283
${INSTALL_CONFIGDIR}
280284
)
281285

282286
include(CMakePackageConfigHelpers)
283287
configure_package_config_file(
284-
${CMAKE_CURRENT_LIST_DIR}/cmake/TritonTFLiteBackendConfig.cmake.in
285-
${CMAKE_CURRENT_BINARY_DIR}/TritonTFLiteBackendConfig.cmake
288+
${CMAKE_CURRENT_LIST_DIR}/cmake/TritonArmNNTFLiteBackendConfig.cmake.in
289+
${CMAKE_CURRENT_BINARY_DIR}/TritonArmNNTFLiteBackendConfig.cmake
286290
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
287291
)
288292

289293
install(
290294
FILES
291-
${CMAKE_CURRENT_BINARY_DIR}/TritonTFLiteBackendConfig.cmake
295+
${CMAKE_CURRENT_BINARY_DIR}/TritonArmNNTFLiteBackendConfig.cmake
292296
DESTINATION ${INSTALL_CONFIGDIR}
293297
)
294298

295299
#
296300
# Export from build tree
297301
#
298302
export(
299-
EXPORT triton-tflite-backend-targets
300-
FILE ${CMAKE_CURRENT_BINARY_DIR}/TritonTFLiteBackendTargets.cmake
301-
NAMESPACE TritonTFLiteBackend::
303+
EXPORT triton-armnn-tflite-backend-targets
304+
FILE ${CMAKE_CURRENT_BINARY_DIR}/TritonArmNNTFLiteBackendTargets.cmake
305+
NAMESPACE TritonArmNNTFLiteBackend::
302306
)
303307

304-
export(PACKAGE TritonTFLiteBackend)
308+
export(PACKAGE TritonArmNNTFLiteBackend)

Dockerfile

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=20.04
22

3-
FROM ubuntu:${UBUNTU_VERSION} as tflite_backend
3+
FROM ubuntu:${UBUNTU_VERSION} as armnn_tflite_backend
44

55
# Triton version pins, assumed same across backend, core, and common
66
ARG TRITON_REPO_TAG=main
@@ -12,18 +12,18 @@ ENV DEBIAN_FRONTEND=noninteractive
1212

1313
RUN apt-get update && \
1414
apt-get install -yqq --no-install-recommends \
15-
git \
16-
wget \
17-
scons \
18-
ca-certificates \
19-
curl \
20-
autoconf \
21-
libtool \
22-
build-essential \
23-
libssl-dev \
24-
xxd \
25-
rapidjson-dev \
26-
unzip
15+
git \
16+
wget \
17+
scons \
18+
ca-certificates \
19+
curl \
20+
autoconf \
21+
libtool \
22+
build-essential \
23+
libssl-dev \
24+
xxd \
25+
rapidjson-dev \
26+
unzip
2727

2828
# Install cmake from source
2929
RUN build=1 && \
@@ -36,18 +36,19 @@ RUN build=1 && \
3636
make -j$(nproc) && \
3737
make install
3838

39-
# Build TFLite Backend
40-
WORKDIR /opt/tflite_backend
39+
# Build ArmNN TFLite Backend
40+
WORKDIR /opt/armnn_tflite_backend
4141
COPY . .
4242
RUN mkdir build && \
4343
cd build && \
4444
cmake .. \
45-
-DCMAKE_INSTALL_PREFIX:PATH=`pwd`/install \
46-
-DTRITON_BACKEND_REPO_TAG=${TRITON_REPO_TAG} \
47-
-DTRITON_CORE_REPO_TAG=${TRITON_REPO_TAG} \
48-
-DTRITON_COMMON_REPO_TAG=${TRITON_REPO_TAG} \
49-
-DTRITON_ENABLE_GPU=OFF \
50-
-DTRITON_ENABLE_MALI_GPU=ON \
51-
-DJOBS=$(nproc) \
45+
-DCMAKE_INSTALL_PREFIX:PATH=`pwd`/install \
46+
-DTRITON_BACKEND_REPO_TAG=${TRITON_REPO_TAG} \
47+
-DTRITON_CORE_REPO_TAG=${TRITON_REPO_TAG} \
48+
-DTRITON_COMMON_REPO_TAG=${TRITON_REPO_TAG} \
49+
-DTRITON_ENABLE_GPU=OFF \
50+
-DTRITON_ENABLE_MALI_GPU=ON \
51+
-DTFLITE_ENABLE_RUY=ON \
52+
-DJOBS=$(nproc) \
5253
&& \
5354
make -j$(nproc) install

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# TFLite Backend
1+
# ArmNN TFLite Backend
22

3-
The Triton backend for [TFLite](https://www.tensorflow.org/lite).
3+
The Triton backend for [TFLite](https://www.tensorflow.org/lite) with support for ArmNN acceleration.
44
You can learn more about Triton backends in the [backend
55
repo](https://github.com/triton-inference-server/backend). Ask
66
questions or report problems on the [issues
@@ -12,15 +12,15 @@ This backend was developed using the existing [Triton PyTorch Backend](https://g
1212

1313
This backend is only currently available for **linux arm64** platforms.
1414

15-
## Build the TFLite Backend
16-
The TFLite backend can be built either integrated with the build process for the [triton server repo](https://github.com/triton-inference-server/server) or it may be built independently using only this repository.
15+
## Build the ArmNN TFLite Backend
16+
The ArmNN TFLite backend can be built either integrated with the build process for the [triton server repo](https://github.com/triton-inference-server/server) or it may be built independently using only this repository.
1717

1818
### Build with Triton Build Convenience Script
19-
The easiest way to get up and running with the triton tflite backend is to build a custom triton docker image using the `build.py` script available in the triton server repo.
19+
The easiest way to get up and running with the triton armnn tflite backend is to build a custom triton docker image using the `build.py` script available in the triton server repo.
2020

21-
To build a triton server docker image with the tflite backend built in simply run the following command from the root of the server repo:
21+
To build a triton server docker image with the armnn tflite backend built in simply run the following command from the root of the server repo:
2222
```bash
23-
./build.py --cmake-dir=/workspace/build --build-dir=/tmp/citritonbuild --target-platform=ubuntu/arm64 --enable-logging --enable-stats --enable-tracing --enable-metrics --endpoint=http --endpoint=grpc --backend=tflite
23+
./build.py --cmake-dir=/workspace/build --build-dir=/tmp/citritonbuild --target-platform=ubuntu/arm64 --enable-logging --enable-stats --enable-tracing --enable-metrics --endpoint=http --endpoint=grpc --backend=armnn_tflite
2424
```
2525

2626
### Build Independently with CMake
@@ -142,11 +142,9 @@ optimization { execution_accelerators {
142142
parameters { key: "reduce_fp32_to_fp16" value: "<on/off>" }
143143
parameters { key: "reduce_fp32_to_bf16" value: "<on/off>" }
144144
parameters { key: "fast_math_enabled" value: "<on/off>" }
145-
parameters { key: "tuning_level" value: "<0-3>" }
146145
}]
147146
}}
148147
```
149-
Note that for MALI GPU tuning level the value corresponds to the following: `(0=UseOnly(default) | 1=RapidTuning | 2=NormalTuning | 3=ExhaustiveTuning)`
150148

151149
### XNNPACK Delegate Optimization Options
152150
Users also have the ability to specify XNNPACK specific optimizations.
@@ -159,8 +157,8 @@ optimization { execution_accelerators {
159157
}}
160158
```
161159

162-
## Running TFLite Backend on MALI GPU
163-
The best way to run the TFLite backend on a platform with a MALI GPU is via Docker. For example on a hikey 970, we can run the following after building our custom tritonserver image using the command from the build with convenience script above:
160+
## Running ArmNN TFLite Backend on MALI GPU
161+
The best way to run the ArmNN TFLite backend on a platform with a MALI GPU is via Docker. For example on a hikey 970, we can run the following after building our custom tritonserver image using the command from the build with convenience script above:
164162
```
165163
docker run --rm -it --device /dev/mali0 -v /usr/lib/aarch64-linux-gnu/libmali.so:/usr/lib/aarch64-linux-gnu/libmali.so -v <full path to your model repo on host>:/models -p 8000:8000 -p 8001:8001 -p 8002:8002 tritonserver:latest
166164
```

cmake/TritonTFLiteBackendConfig.cmake.in renamed to cmake/TritonArmNNTFLiteBackendConfig.cmake.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
include(CMakeFindDependencyMacro)
2828

2929
get_filename_component(
30-
TRITONTFLITEBACKEND_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH
30+
TRITONARMNNTFLITEBACKEND_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH
3131
)
3232

33-
list(APPEND CMAKE_MODULE_PATH ${TRITONTFLITEBACKEND_CMAKE_DIR})
33+
list(APPEND CMAKE_MODULE_PATH ${TRITONARMNNTFLITEBACKEND_CMAKE_DIR})
3434

35-
if(NOT TARGET TritonTFLiteBackend::triton-tflite-backend)
36-
include("${TRITONTFLITEBACKEND_CMAKE_DIR}/TritonTFLiteBackendTargets.cmake")
35+
if(NOT TARGET TritonArmNNTFLiteBackend::triton-armnn-tflite-backend)
36+
include("${TRITONARMNNTFLITEBACKEND_CMAKE_DIR}/TritonArmNNTFLiteBackendTargets.cmake")
3737
endif()
3838

39-
set(TRITONTFLITEBACKEND_LIBRARIES TritonTFLiteBackend::triton-tflite-backend)
39+
set(TRITONARMNNTFLITEBACKEND_LIBRARIES TritonArmNNTFLiteBackend::triton-armnn-tflite-backend)

patches/acl.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/arm_compute/core/Size2D.h b/arm_compute/core/Size2D.h
2+
index bcd89cb31..03bd1eaee 100644
3+
--- a/arm_compute/core/Size2D.h
4+
+++ b/arm_compute/core/Size2D.h
5+
@@ -41,7 +41,7 @@ public:
6+
* @param[in] w Width of the image or rectangle
7+
* @param[in] h Height of the image or rectangle
8+
*/
9+
- Size2D(size_t w, size_t h)
10+
+ Size2D(size_t w, size_t h) noexcept
11+
: width(w), height(h)
12+
{
13+
}

patches/xnnpack_commit.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ index e5f205c0b0b..df2f7345136 100644
77
xnnpack
88
GIT_REPOSITORY https://github.com/google/xnnpack
99
- GIT_TAG 0af63ab36b899559bd1a92bbc327f8137e53c15c
10-
+ GIT_TAG 4422f106e1aa572e80d69c948c36e01966932fad
10+
+ GIT_TAG be3d8fdffe8eb71b80835f168d4a550bb5d80f12
1111
GIT_PROGRESS TRUE
1212
PREFIX "${CMAKE_BINARY_DIR}"
1313
SOURCE_DIR "${CMAKE_BINARY_DIR}/xnnpack"

qa/config-template.pbtxt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "{{ model.name }}"
2-
backend: "tflite"
2+
backend: "armnn_tflite"
33
max_batch_size: {{ model.max_batch_size }}
44
input [
55
{% for input in model.inputs %}
File renamed without changes.

0 commit comments

Comments
 (0)