Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow: Fix 2.12.0 URL #23078

Merged
merged 10 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions recipes/tensorflow-lite/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
sources:
"2.12.0":
url: "https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.10.0.tar.gz"
sha256: "b5a1bb04c84b6fe1538377e5a1f649bb5d5f0b2e3625a3c526ff3a8af88633e8"
url: "https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.12.0.tar.gz"
sha256: "c030cb1905bff1d2446615992aad8d8d85cbe90c4fb625cee458c63bf466bc8e"
"2.10.0":
url: "https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.10.0.tar.gz"
sha256: "b5a1bb04c84b6fe1538377e5a1f649bb5d5f0b2e3625a3c526ff3a8af88633e8"
patches:
"2.12.0":
- patch_file: "patches/remove_simple_memory_arena_debug_dump.patch"
- patch_file: "patches/2.12.0-0001-remove_simple_memory_arena_debug_dump.patch"
patch_description: "Shared build fails on Windows with error LNK2005. Resolve the conflict by removing the conflicting implementation for now."
- patch_file: "patches/disable_fetch_content.patch"
patch_type: "conan"
- patch_file: "patches/2.12.0-0002-disable-fetch-content.patch"
patch_description: "Fail if the CMake build script tries to fetch external dependencies"
patch_type: "conan"
- patch_file: "patches/dependencies_2_10.patch"
- patch_file: "patches/2.12.0-0003-use-cci-dependencies.patch"
patch_description: "Dependency compatibility: Patch CMakeLists.txt, updating package names, target names, etc"
patch_type: "conan"
"2.10.0":
- patch_file: "patches/remove_simple_memory_arena_debug_dump.patch"
- patch_file: "patches/2.10.0-0001-remove_simple_memory_arena_debug_dump.patch"
patch_description: "Shared build fails on Windows with error LNK2005. Resolve the conflict by removing the conflicting implementation for now."
- patch_file: "patches/disable_fetch_content.patch"
- patch_file: "patches/2.10.0-0002-disable_fetch_content.patch"
patch_description: "Fail if the CMake build script tries to fetch external dependencies"
patch_type: "conan"

Check warning on line 24 in recipes/tensorflow-lite/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_type' not found in - patch_file: patches/2.10.0-0 ... ^ (line: 22)
- patch_file: "patches/dependencies_2_10.patch"
- patch_file: "patches/2.10.0-0003-use-cci-dependencies.patch"
patch_description: "Dependency compatibility: Patch CMakeLists.txt, updating package names, target names, etc"
patch_type: "conan"
10 changes: 9 additions & 1 deletion recipes/tensorflow-lite/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os

Check warning on line 1 in recipes/tensorflow-lite/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused import os
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import get, save, copy, export_conandata_patches, apply_conandata_patches
from conan.tools.files import get, save, copy, export_conandata_patches, apply_conandata_patches, replace_in_file

Check warning on line 7 in recipes/tensorflow-lite/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused replace_in_file imported from conan.tools.files
from conan.tools.scm import Version
from os.path import join
import textwrap
Expand Down Expand Up @@ -72,6 +73,10 @@
def layout(self):
cmake_layout(self, src_folder="src")

@property
def _needs_fxdiv(self):
return Version(self.version) >= "2.12.0"

def requirements(self):
self.requires("abseil/20230125.3")
self.requires("eigen/3.4.0")
Expand All @@ -88,6 +93,8 @@
self.requires("pthreadpool/cci.20231129")
if self.options.with_xnnpack or self.options.get_safe("with_nnapi", False):
self.requires("fp16/cci.20210320")
if self._needs_fxdiv:
self.requires("fxdiv/cci.20200417")

