From 718966fea8863edb0f91218cb28aeb32d17cb9c7 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Mon, 10 Oct 2022 10:06:12 +0100 Subject: IVGCVSW-7126 Update Arm NN to Tensorflow 2.10 * Modify get_tensorflow.sh to point to the 2.10 Tensorflow tag. * Modify FindTfLite.cmake to handle the break up of libruy.a * Modify armnn_delegate.cpp to add registration_external field. * Prevent the serializer/deserializer from using a system installed version of flatc. Signed-off-by: Colm Donelan Change-Id: I688f33f387924ba29bf400f60e56f73b2329fdc1 --- delegate/CMakeLists.txt | 2 +- delegate/cmake/Modules/FindTfLite.cmake | 95 +++++++++++++++++++++++++++++++-- delegate/src/armnn_delegate.cpp | 1 + scripts/get_tensorflow.sh | 4 +- src/armnnDeserializer/CMakeLists.txt | 6 +++ src/armnnSerializer/CMakeLists.txt | 6 +++ 6 files changed, 107 insertions(+), 7 deletions(-) diff --git a/delegate/CMakeLists.txt b/delegate/CMakeLists.txt index 641e8c7157..847a8a0be5 100644 --- a/delegate/CMakeLists.txt +++ b/delegate/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required (VERSION 3.7.0) project(armnnDelegate) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion -Wno-comment") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") diff --git a/delegate/cmake/Modules/FindTfLite.cmake b/delegate/cmake/Modules/FindTfLite.cmake index 907c3847cb..22c583a323 100644 --- a/delegate/cmake/Modules/FindTfLite.cmake +++ b/delegate/cmake/Modules/FindTfLite.cmake @@ -24,22 +24,109 @@ if (TfLite_LIB MATCHES .a$) message("-- Static tensorflow lite library found, using for ArmNN build") find_library(TfLite_abseilstrings_LIB "libabsl_strings.a" PATH ${TFLITE_LIB_ROOT}/_deps/abseil-cpp-build/absl/strings) + find_library(TfLite_abseil_synchronization_LIB "libabsl_synchronization.a" + PATH ${TFLITE_LIB_ROOT}/_deps/abseil-cpp-build/absl/synchronization) + + find_library(TfLite_farmhash_LIB "libfarmhash.a" PATH ${TFLITE_LIB_ROOT}/_deps/farmhash-build) find_library(TfLite_fftsg_LIB "libfft2d_fftsg.a" PATH ${TFLITE_LIB_ROOT}/_deps/fft2d-build) find_library(TfLite_fftsg2d_LIB "libfft2d_fftsg2d.a" PATH ${TFLITE_LIB_ROOT}/_deps/fft2d-build) - find_library(TfLite_ruy_LIB "libruy.a" PATH - ${TFLITE_LIB_ROOT}/_deps/ruy-build) find_library(TfLite_flatbuffers_LIB "libflatbuffers.a" PATH ${TFLITE_LIB_ROOT}/_deps/flatbuffers-build) + find_library(TfLite_cpuinfo_LIB "libcpuinfo.a" PATH + ${TFLITE_LIB_ROOT}/_deps/cpuinfo-build) + find_library(TfLite_clog_LIB "libclog.a" PATH + ${TFLITE_LIB_ROOT}/_deps/clog-build) + + # All remaining libraries are part of libruy. + find_library(TfLite_ruy_allocator_LIB "libruy_allocator.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_apply_multiplier_LIB "libruy_apply_multiplier.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_blocking_counter_LIB "libruy_blocking_counter.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_block_map_LIB "libruy_block_map.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_context_LIB "libruy_context.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_context_get_ctx_LIB "libruy_context_get_ctx.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_cpuinfo_LIB "libruy_cpuinfo.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_ctx_LIB "libruy_ctx.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_denormal_LIB "libruy_denormal.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_frontend_LIB "libruy_frontend.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_have_built_path_for_avx2_fma_LIB "libruy_have_built_path_for_avx2_fma.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_have_built_path_for_avx512_LIB "libruy_have_built_path_for_avx512.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_have_built_path_for_avx_LIB "libruy_have_built_path_for_avx.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_kernel_arm_LIB "libruy_kernel_arm.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_kernel_avx2_fma_LIB "libruy_kernel_avx2_fma.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_kernel_avx512_LIB "libruy_kernel_avx512.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_kernel_avx_LIB "libruy_kernel_avx.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_pack_arm_LIB "libruy_pack_arm.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_pack_avx2_fma_LIB "libruy_pack_avx2_fma.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_pack_avx512_LIB "libruy_pack_avx512.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_pack_avx_LIB "libruy_pack_avx.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_prepacked_cache_LIB "libruy_prepacked_cache.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_prepare_packed_matrices_LIB "libruy_prepare_packed_matrices.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_system_aligned_alloc_LIB "libruy_system_aligned_alloc.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_threadpool_LIB "libruy_thread_pool.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_trmul_LIB "libruy_trmul.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_tune_LIB "libruy_tune.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_wait_LIB "libruy_wait.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy) + find_library(TfLite_ruy_profiler_LIB "libruy_profiler_instrumentation.a" PATH + ${TFLITE_LIB_ROOT}/_deps/ruy-build/ruy/profiler) ## Set TFLITE_FOUND if all libraries are satisfied for static lib - find_package_handle_standard_args(TfLite DEFAULT_MSG TfLite_LIB TfLite_abseilstrings_LIB TfLite_ruy_LIB TfLite_fftsg_LIB TfLite_fftsg2d_LIB TfLite_farmhash_LIB TfLite_flatbuffers_LIB) + find_package_handle_standard_args(TfLite DEFAULT_MSG TfLite_LIB TfLite_abseilstrings_LIB TfLite_farmhash_LIB TfLite_fftsg_LIB TfLite_fftsg2d_LIB + TfLite_flatbuffers_LIB TfLite_ruy_allocator_LIB TfLite_ruy_apply_multiplier_LIB TfLite_ruy_blocking_counter_LIB + TfLite_ruy_block_map_LIB TfLite_ruy_context_LIB TfLite_ruy_context_get_ctx_LIB TfLite_ruy_cpuinfo_LIB + TfLite_ruy_ctx_LIB TfLite_ruy_denormal_LIB TfLite_ruy_frontend_LIB TfLite_ruy_have_built_path_for_avx2_fma_LIB + TfLite_ruy_have_built_path_for_avx512_LIB TfLite_ruy_have_built_path_for_avx_LIB TfLite_ruy_kernel_arm_LIB + TfLite_ruy_kernel_avx2_fma_LIB TfLite_ruy_kernel_avx512_LIB TfLite_ruy_kernel_avx_LIB TfLite_ruy_pack_arm_LIB + TfLite_ruy_pack_avx2_fma_LIB TfLite_ruy_pack_avx512_LIB TfLite_ruy_pack_avx_LIB TfLite_ruy_prepacked_cache_LIB + TfLite_ruy_prepare_packed_matrices_LIB TfLite_ruy_system_aligned_alloc_LIB TfLite_ruy_threadpool_LIB + TfLite_ruy_trmul_LIB TfLite_ruy_tune_LIB TfLite_ruy_wait_LIB TfLite_ruy_profiler_LIB TfLite_cpuinfo_LIB TfLite_clog_LIB + TfLite_abseil_synchronization_LIB) # Set external variables for usage in CMakeLists.txt if (TFLITE_FOUND) - set(TfLite_LIB ${TfLite_LIB} ${TfLite_abseilstrings_LIB} ${TfLite_ruy_LIB} ${TfLite_fftsg_LIB} ${TfLite_fftsg2d_LIB} ${TfLite_farmhash_LIB} ${TfLite_flatbuffers_LIB}) + # WARNING! The order of these libraries is critical. Moving them + # around will result in linker errors in DelegateUnitTests. + set(TfLite_LIB ${TfLite_LIB} ${TfLite_abseilstrings_LIB} ${TfLite_farmhash_LIB} ${TfLite_fftsg_LIB} ${TfLite_fftsg2d_LIB} ${TfLite_ruy_threadpool_LIB} + ${TfLite_flatbuffers_LIB} ${TfLite_ruy_allocator_LIB} ${TfLite_ruy_apply_multiplier_LIB} ${TfLite_ruy_blocking_counter_LIB} + ${TfLite_ruy_frontend_LIB} ${TfLite_ruy_trmul_LIB} ${TfLite_ruy_block_map_LIB} ${TfLite_ruy_context_LIB} + ${TfLite_ruy_context_get_ctx_LIB} ${TfLite_ruy_cpuinfo_LIB} ${TfLite_ruy_ctx_LIB} ${TfLite_ruy_denormal_LIB} + ${TfLite_ruy_have_built_path_for_avx2_fma_LIB} ${TfLite_ruy_have_built_path_for_avx512_LIB} + ${TfLite_ruy_have_built_path_for_avx_LIB} ${TfLite_ruy_kernel_arm_LIB} ${TfLite_ruy_kernel_avx2_fma_LIB} + ${TfLite_ruy_kernel_avx512_LIB} ${TfLite_ruy_kernel_avx_LIB} ${TfLite_ruy_pack_arm_LIB} + ${TfLite_ruy_pack_avx2_fma_LIB} ${TfLite_ruy_pack_avx512_LIB} ${TfLite_ruy_pack_avx_LIB} ${TfLite_ruy_prepacked_cache_LIB} + ${TfLite_ruy_prepare_packed_matrices_LIB} ${TfLite_ruy_system_aligned_alloc_LIB} + ${TfLite_ruy_tune_LIB} ${TfLite_ruy_wait_LIB} ${TfLite_ruy_profiler_LIB} + ${TfLite_cpuinfo_LIB} ${TfLite_clog_LIB} ${TfLite_abseil_synchronization_LIB}) endif () elseif (TfLite_LIB MATCHES .so$) message("-- Dynamic tensorflow lite library found, using for ArmNN build") diff --git a/delegate/src/armnn_delegate.cpp b/delegate/src/armnn_delegate.cpp index 21c66fe706..4e99335d16 100644 --- a/delegate/src/armnn_delegate.cpp +++ b/delegate/src/armnn_delegate.cpp @@ -119,6 +119,7 @@ TfLiteStatus DoPrepare(TfLiteContext* tfLiteContext, TfLiteDelegate* tfLiteDeleg .builtin_code = kTfLiteBuiltinDelegate, .custom_name = "TfLiteArmNnDelegate", .version = 1, + .registration_external = nullptr, }; const TfLiteStatus status = diff --git a/scripts/get_tensorflow.sh b/scripts/get_tensorflow.sh index 636dddcaf4..9bd6f5b20c 100755 --- a/scripts/get_tensorflow.sh +++ b/scripts/get_tensorflow.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +# Copyright © 2022 Arm Ltd and Contributors. All rights reserved. # # SPDX-License-Identifier: MIT # @@ -8,7 +8,7 @@ CMD=$( basename "$0" ) # Revision or tag that Arm NN has been tested with: -DEFAULT_TENSORFLOW_REVISION="tags/v2.5.0" # Release 2.5.0 tag +DEFAULT_TENSORFLOW_REVISION="tags/v2.10.0" # Release 2.10.0 tag Usage() { echo "Gets the revision or tag of TensorFlow that this version of Arm NN has been" diff --git a/src/armnnDeserializer/CMakeLists.txt b/src/armnnDeserializer/CMakeLists.txt index 7ba83aae1e..630eb370df 100755 --- a/src/armnnDeserializer/CMakeLists.txt +++ b/src/armnnDeserializer/CMakeLists.txt @@ -3,11 +3,17 @@ # SPDX-License-Identifier: MIT # if(BUILD_ARMNN_DESERIALIZER) + # We're using NO_SYSTEM_ENVIRONMENT_PATH to prevent a system installed + # flatc being found and used. find_program(FLATC flatc HINTS ${FLATC_DIR} + NO_SYSTEM_ENVIRONMENT_PATH DOC "Path to 'flatc', the flatbuffers compiler") + if (NOT FLATC) message(SEND_ERROR "flatc not found. Specify the full path of the flatc executable with -DFLATC=") + else() + message("Using flatc was from: ${FLATC}") endif() add_custom_command( diff --git a/src/armnnSerializer/CMakeLists.txt b/src/armnnSerializer/CMakeLists.txt index 919a68bd0e..b7e65ad090 100755 --- a/src/armnnSerializer/CMakeLists.txt +++ b/src/armnnSerializer/CMakeLists.txt @@ -3,11 +3,17 @@ # SPDX-License-Identifier: MIT # if(BUILD_ARMNN_SERIALIZER) + # We're using NO_SYSTEM_ENVIRONMENT_PATH to prevent a system installed + # flatc being found and used. find_program(FLATC flatc HINTS ${FLATC_DIR} + NO_SYSTEM_ENVIRONMENT_PATH DOC "Path to 'flatc', the flatbuffers compiler") + if (NOT FLATC) message(SEND_ERROR "flatc not found. Specify the full path of the flatc executable with -DFLATC=") + else() + message("Using flatc was from: ${FLATC}") endif() add_custom_command( -- cgit v1.2.1