From cbb9f3640583f78e1520577c5b0c18ca5dfc2010 Mon Sep 17 00:00:00 2001 From: xudandan Date: Mon, 22 Jul 2024 10:18:06 +0800 Subject: [PATCH] armnn: compatible with openEuler baseline * compatible with openEuler baseline Signed-off-by: xudandan --- .oebuild/manifest.yaml | 13 ++ .../arm-compute-library_%.bbappend | 2 +- .../armnn/0002-add-inculde-iterator.patch | 11 ++ .../armnn/0003-change-absl-libs-path.patch | 18 ++ .../recipes-arm/armnn/armnn_%.bbappend | 2 + .../files/change-tools-cmake.patch | 182 ++++++++++++++++++ .../tensorflow-lite_%.bbappend | 19 +- .../tensorflow-lite/tensorflow-lite_2.9.1.bb | 4 +- 8 files changed, 247 insertions(+), 4 deletions(-) create mode 100644 meta-openeuler/recipes-arm/armnn/armnn/0002-add-inculde-iterator.patch create mode 100644 meta-openeuler/recipes-arm/armnn/armnn/0003-change-absl-libs-path.patch create mode 100644 meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/files/change-tools-cmake.patch diff --git a/.oebuild/manifest.yaml b/.oebuild/manifest.yaml index e3fd78bb2b7..15325303c48 100644 --- a/.oebuild/manifest.yaml +++ b/.oebuild/manifest.yaml @@ -2124,3 +2124,16 @@ manifest_list: libvpx: remote_url: https://gitee.com/src-openeuler/libvpx.git version: 0ac414f4f38419207a874f79ce6075335eb19b6d + flatbuffers: + remote_url: https://gitee.com/src-openeuler/flatbuffers.git + version: 482e2ea3dc95339111ce48e1f4ae1ac646ad07b3 + tensorflow: + remote_url: https://gitee.com/src-openeuler/tensorflow.git + version: 887c706f000886f4e44f5855474ef2b24ccd1596 + ComputeLibrary: + remote_url: https://gitee.com/src-openeuler/ComputeLibrary.git + version: 88d32a1e37776d64bdeafe64173b50b73524c135 + armnn: + remote_url: https://gitee.com/src-openeuler/armnn.git + version: 64676572e789604efd056143200b6e4677fb64fc + diff --git a/meta-openeuler/recipes-arm/arm-compute-library/arm-compute-library_%.bbappend b/meta-openeuler/recipes-arm/arm-compute-library/arm-compute-library_%.bbappend index 1c4ad36a0da..9583beb352d 100644 --- a/meta-openeuler/recipes-arm/arm-compute-library/arm-compute-library_%.bbappend +++ b/meta-openeuler/recipes-arm/arm-compute-library/arm-compute-library_%.bbappend @@ -13,7 +13,7 @@ SRC_URI[arm-compute-library.sha256sum] = "2f70f54d84390625222503ea38650c00c49d4b S = "${WORKDIR}/ComputeLibrary-${PV}" -EXTRA_OESCONS = "arch=arm64-v8a extra_cxx_flags="-fPIC -Wno-unused-but-set-variable -Wno-ignored-qualifiers -Wno-noexcept" benchmark_tests=1 validation_tests=0 set_soname=1" +EXTRA_OESCONS = "arch=arm64-v8a extra_cxx_flags="-fPIC -Wno-unused-but-set-variable -Wno-ignored-qualifiers -Wno-noexcept -Wno-strict-overflow -Wno-array-bounds" benchmark_tests=1 validation_tests=0 set_soname=1" EXTRA_OESCONS += "neon=1 opencl=0 embed_kernels=1" EXTRA_OESCONS:remove = "MAXLINELENGTH=2097152" diff --git a/meta-openeuler/recipes-arm/armnn/armnn/0002-add-inculde-iterator.patch b/meta-openeuler/recipes-arm/armnn/armnn/0002-add-inculde-iterator.patch new file mode 100644 index 00000000000..201b5b306cc --- /dev/null +++ b/meta-openeuler/recipes-arm/armnn/armnn/0002-add-inculde-iterator.patch @@ -0,0 +1,11 @@ +diff -uprN a/tests/TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp b/tests/TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp +--- a/tests/TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp 2024-07-17 07:58:32.244108640 +0000 ++++ b/tests/TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp 2024-07-17 07:56:31.949756463 +0000 +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + using namespace armnnTfLiteParser; + using namespace armnn; diff --git a/meta-openeuler/recipes-arm/armnn/armnn/0003-change-absl-libs-path.patch b/meta-openeuler/recipes-arm/armnn/armnn/0003-change-absl-libs-path.patch new file mode 100644 index 00000000000..947fc1e7d38 --- /dev/null +++ b/meta-openeuler/recipes-arm/armnn/armnn/0003-change-absl-libs-path.patch @@ -0,0 +1,18 @@ +diff -urpN a/delegate/cmake/Modules/FindTfLite.cmake b/delegate/cmake/Modules/FindTfLite.cmake +--- a/delegate/cmake/Modules/FindTfLite.cmake 2024-07-21 21:41:44.597112645 +0800 ++++ b/delegate/cmake/Modules/FindTfLite.cmake 2024-07-21 21:40:25.159199380 +0800 +@@ -22,10 +22,10 @@ find_library(TfLite_LIB NAMES "libtensor + # If the static library was found, gather all of its dependencies + 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_abseilstrings_LIB "libabsl_strings.so" ++ PATH ${TFLITE_LIB_ROOT}) ++ find_library(TfLite_abseil_synchronization_LIB "libabsl_synchronization.so" ++ PATH ${TFLITE_LIB_ROOT}) + + + find_library(TfLite_farmhash_LIB "libfarmhash.a" diff --git a/meta-openeuler/recipes-arm/armnn/armnn_%.bbappend b/meta-openeuler/recipes-arm/armnn/armnn_%.bbappend index 0759fdc4ce7..3516a50bad9 100644 --- a/meta-openeuler/recipes-arm/armnn/armnn_%.bbappend +++ b/meta-openeuler/recipes-arm/armnn/armnn_%.bbappend @@ -76,6 +76,8 @@ SRC_URI += " \ file://${BP}.tar.gz \ file://armnn-use-static-libraries.patch \ file://0001-modify-cmake-files.patch \ + file://0002-add-inculde-iterator.patch \ + file://0003-change-absl-libs-path.patch \ " S = "${WORKDIR}/${BP}" diff --git a/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/files/change-tools-cmake.patch b/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/files/change-tools-cmake.patch new file mode 100644 index 00000000000..b4c653117ef --- /dev/null +++ b/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/files/change-tools-cmake.patch @@ -0,0 +1,182 @@ +diff -urpN a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt +--- a/tensorflow/lite/CMakeLists.txt 2024-07-21 14:42:31.900041655 +0000 ++++ b/tensorflow/lite/CMakeLists.txt 2024-07-21 14:48:49.563383581 +0000 +@@ -515,14 +515,14 @@ target_include_directories(tensorflow-li + ) + target_link_libraries(tensorflow-lite + PUBLIC +- Eigen3::Eigen ++ ${Eigen3_LIBRARY} + NEON_2_SSE +- absl::flags +- absl::hash +- absl::status +- absl::strings +- absl::synchronization +- absl::variant ++ absl_flags ++ absl_hash ++ absl_status ++ absl_strings ++ absl_synchronization ++ absl_variant + farmhash + fft2d_fftsg2d + flatbuffers +diff -urpN a/tensorflow/lite/tools/cmake/modules/Findabsl.cmake b/tensorflow/lite/tools/cmake/modules/Findabsl.cmake +--- a/tensorflow/lite/tools/cmake/modules/Findabsl.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/Findabsl.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -15,7 +15,6 @@ + + # grpc uses find_package in CONFIG mode for this package, so override the + # system installation and build from source instead. +-include(abseil-cpp) + if(abseil-cpp_POPULATED) + set(_ABSL_LIBRARY_NAMES + algorithm +diff -urpN a/tensorflow/lite/tools/cmake/modules/abseil-cpp.cmake b/tensorflow/lite/tools/cmake/modules/abseil-cpp.cmake +--- a/tensorflow/lite/tools/cmake/modules/abseil-cpp.cmake 2024-07-21 14:42:31.977042541 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/abseil-cpp.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -22,12 +22,6 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + abseil-cpp +- GIT_REPOSITORY https://github.com/abseil/abseil-cpp +- # Sync with tensorflow/third_party/absl/workspace.bzl +- GIT_TAG 273292d1cfc0a94a65082ee350509af1d113344d +- GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE +- PREFIX "${CMAKE_BINARY_DIR}" + SOURCE_DIR "${CMAKE_BINARY_DIR}/abseil-cpp" + ) + OverridableFetchContent_GetProperties(abseil-cpp) +diff -urpN a/tensorflow/lite/tools/cmake/modules/clog.cmake b/tensorflow/lite/tools/cmake/modules/clog.cmake +--- a/tensorflow/lite/tools/cmake/modules/clog.cmake 2024-07-21 14:42:31.977042541 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/clog.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,11 +21,7 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + clog +- GIT_REPOSITORY https://github.com/pytorch/cpuinfo +- # Sync with tensorflow/third_party/clog/workspace.bzl +- GIT_TAG 5e63739504f0f8e18e941bd63b2d6d42536c7d90 +- GIT_PROGRESS TRUE +- SOURCE_DIR "${CMAKE_BINARY_DIR}/clog" ++ SOURCE_DIR "${CMAKE_BINARY_DIR}/cpuinfo" + ) + OverridableFetchContent_GetProperties(clog) + if(NOT clog_POPULATED) +diff -urpN a/tensorflow/lite/tools/cmake/modules/cpuinfo.cmake b/tensorflow/lite/tools/cmake/modules/cpuinfo.cmake +--- a/tensorflow/lite/tools/cmake/modules/cpuinfo.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/cpuinfo.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,10 +21,6 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + cpuinfo +- GIT_REPOSITORY https://github.com/pytorch/cpuinfo +- # Sync with tensorflow/third_party/cpuinfo/workspace.bzl +- GIT_TAG 5e63739504f0f8e18e941bd63b2d6d42536c7d90 +- GIT_PROGRESS TRUE + SOURCE_DIR "${CMAKE_BINARY_DIR}/cpuinfo" + ) + OverridableFetchContent_GetProperties(cpuinfo) +diff -urpN a/tensorflow/lite/tools/cmake/modules/eigen.cmake b/tensorflow/lite/tools/cmake/modules/eigen.cmake +--- a/tensorflow/lite/tools/cmake/modules/eigen.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/eigen.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,24 +21,18 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + eigen +- GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git +- # Sync with tensorflow/third_party/eigen3/workspace.bzl +- GIT_TAG 0e187141679fdb91da33249d18cb79a011c0e2ea +- # It's not currently (cmake 3.17) possible to shallow clone with a GIT TAG +- # as cmake attempts to git checkout the commit hash after the clone +- # which doesn't work as it's a shallow clone hence a different commit hash. +- # https://gitlab.kitware.com/cmake/cmake/-/issues/17770 +- # GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE +- PREFIX "${CMAKE_BINARY_DIR}" + SOURCE_DIR "${CMAKE_BINARY_DIR}/eigen" +- LICENSE_FILE "COPYING.MPL2" + ) + OverridableFetchContent_GetProperties(eigen) + if(NOT eigen_POPULATED) + OverridableFetchContent_Populate(eigen) + endif() + ++set(EIGEN_SOURCE_DIR "${eigen_SOURCE_DIR}" CACHE PATH ++ "Source directory for the CMake project." ++) ++ ++include_directories(${CMAKE_BINARY_DIR}/eigen) + # Patch Eigen to disable Fortran compiler check for BLAS and LAPACK tests. + if(NOT EIGEN_DISABLED_FORTRAN_COMPILER_CHECK) + file(WRITE "${eigen_SOURCE_DIR}/cmake/language_support.cmake" " +diff -urpN a/tensorflow/lite/tools/cmake/modules/farmhash.cmake b/tensorflow/lite/tools/cmake/modules/farmhash.cmake +--- a/tensorflow/lite/tools/cmake/modules/farmhash.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/farmhash.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,15 +21,6 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + farmhash +- GIT_REPOSITORY https://github.com/google/farmhash +- # Sync with tensorflow/third_party/farmhash/workspace.bzl +- GIT_TAG 0d859a811870d10f53a594927d0d0b97573ad06d +- # It's not currently possible to shallow clone with a GIT TAG +- # as cmake attempts to git checkout the commit hash after the clone +- # which doesn't work as it's a shallow clone hence a different commit hash. +- # https://gitlab.kitware.com/cmake/cmake/-/issues/17770 +- # GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE + SOURCE_DIR "${CMAKE_BINARY_DIR}/farmhash" + ) + OverridableFetchContent_GetProperties(farmhash) +diff -urpN a/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake b/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake +--- a/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,11 +21,6 @@ include(FetchContent) + + OverridableFetchContent_Declare( + flatbuffers +- GIT_REPOSITORY https://github.com/google/flatbuffers +- # Sync with tensorflow/third_party/flatbuffers/workspace.bzl +- GIT_TAG v2.0.6 +- GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE + SOURCE_DIR "${CMAKE_BINARY_DIR}/flatbuffers" + ) + +diff -urpN a/tensorflow/lite/tools/cmake/modules/gemmlowp.cmake b/tensorflow/lite/tools/cmake/modules/gemmlowp.cmake +--- a/tensorflow/lite/tools/cmake/modules/gemmlowp.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/gemmlowp.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,15 +21,6 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + gemmlowp +- GIT_REPOSITORY https://github.com/google/gemmlowp +- # Sync with tensorflow/third_party/gemmlowp/workspace.bzl +- GIT_TAG fda83bdc38b118cc6b56753bd540caa49e570745 +- # It's not currently (cmake 3.17) possible to shallow clone with a GIT TAG +- # as cmake attempts to git checkout the commit hash after the clone +- # which doesn't work as it's a shallow clone hence a different commit hash. +- # https://gitlab.kitware.com/cmake/cmake/-/issues/17770 +- # GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE + SOURCE_DIR "${CMAKE_BINARY_DIR}/gemmlowp" + ) + +diff -urpN a/tensorflow/lite/tools/cmake/modules/ruy.cmake b/tensorflow/lite/tools/cmake/modules/ruy.cmake +--- a/tensorflow/lite/tools/cmake/modules/ruy.cmake 2024-07-21 14:42:31.978042552 +0000 ++++ b/tensorflow/lite/tools/cmake/modules/ruy.cmake 2024-07-21 14:48:49.557383512 +0000 +@@ -21,10 +21,6 @@ include(OverridableFetchContent) + + OverridableFetchContent_Declare( + ruy +- GIT_REPOSITORY https://github.com/google/ruy +- # Sync with tensorflow/third_party/ruy/workspace.bzl +- GIT_TAG 841ea4172ba904fe3536789497f9565f2ef64129 +- GIT_PROGRESS TRUE + SOURCE_DIR "${CMAKE_BINARY_DIR}/ruy" + ) + OverridableFetchContent_GetProperties(ruy) diff --git a/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_%.bbappend b/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_%.bbappend index ced7a21b6c9..8536c4d7d2f 100644 --- a/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_%.bbappend +++ b/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_%.bbappend @@ -4,7 +4,7 @@ PV = "2.10.0" OPENEULER_REPO_NAME = "tensorflow" -DEPENDS:remove = "libgfortran" +DEPENDS:remove:libc-musl = "libgfortran" SRC_URI:remove = " \ file://fix-to-cmake-2.9.1.patch \ @@ -13,7 +13,11 @@ SRC_URI:remove = " \ SRC_URI = " \ file://tensorflow-${PV}.tar.gz \ + file://external.tar.bz2.partaa \ + file://external.tar.bz2.partab \ + file://external.tar.bz2.partac \ file://modify-deps-on-libclang-gcsfs-gast.patch \ + file://change-tools-cmake.patch \ " @@ -21,6 +25,19 @@ S = "${WORKDIR}/tensorflow-${PV}" EXTRA_OECMAKE:append = " -DTFLITE_ENABLE_XNNPACK=OFF " +DEPENDS += " \ + abseil-cpp \ +" + +do_configure:prepend() { + cat ${WORKDIR}/external.tar.* | tar -xvjf - -C ${WORKDIR}/ + mv ${WORKDIR}/external/eigen_archive ${WORKDIR}/build/eigen + mv ${WORKDIR}/external/farmhash_archive ${WORKDIR}/build/farmhash + mv ${WORKDIR}/external/gemmlowp ${WORKDIR}/build/gemmlowp + mv ${WORKDIR}/external/cpuinfo ${WORKDIR}/build/cpuinfo + mv ${WORKDIR}/external/ruy ${WORKDIR}/build/ruy + mv ${WORKDIR}/external/flatbuffers ${WORKDIR}/build/flatbuffers +} do_install() { # install libraries diff --git a/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_2.9.1.bb b/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_2.9.1.bb index 54c9581eda1..01c29a7770f 100644 --- a/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_2.9.1.bb +++ b/meta-openeuler/recipes-tensorflow-lite/tensorflow-lite/tensorflow-lite_2.9.1.bb @@ -48,8 +48,8 @@ do_install() { s:@includedir@:${includedir}:g' ${D}${libdir}/pkgconfig/tensorflow2-lite.pc # flatbuffers - install -d ${D}${includedir}/flatbuffers - install -m 0644 ${B}/flatbuffers/include/flatbuffers/*.h ${D}${includedir}/flatbuffers/ +# install -d ${D}${includedir}/flatbuffers +# install -m 0644 ${B}/flatbuffers/include/flatbuffers/*.h ${D}${includedir}/flatbuffers/ } ALLOW_EMPTY:${PN} = "1" -- Gitee