def validate(self):
if self.settings.get_safe("compiler.cppstd"):
Expand Down Expand Up @@ -151,6 +158,7 @@
def package(self):
copy(self, "LICENSE", self.source_folder, join(self.package_folder, "licenses"))
copy(self, "*.h", join(self.source_folder, "tensorflow", "lite"), join(self.package_folder, "include", "tensorflow", "lite"))
copy(self, "version.h", join(self.source_folder, "tensorflow", "core", "public"), join(self.package_folder, "include", "tensorflow", "core", "public"))
copy(self, "*.a", self.build_folder, join(self.package_folder, "lib"))
copy(self, "*.so", self.build_folder, join(self.package_folder, "lib"))
copy(self, "*.dylib", self.build_folder, join(self.package_folder, "lib"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
index c71a392..7260efe 100644
--- a/tensorflow/lite/CMakeLists.txt
+++ b/tensorflow/lite/CMakeLists.txt
@@ -221,6 +221,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android")
endif()
# Build a list of source files to compile into the TF Lite library.
populate_tflite_source_vars("." TFLITE_SRCS)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND BUILD_SHARED_LIBS)
+ list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*simple_memory_arena_debug_dump\\.cc$")
+endif()

# This particular file is excluded because the more explicit approach to enable
# XNNPACK delegate is preferred to the weak-symbol one.
@@ -654,4 +657,4 @@ target_link_libraries(_pywrap_tensorflow_interpreter_wrapper
target_compile_options(_pywrap_tensorflow_interpreter_wrapper
PUBLIC ${TFLITE_TARGET_PUBLIC_OPTIONS}
PRIVATE ${TFLITE_TARGET_PRIVATE_OPTIONS}
-)
\ No newline at end of file
+)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
index 24b8265..7260efe 100644
--- a/tensorflow/lite/CMakeLists.txt
+++ b/tensorflow/lite/CMakeLists.txt
@@ -657,4 +657,4 @@ target_link_libraries(_pywrap_tensorflow_interpreter_wrapper
target_compile_options(_pywrap_tensorflow_interpreter_wrapper
PUBLIC ${TFLITE_TARGET_PUBLIC_OPTIONS}
PRIVATE ${TFLITE_TARGET_PRIVATE_OPTIONS}
-)
\ No newline at end of file
+)
diff --git a/tensorflow/lite/tools/cmake/modules/OverridableFetchContent.cmake b/tensorflow/lite/tools/cmake/modules/OverridableFetchContent.cmake
index 9ed9510..4a6a45d 100644
--- a/tensorflow/lite/tools/cmake/modules/OverridableFetchContent.cmake
+++ b/tensorflow/lite/tools/cmake/modules/OverridableFetchContent.cmake
@@ -251,6 +251,7 @@ function(OverridableFetchContent_Declare CONTENT_NAME)
URL_HASH
URL_MD5
)
+ message(FATAL_ERROR "OverridableFetchContent_Declare called by ${CONTENT_NAME}! Failing build.")
set(ALL_VALUE_ARGS LICENSE_FILE LICENSE_URL ${OVERRIDABLE_ARGS})
cmake_parse_arguments(ARGS
""
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
index 24b8265..9e0d1e0 100644
--- a/tensorflow/lite/CMakeLists.txt
+++ b/tensorflow/lite/CMakeLists.txt
@@ -142,31 +142,16 @@
find_package(absl REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(farmhash REQUIRED)
-find_package(fft2d REQUIRED)
+find_package(fft REQUIRED)
find_package(Flatbuffers REQUIRED)
find_package(gemmlowp REQUIRED)
-find_package(NEON_2_SSE REQUIRED)
find_package(cpuinfo REQUIRED) #CPUINFO is used by XNNPACK and RUY library
find_package(ruy REQUIRED)
-# Download necessary dependencies.
-# Download pthreadpool source package if it doesn't exist.
-if(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
- message(STATUS "Downloading pthreadpool to ${CMAKE_BINARY_DIR}/pthreadpool-source (define PTHREADPOOL_SOURCE_DIR to avoid it)")
- configure_file(cmake/DownloadPThreadPool.cmake "${CMAKE_BINARY_DIR}/pthreadpool-download/CMakeLists.txt")
- execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pthreadpool-download")
- execute_process(COMMAND "${CMAKE_COMMAND}" --build .
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pthreadpool-download")
- set(PTHREADPOOL_SOURCE_DIR "${CMAKE_BINARY_DIR}/pthreadpool-source" CACHE STRING "pthreadpool source directory")
-endif()
-# Configure pthreadpool
-if(NOT TARGET pthreadpool)
- set(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
- set(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
- set(PTHREADPOOL_ALLOW_DEPRECATED_API OFF CACHE BOOL "")
- add_subdirectory(
- "${PTHREADPOOL_SOURCE_DIR}"
- "${CMAKE_BINARY_DIR}/pthreadpool")
+
+if(TARGET flatbuffers::flatbuffers_shared)
+ set(FLATBUFFERS_TARGET flatbuffers::flatbuffers_shared)
+else()
+ set(FLATBUFFERS_TARGET flatbuffers::flatbuffers)
endif()
set(TF_TARGET_PRIVATE_OPTIONS "")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
@@ -180,6 +165,10 @@
set(TFLITE_TARGET_PRIVATE_DEFINITIONS "")
# Additional library dependencies based upon enabled features.
set(TFLITE_TARGET_DEPENDENCIES "")
+if (NOT CMAKE_SYSTEM_PROCESSOR OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86")
+ find_package(NEON_2_SSE REQUIRED)
+ list(APPEND TFLITE_TARGET_DEPENDENCIES NEON_2_SSE::NEON_2_SSE)
+endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
# TFLite uses deprecated methods in neon2sse which generates a huge number of
# warnings so surpress these until they're fixed.
@@ -429,13 +418,14 @@
endif()
if(TFLITE_ENABLE_XNNPACK)
find_package(fp16_headers REQUIRED)
- find_package(XNNPACK REQUIRED)
+ find_package(xnnpack REQUIRED)
+ find_package(pthreadpool REQUIRED)
populate_tflite_source_vars("delegates/xnnpack"
TFLITE_DELEGATES_XNNPACK_SRCS
FILTER ".*(_test|_tester)\\.(cc|h)"
)
list(APPEND TFLITE_TARGET_DEPENDENCIES
- XNNPACK
+ xnnpack::xnnpack
)
list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DTFLITE_BUILD_WITH_XNNPACK_DELEGATE")
endif()
@@ -492,6 +482,7 @@
TFLITE_KERNEL_INTERNAL_REF_SPARSE_OPS_SRCS
)
set(TFLITE_PROFILER_SRCS
+${TFLITE_SOURCE_DIR}/profiling/telemetry/telemetry.cc
${TFLITE_SOURCE_DIR}/profiling/platform_profiler.cc
${TFLITE_SOURCE_DIR}/profiling/root_profiler.h
${TFLITE_SOURCE_DIR}/profiling/root_profiler.cc
@@ -555,19 +546,18 @@
target_link_libraries(tensorflow-lite
PUBLIC
Eigen3::Eigen
- NEON_2_SSE::NEON_2_SSE
absl::flags
absl::hash
absl::status
absl::strings
absl::synchronization
absl::variant
- farmhash
- fft2d_fftsg2d
- flatbuffers::flatbuffers
- gemmlowp
+ farmhash::farmhash
+ fft::fft
+ ${FLATBUFFERS_TARGET}
+ gemmlowp::eight_bit_int_gemm
ruy::ruy
- pthreadpool
+ pthreadpool::pthreadpool
${CMAKE_DL_LIBS}
${TFLITE_TARGET_DEPENDENCIES}
)
2 changes: 2 additions & 0 deletions recipes/tensorflow-lite/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <tensorflow/lite/version.h>
#include <tensorflow/lite/model.h>
#include <tensorflow/lite/interpreter.h>
#include <tensorflow/lite/kernels/register.h>
Expand All @@ -12,6 +13,7 @@ int main(int argc, char * argv[]) {
std::cerr << "Pass model file path as argument" << std::endl;
return -1;
}
std::cout << "Using TensorFlow Lite version " << TFLITE_VERSION_STRING << std::endl;
auto model = tflite::FlatBufferModel::BuildFromFile(argv[1]);
if (!model) {
throw std::runtime_error("Failed to load TFLite model");
Expand Down
Loading