@@ -21,6 +21,7 @@ set(TFLITE_TAG "v2.4.1" CACHE STRING "Version of TFLite to build")
2121set (BAZEL_BINARY "/usr/bin/bazel" CACHE STRING "Location of bazel binary on host" )
2222option (TFLITE_BAZEL_BUILD "Build tflite bazel" OFF )
2323option (TFLITE_ENABLE_RUY "Use RUY library in TFLite build" ON )
24+ option (TFLITE_ENABLE_XNNPACK "Build backend with xnnpack delgate support" ON )
2425option (TFLITE_ENABLE_FLEX_OPS "Build tflite with flex ops support (must build with bazel)" OFF )
2526
2627# ArmNN Options
@@ -132,8 +133,6 @@ set(TFLITE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external/tensorflow_lite)
132133
133134if (TFLITE_BAZEL_BUILD)
134135 SET (BAZEL_BUILD_FLAGS
135- "--define=tflite_with_xnnpack=true"
136- "--define=with_select_tf_ops=true"
137136 "--config=monolithic"
138137 "-c" "opt"
139138 )
@@ -144,10 +143,16 @@ if (TFLITE_BAZEL_BUILD)
144143 LIST (APPEND BAZEL_BUILD_FLAGS "--define=tflite_with_ruy=false" )
145144 endif ()
146145
146+ if (TFLITE_ENABLE_XNNPACK)
147+ LIST (APPEND BAZEL_BUILD_FLAGS "--define=tflite_with_xnnpack=true" )
148+ else ()
149+ LIST (APPEND BAZEL_BUILD_FLAGS "--define=tflite_with_xnnpack=false" )
150+ endif ()
151+
147152 if (TFLITE_ENABLE_FLEX_OPS)
148- LIST ( APPEND BAZEL_BUILD_FLAGS "--define=with_select_tf_ops= true" )
153+ SET (TFLITE_PATCH_COMMAND "git" "apply" " ${CMAKE_CURRENT_SOURCE_DIR} /patches/tflite_bazel_build.patch" "||" " true" )
149154 else ()
150- LIST ( APPEND BAZEL_BUILD_FLAGS "--define=with_select_tf_ops=false " )
155+ SET (TFLITE_PATCH_COMMAND " " )
151156 endif ()
152157
153158 if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
@@ -163,7 +168,8 @@ if (TFLITE_BAZEL_BUILD)
163168 GIT_REPOSITORY https://github.com/tensorflow/tensorflow.git
164169 GIT_TAG ${TFLITE_TAG}
165170 GIT_SHALLOW ON
166- PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR} /patches/xnnpack_commit.patch || true # patch updates the commit hash for xnnpack for tensorflow v2.4.1
171+ PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR} /patches/tflite.patch || true # patch updates the commit hash for xnnpack for tensorflow v2.4.1
172+ COMMAND ${TFLITE_PATCH_COMMAND}
167173 CONFIGURE_COMMAND ""
168174 BUILD_COMMAND ${BAZEL_BINARY} build ${BAZEL_BUILD_FLAGS} //tensorflow/lite:libtensorflowlite.so
169175 BUILD_IN_SOURCE ON
0 commit comments