From 6c83964fe940fa28639c59ac485caf5bdaa5cbcf Mon Sep 17 00:00:00 2001 From: luncliff Date: Sat, 7 Sep 2024 23:33:12 +0900 Subject: [PATCH 1/5] [tensorflow-lite] update to v2.17.0, change patches --- ports/tensorflow-lite/fix-cmake-c-api.patch | 8 +- ports/tensorflow-lite/fix-cmake-vcpkg.patch | 119 +++++++------- .../fix-source-apple-opencl.patch | 148 ------------------ ports/tensorflow-lite/portfile.cmake | 35 ++++- ports/tensorflow-lite/vcpkg.json | 2 +- 5 files changed, 97 insertions(+), 215 deletions(-) delete mode 100644 ports/tensorflow-lite/fix-source-apple-opencl.patch diff --git a/ports/tensorflow-lite/fix-cmake-c-api.patch b/ports/tensorflow-lite/fix-cmake-c-api.patch index 026b6c27..e2697ed8 100644 --- a/ports/tensorflow-lite/fix-cmake-c-api.patch +++ b/ports/tensorflow-lite/fix-cmake-c-api.patch @@ -1,8 +1,8 @@ diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt -index a61f5373..338d958d 100644 +index b646abf5..0e27bc00 100644 --- a/tensorflow/lite/CMakeLists.txt +++ b/tensorflow/lite/CMakeLists.txt -@@ -661,6 +661,34 @@ target_compile_options(tensorflow-lite +@@ -701,6 +701,34 @@ target_compile_definitions(tensorflow-lite ) add_library(${PROJECT_NAME}::tensorflowlite ALIAS tensorflow-lite) @@ -11,7 +11,7 @@ index a61f5373..338d958d 100644 + ${TFLITE_SOURCE_DIR}/core/c/c_api.cc + ${TFLITE_SOURCE_DIR}/core/c/c_api_experimental.cc + ${TFLITE_SOURCE_DIR}/core/c/common.cc -+ ${TFLITE_SOURCE_DIR}/core/c/registration_external.cc ++ ${TFLITE_SOURCE_DIR}/core/c/operator.cc + c/builtin_op_data.h + c/c_api.h + c/c_api_experimental.h @@ -37,7 +37,7 @@ index a61f5373..338d958d 100644 # The install targets. if(TFLITE_ENABLE_INSTALL) install( -@@ -668,6 +696,7 @@ if(TFLITE_ENABLE_INSTALL) +@@ -708,6 +736,7 @@ if(TFLITE_ENABLE_INSTALL) EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/ports/tensorflow-lite/fix-cmake-vcpkg.patch b/ports/tensorflow-lite/fix-cmake-vcpkg.patch index 4bc170af..d7e0dc1b 100644 --- a/ports/tensorflow-lite/fix-cmake-vcpkg.patch +++ b/ports/tensorflow-lite/fix-cmake-vcpkg.patch @@ -1,10 +1,10 @@ diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt -index a6fba5f3..a3a51d6d 100644 +index b79818f3..b646abf5 100644 --- a/tensorflow/lite/CMakeLists.txt +++ b/tensorflow/lite/CMakeLists.txt -@@ -51,14 +51,6 @@ endif() - set(TF_SOURCE_DIR "${TENSORFLOW_SOURCE_DIR}/tensorflow") +@@ -52,14 +52,6 @@ set(TF_SOURCE_DIR "${TENSORFLOW_SOURCE_DIR}/tensorflow") set(TSL_SOURCE_DIR "${TENSORFLOW_SOURCE_DIR}/third_party/xla/third_party/tsl") + set(XLA_SOURCE_DIR "${TENSORFLOW_SOURCE_DIR}/third_party/xla/") set(TFLITE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}") -set(CMAKE_MODULE_PATH - "${TFLITE_SOURCE_DIR}/tools/cmake/modules" @@ -17,7 +17,7 @@ index a6fba5f3..a3a51d6d 100644 include(GNUInstallDirs) include(CMakeDependentOption) option(TFLITE_ENABLE_INSTALL "Enable install rule" OFF) -@@ -83,7 +75,7 @@ if(TFLITE_KERNEL_TEST AND ${CMAKE_CROSSCOMPILING}) +@@ -84,7 +76,7 @@ if(TFLITE_KERNEL_TEST AND ${CMAKE_CROSSCOMPILING}) endif() endif() @@ -26,21 +26,23 @@ index a6fba5f3..a3a51d6d 100644 set(CMAKE_CXX_STANDARD_REQUIRED ON) set(_TFLITE_ENABLE_RUY "${TFLITE_ENABLE_RUY}") if("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") -@@ -241,6 +233,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android") +@@ -243,6 +235,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Android") ${ANDROID_ANDROID_LIB} ) endif() +if(CMAKE_SYSTEM_NAME MATCHES Windows) # Windows|WindowsStore + list(APPEND TFLITE_TARGET_PRIVATE_DEFINITIONS + _CRT_SECURE_NO_WARNINGS -+ _SILENCE_CXX20_IS_POD_DEPRECATION_WARNING _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING ++ _SILENCE_CXX20_IS_POD_DEPRECATION_WARNING ++ _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING ++ _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING + ) + list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS /Zc:__cplusplus) +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) -@@ -277,8 +277,15 @@ populate_tflite_source_vars("core" TFLITE_CORE_SRCS) +@@ -279,8 +280,15 @@ populate_tflite_source_vars("core" TFLITE_CORE_SRCS) populate_tflite_source_vars( "core/acceleration/configuration" TFLITE_CORE_ACCELERATION_SRCS FILTER "xnnpack_plugin.*" @@ -56,7 +58,7 @@ index a6fba5f3..a3a51d6d 100644 populate_tflite_source_vars("core/api" TFLITE_CORE_API_SRCS) populate_tflite_source_vars("core/async" TFLITE_CORE_ASYNC_SRCS) populate_tflite_source_vars("core/async/c" TFLITE_CORE_ASYNC_C_SRCS) -@@ -294,13 +301,16 @@ populate_tflite_source_vars("core/async/interop/c" TFLITE_CORE_ASYNC_INTEROP_C_S +@@ -296,13 +304,16 @@ populate_tflite_source_vars("core/async/interop/c" TFLITE_CORE_ASYNC_INTEROP_C_S populate_tflite_source_vars("delegates/utils" TFLITE_DELEGATES_UTILS_SRCS) populate_tflite_source_vars("async" TFLITE_ASYNC_SRCS) if(TFLITE_ENABLE_GPU) @@ -78,24 +80,16 @@ index a6fba5f3..a3a51d6d 100644 endif() populate_tflite_source_vars( "delegates/gpu/cl" TFLITE_DELEGATES_GPU_CL_SRCS -@@ -381,11 +391,15 @@ if(TFLITE_ENABLE_GPU) - ${TFLITE_SOURCE_DIR}/delegates/gpu/common - ${TFLITE_SOURCE_DIR}/delegates/gpu/common/task - ) -- if(TFLITE_ENABLE_METAL AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") -+ if(TFLITE_ENABLE_METAL AND APPLE) - # +@@ -388,6 +399,8 @@ if(TFLITE_ENABLE_GPU) # libmetal_delegate library # enable_language(OBJCXX) -+ # Enforce source language with the compiler's option -+ cmake_policy(SET CMP0119 NEW) -+ # Xcode will apply -fobjc-arc -+ set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") ++ cmake_policy(SET CMP0119 NEW) # Enforce source language with the compiler's option ++ set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") # Xcode will apply -fobjc-arc list(APPEND TFLITE_DELEGATES_METAL_SRCS ${TFLITE_SOURCE_DIR}/delegates/gpu/metal_delegate.mm ${TFLITE_SOURCE_DIR}/delegates/gpu/metal/buffer.cc -@@ -400,11 +414,11 @@ if(TFLITE_ENABLE_GPU) +@@ -402,11 +415,11 @@ if(TFLITE_ENABLE_GPU) add_library(metal_delegate STATIC ${TFLITE_DELEGATES_METAL_SRCS} ) @@ -112,10 +106,13 @@ index a6fba5f3..a3a51d6d 100644 # # generate flatbuffers header for inference_context # -@@ -439,15 +453,11 @@ if(TFLITE_ENABLE_GPU) - SET(METAL_DELEGATE_PATH ${TFLITE_SOURCE_DIR}/delegates/gpu/metal/) - - foreach(lib_name ${CC_SRCS}) +@@ -438,40 +451,39 @@ if(TFLITE_ENABLE_GPU) + metal_device + metal_spatial_tensor + ) +- SET(METAL_DELEGATE_PATH ${TFLITE_SOURCE_DIR}/delegates/gpu/metal/) +- +- foreach(lib_name ${CC_SRCS}) - set_source_files_properties(${METAL_DELEGATE_PATH}${lib_name}.cc PROPERTIES LANGUAGE OBJCXX) - add_library("${lib_name}" STATIC ${METAL_DELEGATE_PATH}${lib_name}.cc) - target_include_directories("${lib_name}" PUBLIC @@ -125,26 +122,40 @@ index a6fba5f3..a3a51d6d 100644 - set_target_properties(${lib_name} PROPERTIES LINKER_LANGUAGE OBJCXX) - target_link_libraries(${lib_name}) - endforeach() -+ add_library(${lib_name} STATIC ${METAL_DELEGATE_PATH}${lib_name}.cc) -+ target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) -+ set_target_properties(${lib_name} PROPERTIES LINKER_LANGUAGE OBJCXX) # requires CMP0119 -+ target_link_libraries(${lib_name} PUBLIC absl::status flatbuffers::flatbuffers) -+ endforeach() - - list(APPEND MM_SRCS - buffer_convert -@@ -455,21 +465,21 @@ if(TFLITE_ENABLE_GPU) - ) - foreach(lib_name ${MM_SRCS}) - add_library("${lib_name}" STATIC ${METAL_DELEGATE_PATH}${lib_name}.mm) +- +- list(APPEND MM_SRCS +- buffer_convert +- common +- ) +- foreach(lib_name ${MM_SRCS}) +- add_library("${lib_name}" STATIC ${METAL_DELEGATE_PATH}${lib_name}.mm) - target_include_directories("${lib_name}" PUBLIC - ${CMAKE_BINARY_DIR}/abseil-cpp - ${CMAKE_BINARY_DIR}/flatbuffers/include - ) - target_link_libraries(${lib_name}) -+ target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) -+ target_link_libraries(${lib_name} PUBLIC absl::status flatbuffers::flatbuffers) - endforeach() +- endforeach() ++ SET(METAL_DELEGATE_PATH ${TFLITE_SOURCE_DIR}/delegates/gpu/metal/) ++ ++ foreach(lib_name ${CC_SRCS}) ++ add_library(${lib_name} STATIC ${METAL_DELEGATE_PATH}${lib_name}.cc) ++ target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) ++ set_target_properties(${lib_name} PROPERTIES LINKER_LANGUAGE OBJCXX) # requires CMP0119 ++ target_link_libraries(${lib_name} PUBLIC absl::status flatbuffers::flatbuffers) ++ endforeach() ++ ++ list(APPEND MM_SRCS ++ buffer_convert ++ common ++ ) ++ foreach(lib_name ${MM_SRCS}) ++ add_library("${lib_name}" STATIC ${METAL_DELEGATE_PATH}${lib_name}.mm) ++ target_include_directories("${lib_name}" PUBLIC ++ target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) ++ target_link_libraries(${lib_name} PUBLIC absl::status flatbuffers::flatbuffers) ++ ) ++ target_link_libraries(${lib_name}) ++ endforeach() endif() list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DCL_DELEGATE_NO_GL" "-DEGL_NO_X11") - list(APPEND TFLITE_TARGET_DEPENDENCIES @@ -162,7 +173,7 @@ index a6fba5f3..a3a51d6d 100644 populate_tflite_source_vars("delegates/nnapi" TFLITE_DELEGATES_NNAPI_SRCS FILTER "(_test_list|_disabled)\\.(cc|h)$" -@@ -479,8 +488,18 @@ if(_TFLITE_ENABLE_NNAPI) +@@ -481,8 +493,18 @@ if(_TFLITE_ENABLE_NNAPI) ) list(APPEND TFLITE_NNAPI_SRCS @@ -171,7 +182,7 @@ index a6fba5f3..a3a51d6d 100644 "${TFLITE_SOURCE_DIR}/nnapi/sl/SupportLibrary.cc" ) + # tsl::mutex requires nsync_cpp -+ find_library(NSYNC_LIBRARY NAMES nsync_cpp REQUIRED) ++ find_package(nsync_cpp CONFIG REQUIRED) + list(APPEND TFLITE_TARGET_DEPENDENCIES ${NSYNC_LIBRARY}) + + # disable ml_dtypes/float8.h which requries libeigen3 master branch ... @@ -181,7 +192,7 @@ index a6fba5f3..a3a51d6d 100644 if(${TFLITE_ENABLE_NNAPI_VERBOSE_VALIDATION}) list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DNNAPI_VERBOSE_VALIDATION") -@@ -494,14 +513,14 @@ else() +@@ -496,14 +518,14 @@ else() ) endif() if(TFLITE_ENABLE_XNNPACK) @@ -199,7 +210,7 @@ index a6fba5f3..a3a51d6d 100644 ) list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DTFLITE_BUILD_WITH_XNNPACK_DELEGATE") list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DXNNPACK_DELEGATE_ENABLE_QS8") -@@ -642,7 +661,7 @@ target_include_directories(tensorflow-lite +@@ -647,7 +669,7 @@ target_include_directories(tensorflow-lite PUBLIC $ $ ) target_link_libraries(tensorflow-lite @@ -208,7 +219,7 @@ index a6fba5f3..a3a51d6d 100644 Eigen3::Eigen absl::flags absl::hash -@@ -656,7 +675,7 @@ target_link_libraries(tensorflow-lite +@@ -661,7 +683,7 @@ target_link_libraries(tensorflow-lite gemmlowp::gemmlowp ml_dtypes ruy::ruy @@ -217,22 +228,20 @@ index a6fba5f3..a3a51d6d 100644 ${CMAKE_DL_LIBS} ${TFLITE_TARGET_DEPENDENCIES} ) -@@ -669,6 +688,11 @@ target_compile_options(tensorflow-lite +@@ -674,6 +696,9 @@ target_compile_options(tensorflow-lite PUBLIC ${TFLITE_TARGET_PUBLIC_OPTIONS} PRIVATE ${TFLITE_TARGET_PRIVATE_OPTIONS} ) -+ +target_compile_definitions(tensorflow-lite + PRIVATE ${TFLITE_TARGET_PRIVATE_DEFINITIONS} +) -+ add_library(${PROJECT_NAME}::tensorflowlite ALIAS tensorflow-lite) - # see tensorflow/lite/c/CMakeLists.txt -@@ -708,6 +732,13 @@ if(TFLITE_ENABLE_INSTALL) - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) + # The install targets. +@@ -693,6 +718,13 @@ if(TFLITE_ENABLE_INSTALL) + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tensorflow/lite/${dir}" + ) + endforeach() + if(NOT BUILD_SHARED_LIBS AND TFLITE_ENABLE_METAL AND APPLE) + install( + TARGETS metal_delegate @@ -241,9 +250,9 @@ index a6fba5f3..a3a51d6d 100644 + ) + endif() - foreach(hdr ${_ALL_TFLITE_HDRS}) - get_filename_component(dir ${hdr} DIRECTORY) -@@ -739,6 +770,7 @@ if(TFLITE_ENABLE_INSTALL) + install( + EXPORT ${PROJECT_NAME}Targets +@@ -715,6 +747,7 @@ if(TFLITE_ENABLE_INSTALL) ) endif() diff --git a/ports/tensorflow-lite/fix-source-apple-opencl.patch b/ports/tensorflow-lite/fix-source-apple-opencl.patch deleted file mode 100644 index b41e5ff1..00000000 --- a/ports/tensorflow-lite/fix-source-apple-opencl.patch +++ /dev/null @@ -1,148 +0,0 @@ -diff --git a/tensorflow/lite/delegates/gpu/cl/cl_operation.h b/tensorflow/lite/delegates/gpu/cl/cl_operation.h -index 63748117..7ff6bb82 100644 ---- a/tensorflow/lite/delegates/gpu/cl/cl_operation.h -+++ b/tensorflow/lite/delegates/gpu/cl/cl_operation.h -@@ -79,6 +79,7 @@ class ClOperation { - operation_->work_group_size_); - } - -+#if defined(cl_khr_command_buffer) - absl::Status AddToCommanBuffer(cl_command_buffer_khr cb) { - RETURN_IF_ERROR(cl_args_.Bind(kernel_.kernel())); - std::array local; -@@ -98,6 +99,7 @@ class ClOperation { - } - return absl::OkStatus(); - } -+#endif - - absl::Status AddToQueue(ProfilingCommandQueue* queue, CLEvent* event) { - RETURN_IF_ERROR(cl_args_.Bind(kernel_.kernel())); -diff --git a/tensorflow/lite/delegates/gpu/cl/inference_context.cc b/tensorflow/lite/delegates/gpu/cl/inference_context.cc -index b1dc7862..24e34114 100644 ---- a/tensorflow/lite/delegates/gpu/cl/inference_context.cc -+++ b/tensorflow/lite/delegates/gpu/cl/inference_context.cc -@@ -319,12 +319,14 @@ absl::Status InferenceContext::InitFromGpuModel( - return absl::OkStatus(); - } - -+#if defined(cl_khr_command_buffer) - absl::Status InferenceContext::AddToCommanBuffer(cl_command_buffer_khr cb) { - for (auto& node : nodes_) { - RETURN_IF_ERROR(node.cl_operation.AddToCommanBuffer(cb)); - } - return absl::OkStatus(); - } -+#endif - - absl::Status InferenceContext::RestoreDeserialized( - const absl::Span serialized_model, Environment* env, -diff --git a/tensorflow/lite/delegates/gpu/cl/inference_context.h b/tensorflow/lite/delegates/gpu/cl/inference_context.h -index e5e883b0..41a655e2 100644 ---- a/tensorflow/lite/delegates/gpu/cl/inference_context.h -+++ b/tensorflow/lite/delegates/gpu/cl/inference_context.h -@@ -74,7 +74,9 @@ class InferenceContext { - Environment* env, std::vector* serialized_model = nullptr, - Buffer* shared_buffer = nullptr); - -+#if defined(cl_khr_command_buffer) - absl::Status AddToCommanBuffer(cl_command_buffer_khr cb); -+#endif - - // Applies OpenCL-specific transformations to the graph before the - // initialization. These transformations are either impossible or useless in -diff --git a/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.cc b/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.cc -index 7bf63235..d3a43129 100644 ---- a/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.cc -+++ b/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.cc -@@ -233,6 +233,7 @@ void LoadOpenCLFunctions(void* libopencl, bool use_wrapper) { - LoadFunction(clEnqueueAcquireEGLObjectsKHR); - LoadFunction(clEnqueueReleaseEGLObjectsKHR); - -+#if defined(cl_khr_command_buffer) - // cl_khr_command_buffer extension - LoadFunction(clCreateCommandBufferKHR); - LoadFunction(clRetainCommandBufferKHR); -@@ -241,6 +242,7 @@ void LoadOpenCLFunctions(void* libopencl, bool use_wrapper) { - LoadFunction(clEnqueueCommandBufferKHR); - LoadFunction(clCommandNDRangeKernelKHR); - LoadFunction(clGetCommandBufferInfoKHR); -+#endif - - LoadQcomExtensionFunctions(); - } -@@ -363,6 +365,7 @@ PFN_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; - PFN_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; - PFN_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; - -+#if defined(cl_khr_command_buffer) - // cl_khr_command_buffer extension - PFN_clCreateCommandBufferKHR clCreateCommandBufferKHR; - PFN_clRetainCommandBufferKHR clRetainCommandBufferKHR; -@@ -371,6 +374,7 @@ PFN_clFinalizeCommandBufferKHR clFinalizeCommandBufferKHR; - PFN_clEnqueueCommandBufferKHR clEnqueueCommandBufferKHR; - PFN_clCommandNDRangeKernelKHR clCommandNDRangeKernelKHR; - PFN_clGetCommandBufferInfoKHR clGetCommandBufferInfoKHR; -+#endif - - DEFINE_QCOM_FUNCTION_PTRS - -diff --git a/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h b/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h -index f946e8e2..54fcc718 100644 ---- a/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h -+++ b/tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h -@@ -522,6 +522,7 @@ typedef cl_int(CL_API_CALL *PFN_clEnqueueReleaseEGLObjectsKHR)( - const cl_mem * /*mem_objects*/, cl_uint /*num_events_in_wait_list*/, - const cl_event * /*event_wait_list*/, cl_event * /*event*/); - -+#if defined(cl_khr_command_buffer) - // cl_khr_command_buffer - typedef cl_command_buffer_khr(CL_API_CALL *PFN_clCreateCommandBufferKHR)( - cl_uint /*num_queues*/, const cl_command_queue * /*queues*/, -@@ -559,6 +560,7 @@ typedef cl_int(CL_API_CALL *PFN_clGetCommandBufferInfoKHR)( - cl_command_buffer_khr /*command_buffer*/, - cl_command_buffer_info_khr /*param_name*/, size_t /*param_value_size*/, - void * /*param_value*/, size_t * /*param_value_size_ret*/); -+#endif - - extern PFN_clGetPlatformIDs clGetPlatformIDs; - extern PFN_clGetPlatformInfo clGetPlatformInfo; -@@ -678,6 +680,7 @@ extern PFN_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; - extern PFN_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; - extern PFN_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; - -+#if defined(cl_khr_command_buffer) - // cl_khr_command_buffer extension - extern PFN_clCreateCommandBufferKHR clCreateCommandBufferKHR; - extern PFN_clRetainCommandBufferKHR clRetainCommandBufferKHR; -@@ -686,6 +689,7 @@ extern PFN_clFinalizeCommandBufferKHR clFinalizeCommandBufferKHR; - extern PFN_clEnqueueCommandBufferKHR clEnqueueCommandBufferKHR; - extern PFN_clCommandNDRangeKernelKHR clCommandNDRangeKernelKHR; - extern PFN_clGetCommandBufferInfoKHR clGetCommandBufferInfoKHR; -+#endif - - // For convenient image creation - // It uses clCreateImage if it available (clCreateImage available since cl 1.2) -diff --git a/tensorflow/lite/delegates/gpu/cl/util.cc b/tensorflow/lite/delegates/gpu/cl/util.cc -index b615a9b6..e61432a5 100644 ---- a/tensorflow/lite/delegates/gpu/cl/util.cc -+++ b/tensorflow/lite/delegates/gpu/cl/util.cc -@@ -152,12 +152,18 @@ std::string CLErrorCodeToString(cl_int error_code) { - return "Invalid device queue"; - case CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: - return "Invalid GL sharegroup reference KHR"; -+#if defined(CL_INVALID_COMMAND_BUFFER_KHR) - case CL_INVALID_COMMAND_BUFFER_KHR: - return "Invalid command buffer KHR"; -+#endif -+#if defined(CL_INVALID_SYNC_POINT_WAIT_LIST_KHR) - case CL_INVALID_SYNC_POINT_WAIT_LIST_KHR: - return "Invalid sync point wait list KHR"; -+#endif -+#if defined(CL_INCOMPATIBLE_COMMAND_QUEUE_KHR) - case CL_INCOMPATIBLE_COMMAND_QUEUE_KHR: - return "Incompatible command queue KHR"; -+#endif - - default: - return absl::StrCat("Unknown OpenCL error code - ", error_code); diff --git a/ports/tensorflow-lite/portfile.cmake b/ports/tensorflow-lite/portfile.cmake index b4df3d9e..408f3d1e 100644 --- a/ports/tensorflow-lite/portfile.cmake +++ b/ports/tensorflow-lite/portfile.cmake @@ -17,16 +17,15 @@ endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO tensorflow/tensorflow - REF v2.16.2 - SHA512 548eb959597bc76b11a94151d0201ee24166744b74317f59bd70611f3e5490863c6f444b38f7d141921b7725cdc62633bf8eacf38b6b71ff50a6431c396fe2d4 + REF v2.17.0 + SHA512 45061f075971cf2bc219a34b1cda2ee9851ba586e94046838e6e1fd26adcfb399d90e71e89a0f709d5282ff3be7cc3a82b81d62dce53db5010640ea41487a469 PATCHES tensorflow-pr-61381.patch tensorflow-pr-62037.patch - fix-cmake-c-api.patch fix-cmake-vcpkg.patch - fix-sources.patch - fix-source-abseil.patch - fix-source-apple-opencl.patch + fix-cmake-c-api.patch + # fix-sources.patch + # fix-source-abseil.patch ) file(REMOVE_RECURSE @@ -73,9 +72,31 @@ vcpkg_execute_required_process( WORKING_DIRECTORY "${ACCELERATION_CONFIGURATION_PATH}" ) -set(SCHEMA_PATH "${TFLITE_SOURCE_DIR}/schema") +set(SCHEMA_PATH "${TFLITE_SOURCE_DIR}/stablehlo/schema") vcpkg_execute_required_process( COMMAND ${FLATC} --cpp --gen-mutable --gen-object-api schema.fbs + LOGNAME codegen-flatc-stablehlo-schema + WORKING_DIRECTORY "${SCHEMA_PATH}" +) + +set(SCHEMA_PATH "${TFLITE_SOURCE_DIR}/schema") +vcpkg_download_distfile(TFLITE_SCHEMA_FBS_PATH + URLS "https://raw.githubusercontent.com/tensorflow/tensorflow/fcbcc19aa91748d2b506048cb450f95792f92254/tensorflow/lite/schema/schema.fbs?full_index=1" + FILENAME tensorflow-schema.fbs + SHA512 574f63957e01bd4ed4810d5218e80768a815b2713da689bb6907ef306546a9126cce77f75bcbd7222ed341fbee8bc11f83dc69d4b7dd7e184f640a2fc46634b8 +) +file(COPY_FILE "${TFLITE_SCHEMA_FBS_PATH}" "${SCHEMA_PATH}/schema.fbs") +vcpkg_execute_required_process( + COMMAND ${FLATC} --cpp --gen-mutable --gen-object-api + schema.fbs + conversion_metadata.fbs + schema_v0.fbs + schema_v1.fbs + schema_v2.fbs + schema_v3.fbs + schema_v3a.fbs + schema_v3b.fbs + schema_v3c.fbs LOGNAME codegen-flatc-schema WORKING_DIRECTORY "${SCHEMA_PATH}" ) diff --git a/ports/tensorflow-lite/vcpkg.json b/ports/tensorflow-lite/vcpkg.json index 6397e625..c8d1b4f2 100644 --- a/ports/tensorflow-lite/vcpkg.json +++ b/ports/tensorflow-lite/vcpkg.json @@ -1,6 +1,6 @@ { "name": "tensorflow-lite", - "version-semver": "2.16.2", + "version-semver": "2.17.0", "description": "Open standard for machine learning interoperability", "homepage": "https://www.tensorflow.org/", "license": "Apache-2.0", From 64ee64cfeff05db20a34ea61274150a093427cad Mon Sep 17 00:00:00 2001 From: luncliff Date: Sat, 7 Sep 2024 23:53:35 +0900 Subject: [PATCH 2/5] [tensorflow-lite] update comments, baseline --- ports/tensorflow-lite/portfile.cmake | 4 +++- versions/baseline.json | 2 +- versions/t-/tensorflow-lite.json | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ports/tensorflow-lite/portfile.cmake b/ports/tensorflow-lite/portfile.cmake index 408f3d1e..2771a981 100644 --- a/ports/tensorflow-lite/portfile.cmake +++ b/ports/tensorflow-lite/portfile.cmake @@ -79,12 +79,14 @@ vcpkg_execute_required_process( WORKING_DIRECTORY "${SCHEMA_PATH}" ) -set(SCHEMA_PATH "${TFLITE_SOURCE_DIR}/schema") +# download schema.fbs from the previous commit +# see https://github.com/tensorflow/tensorflow/tree/v2.17.0/tensorflow/lite/schema vcpkg_download_distfile(TFLITE_SCHEMA_FBS_PATH URLS "https://raw.githubusercontent.com/tensorflow/tensorflow/fcbcc19aa91748d2b506048cb450f95792f92254/tensorflow/lite/schema/schema.fbs?full_index=1" FILENAME tensorflow-schema.fbs SHA512 574f63957e01bd4ed4810d5218e80768a815b2713da689bb6907ef306546a9126cce77f75bcbd7222ed341fbee8bc11f83dc69d4b7dd7e184f640a2fc46634b8 ) +set(SCHEMA_PATH "${TFLITE_SOURCE_DIR}/schema") file(COPY_FILE "${TFLITE_SCHEMA_FBS_PATH}" "${SCHEMA_PATH}/schema.fbs") vcpkg_execute_required_process( COMMAND ${FLATC} --cpp --gen-mutable --gen-object-api diff --git a/versions/baseline.json b/versions/baseline.json index f5abf758..527e0323 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -193,7 +193,7 @@ "port-version": 0 }, "tensorflow-lite": { - "baseline": "2.16.2", + "baseline": "2.17.0", "port-version": 0 }, "tensorpipe": { diff --git a/versions/t-/tensorflow-lite.json b/versions/t-/tensorflow-lite.json index 05c4b71f..4155fceb 100644 --- a/versions/t-/tensorflow-lite.json +++ b/versions/t-/tensorflow-lite.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "161ee8b1833cbbdc6c819c8355d16565bb5ad28a", + "version-semver": "2.17.0", + "port-version": 0 + }, { "git-tree": "e4ac3ef8f3a6358b46088abd311cbdbfe60f4103", "version-semver": "2.16.2", From 667dadcb950c6f0b419dc376c02393ca20b42e43 Mon Sep 17 00:00:00 2001 From: luncliff Date: Sun, 8 Sep 2024 19:04:51 +0900 Subject: [PATCH 3/5] [tensorflow-lite] fix wrong patch sections --- ports/tensorflow-lite/fix-cmake-vcpkg.patch | 13 +++++-------- versions/t-/tensorflow-lite.json | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ports/tensorflow-lite/fix-cmake-vcpkg.patch b/ports/tensorflow-lite/fix-cmake-vcpkg.patch index d7e0dc1b..76363581 100644 --- a/ports/tensorflow-lite/fix-cmake-vcpkg.patch +++ b/ports/tensorflow-lite/fix-cmake-vcpkg.patch @@ -99,14 +99,14 @@ index b79818f3..b646abf5 100644 - PRIVATE ${TENSORFLOW_SOURCE_DIR} - ) + target_include_directories(metal_delegate PRIVATE ${TENSORFLOW_SOURCE_DIR}) -+ target_link_libraries(metal_delegate PUBLIC absl::status flatbuffers::flatbuffers "-framework Foundation" "-framework Metal") ++ target_link_libraries(metal_delegate PUBLIC absl::status absl::strings flatbuffers::flatbuffers "-framework Foundation" "-framework Metal") + # some sources need Objective-C++ types + set_source_files_properties(${TFLITE_DELEGATES_METAL_SRCS} PROPERTIES LANGUAGE OBJCXX) + list(APPEND TFLITE_TARGET_DEPENDENCIES metal_delegate) # # generate flatbuffers header for inference_context # -@@ -438,40 +451,39 @@ if(TFLITE_ENABLE_GPU) +@@ -438,40 +451,36 @@ if(TFLITE_ENABLE_GPU) metal_device metal_spatial_tensor ) @@ -141,7 +141,7 @@ index b79818f3..b646abf5 100644 + add_library(${lib_name} STATIC ${METAL_DELEGATE_PATH}${lib_name}.cc) + target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) + set_target_properties(${lib_name} PROPERTIES LINKER_LANGUAGE OBJCXX) # requires CMP0119 -+ target_link_libraries(${lib_name} PUBLIC absl::status flatbuffers::flatbuffers) ++ target_link_libraries(${lib_name} PUBLIC absl::status absl::strings flatbuffers::flatbuffers) + endforeach() + + list(APPEND MM_SRCS @@ -150,11 +150,8 @@ index b79818f3..b646abf5 100644 + ) + foreach(lib_name ${MM_SRCS}) + add_library("${lib_name}" STATIC ${METAL_DELEGATE_PATH}${lib_name}.mm) -+ target_include_directories("${lib_name}" PUBLIC -+ target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) -+ target_link_libraries(${lib_name} PUBLIC absl::status flatbuffers::flatbuffers) -+ ) -+ target_link_libraries(${lib_name}) ++ target_include_directories(${lib_name} PRIVATE ${TENSORFLOW_SOURCE_DIR}) ++ target_link_libraries(${lib_name} PUBLIC absl::status absl::strings flatbuffers::flatbuffers) + endforeach() endif() list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DCL_DELEGATE_NO_GL" "-DEGL_NO_X11") diff --git a/versions/t-/tensorflow-lite.json b/versions/t-/tensorflow-lite.json index 4155fceb..a22c2d7b 100644 --- a/versions/t-/tensorflow-lite.json +++ b/versions/t-/tensorflow-lite.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "161ee8b1833cbbdc6c819c8355d16565bb5ad28a", + "git-tree": "3031713fd7b9f72f7bc4637e23c98a8c099f6cf9", "version-semver": "2.17.0", "port-version": 0 }, From 140359d47659ac82c7229444f0a1c02bfacec12a Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 9 Sep 2024 21:22:59 +0900 Subject: [PATCH 4/5] [tensorflow-lite] build in Android NDK 27+ --- ports/tensorflow-lite/fix-cmake-vcpkg.patch | 6 +- ports/tensorflow-lite/fix-source-abseil.patch | 637 ------------------ ports/tensorflow-lite/fix-sources.patch | 33 +- ports/tensorflow-lite/portfile.cmake | 3 +- ports/tensorflow-lite/vcpkg.json | 1 - test/azure-port-android.txt | 1 + versions/t-/tensorflow-lite.json | 2 +- 7 files changed, 22 insertions(+), 661 deletions(-) delete mode 100644 ports/tensorflow-lite/fix-source-abseil.patch diff --git a/ports/tensorflow-lite/fix-cmake-vcpkg.patch b/ports/tensorflow-lite/fix-cmake-vcpkg.patch index 76363581..862c55fe 100644 --- a/ports/tensorflow-lite/fix-cmake-vcpkg.patch +++ b/ports/tensorflow-lite/fix-cmake-vcpkg.patch @@ -180,7 +180,7 @@ index b79818f3..b646abf5 100644 ) + # tsl::mutex requires nsync_cpp + find_package(nsync_cpp CONFIG REQUIRED) -+ list(APPEND TFLITE_TARGET_DEPENDENCIES ${NSYNC_LIBRARY}) ++ list(APPEND TFLITE_TARGET_DEPENDENCIES nsync_cpp) + + # disable ml_dtypes/float8.h which requries libeigen3 master branch ... + set_source_files_properties(${TFLITE_NNAPI_SRCS} PROPERTIES @@ -196,14 +196,14 @@ index b79818f3..b646abf5 100644 - find_package(fp16_headers REQUIRED) - find_package(XNNPACK REQUIRED) + find_path(FP16_INCLUDE_DIRS "fp16.h" REQUIRED) -+ find_package(xnnpack CONFIG REQUIRED) # xnnpack ++ find_library(XNNPACK_LIBRARY NAMES xnnpack REQUIRED) populate_tflite_source_vars("delegates/xnnpack" TFLITE_DELEGATES_XNNPACK_SRCS FILTER ".*(_test|_tester)\\.(cc|h)" ) list(APPEND TFLITE_TARGET_DEPENDENCIES - XNNPACK -+ xnnpack ++ ${XNNPACK_LIBRARY} ) list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DTFLITE_BUILD_WITH_XNNPACK_DELEGATE") list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DXNNPACK_DELEGATE_ENABLE_QS8") diff --git a/ports/tensorflow-lite/fix-source-abseil.patch b/ports/tensorflow-lite/fix-source-abseil.patch deleted file mode 100644 index 05909022..00000000 --- a/ports/tensorflow-lite/fix-source-abseil.patch +++ /dev/null @@ -1,637 +0,0 @@ -diff --git a/tensorflow/lite/delegates/gpu/api.h b/tensorflow/lite/delegates/gpu/api.h -index 4594410a..987747cd 100644 ---- a/tensorflow/lite/delegates/gpu/api.h -+++ b/tensorflow/lite/delegates/gpu/api.h -@@ -230,7 +230,7 @@ bool IsValid(const TensorObjectDef& def); - uint32_t NumElements(const TensorObjectDef& def); - - using TensorObject = -- absl::variant; - - // @return true if object is set and corresponding values are defined. -diff --git a/tensorflow/lite/delegates/gpu/common/tasks/mean_stddev_normalization.cc b/tensorflow/lite/delegates/gpu/common/tasks/mean_stddev_normalization.cc -index f45a58c7..c8871346 100644 ---- a/tensorflow/lite/delegates/gpu/common/tasks/mean_stddev_normalization.cc -+++ b/tensorflow/lite/delegates/gpu/common/tasks/mean_stddev_normalization.cc -@@ -43,8 +43,8 @@ absl::Status CheckIfValidNodeOfType(const Node* node, - } - - absl::Status GetElementwiseScalarValue(const Node* node, float* result) { -- auto attr = absl::any_cast(node->operation.attributes); -- const float* value = absl::get_if(&attr.param); -+ auto attr = std::any_cast(node->operation.attributes); -+ const float* value = std::get_if(&attr.param); - if (!value) { - return absl::NotFoundError("Not a scalar value inside attributes."); - } -@@ -391,7 +391,7 @@ absl::Status TryMeanStdDevNormalization( - Node* first_mean_node = graph.GetNode(first_node_id); - RETURN_IF_ERROR(CheckIfValidNodeOfType(first_mean_node, OperationType::MEAN)); - auto first_mean_attr = -- absl::any_cast(first_mean_node->operation.attributes); -+ std::any_cast(first_mean_node->operation.attributes); - if (first_mean_attr.dims != std::set{Axis::CHANNELS}) { - return absl::NotFoundError("MeanStdDevNormalization not suitable."); - } -diff --git a/tensorflow/lite/delegates/gpu/common/tasks/prelu.cc b/tensorflow/lite/delegates/gpu/common/tasks/prelu.cc -index 7ad25f78..81b5b7c5 100644 ---- a/tensorflow/lite/delegates/gpu/common/tasks/prelu.cc -+++ b/tensorflow/lite/delegates/gpu/common/tasks/prelu.cc -@@ -31,7 +31,7 @@ ElementwiseDescriptor CreatePReLU(const PReLUAttributes& attr, - ElementwiseDescriptor op_desc; - std::string alpha_read; - auto alpha_linear = -- absl::get_if>(&attr.alpha); -+ std::get_if>(&attr.alpha); - if (alpha_linear) { - TensorDescriptor alpha_tensor_desc = CreateConstantLinearTensorDescriptor( - tensor_desc.GetDataType(), tensor_desc.GetStorageType(), *alpha_linear); -@@ -41,7 +41,7 @@ ElementwiseDescriptor CreatePReLU(const PReLUAttributes& attr, - } - - auto alpha_hwc = -- absl::get_if>(&attr.alpha); -+ std::get_if>(&attr.alpha); - if (alpha_hwc) { - const BHWC shape = - BHWC(1, alpha_hwc->shape.h, alpha_hwc->shape.w, alpha_hwc->shape.c); -diff --git a/tensorflow/lite/delegates/gpu/common/tasks/special/dw7x7_conv2to6_concat_conv8to8.cc b/tensorflow/lite/delegates/gpu/common/tasks/special/dw7x7_conv2to6_concat_conv8to8.cc -index ced3435f..ad8c84d7 100644 ---- a/tensorflow/lite/delegates/gpu/common/tasks/special/dw7x7_conv2to6_concat_conv8to8.cc -+++ b/tensorflow/lite/delegates/gpu/common/tasks/special/dw7x7_conv2to6_concat_conv8to8.cc -@@ -183,7 +183,7 @@ GPUOperation CreateDW7x7Conv2To6ConcatConv8to8( - constants.push_back(conv2to6.weights.data[i]); - } - -- auto alpha0 = absl::get_if>( -+ auto alpha0 = std::get_if>( - &prelu0.alpha); - for (int i = 0; i < 6; ++i) { - constants.push_back(alpha0->data[i]); -@@ -222,7 +222,7 @@ GPUOperation CreateDW7x7Conv2To6ConcatConv8to8( - } - } - -- auto alpha1 = absl::get_if>( -+ auto alpha1 = std::get_if>( - &prelu1.alpha); - for (int i = 0; i < 8; ++i) { - constants.push_back(alpha1->data[i]); -@@ -273,7 +273,7 @@ absl::Status TryDW7x7Conv2To6ConcatConv8to8( - } - - DepthwiseConvolution2DAttributes* dw_attr = -- absl::any_cast( -+ std::any_cast( - &dw_node->operation.attributes); - const bool kGoodDwWeights = - dw_attr->weights.shape.w == 7 && dw_attr->weights.shape.h == 7 && -@@ -308,7 +308,8 @@ absl::Status TryDW7x7Conv2To6ConcatConv8to8( - OperationType::CONVOLUTION_2D) { - return absl::NotFoundError("DW7x7Conv2To6ConcatConv8to8 not suitable."); - } -- Convolution2DAttributes* conv1_attr = absl::any_cast( -+ Convolution2DAttributes* conv1_attr = -+ std::any_cast( - &conv1_node->operation.attributes); - if (!IsConv1x1(*conv1_attr) || conv1_attr->weights.shape.i != 2 || - conv1_attr->weights.shape.o != 6) { -@@ -370,7 +371,7 @@ absl::Status TryDW7x7Conv2To6ConcatConv8to8( - return absl::NotFoundError("DW7x7Conv2To6ConcatConv8to8 not suitable."); - } - Pooling2DAttributes* pooling_attr = -- absl::any_cast(&pooling_node->operation.attributes); -+ std::any_cast(&pooling_node->operation.attributes); - if (pooling_attr->type != PoolingType::MAX || pooling_attr->output_indices || - pooling_attr->kernel.w != 2 || pooling_attr->kernel.h != 2 || - pooling_attr->strides.w != 2 || pooling_attr->strides.h != 2 || -@@ -394,7 +395,7 @@ absl::Status TryDW7x7Conv2To6ConcatConv8to8( - OperationType::CONVOLUTION_2D) { - return absl::NotFoundError("DW7x7Conv2To6ConcatConv8to8 not suitable."); - } -- Convolution2DAttributes* conv2_attr = absl::any_cast( -+ Convolution2DAttributes* conv2_attr = std::any_cast( - &conv2_node->operation.attributes); - if (!IsConv1x1(*conv2_attr) || conv2_attr->weights.shape.i != 8 || - conv2_attr->weights.shape.o != 8) { -@@ -438,9 +439,9 @@ absl::Status TryDW7x7Conv2To6ConcatConv8to8( - } - - PReLUAttributes* prelu1_attr = -- absl::any_cast(&prelu1_node->operation.attributes); -+ std::any_cast(&prelu1_node->operation.attributes); - PReLUAttributes* prelu2_attr = -- absl::any_cast(&prelu2_node->operation.attributes); -+ std::any_cast(&prelu2_node->operation.attributes); - - std::vector op_outputs = {concat_outputs[0], prelu2_outputs[0]}; - std::unique_ptr* gpu_op = -diff --git a/tensorflow/lite/delegates/gpu/common/tasks/special/thin_pointwise_fuser.cc b/tensorflow/lite/delegates/gpu/common/tasks/special/thin_pointwise_fuser.cc -index 902ef54a..691beab1 100644 ---- a/tensorflow/lite/delegates/gpu/common/tasks/special/thin_pointwise_fuser.cc -+++ b/tensorflow/lite/delegates/gpu/common/tasks/special/thin_pointwise_fuser.cc -@@ -350,7 +350,7 @@ bool ThinPointwiseFuser::IsNodeSupported(const GpuInfo& gpu_info, - return false; - } - DepthwiseConvolution2DAttributes* dw_attr = -- absl::any_cast( -+ std::any_cast( - &node->operation.attributes); - const auto dw_shape = dw_attr->weights.shape; - bool good_dw = dw_shape.o == 1; -@@ -387,7 +387,7 @@ bool ThinPointwiseFuser::IsNodeSupported(const GpuInfo& gpu_info, - return false; - } - Convolution2DAttributes* conv_attr = -- absl::any_cast(&node->operation.attributes); -+ std::any_cast(&node->operation.attributes); - if (conv_attr->groups != 1) { - return false; - } -@@ -462,12 +462,12 @@ bool ThinPointwiseFuser::ReserveNode(const GpuInfo& gpu_info, Node* node) { - if (IsConvNode(node)) { - convs_count_++; - Convolution2DAttributes* conv_attr = -- absl::any_cast(&node->operation.attributes); -+ std::any_cast(&node->operation.attributes); - buffer_size_ += GetConvWeightsSize(*conv_attr, op_def_.precision); - } - if (IsDwConvNode(node)) { - DepthwiseConvolution2DAttributes* dw_attr = -- absl::any_cast( -+ std::any_cast( - &node->operation.attributes); - buffer_size_ += GetDepthwiseConvWeightsSize(*dw_attr, op_def_.precision); - } -@@ -479,12 +479,12 @@ uint64_t ThinPointwiseFuser::GetNodeFlops(Node* node) const { - auto output_shape = graph_->FindOutputs(node->id)[0]->tensor.shape; - if (op_type == OperationType::DEPTHWISE_CONVOLUTION) { - DepthwiseConvolution2DAttributes* attr = -- absl::any_cast( -+ std::any_cast( - &node->operation.attributes); - return GetDepthwiseConvolutionFlops(output_shape, attr->weights.shape); - } else if (op_type == OperationType::CONVOLUTION_2D) { - Convolution2DAttributes* attr = -- absl::any_cast(&node->operation.attributes); -+ std::any_cast(&node->operation.attributes); - return GetConvolutionFlops(output_shape, attr->weights.shape); - } - return 0; -@@ -495,11 +495,11 @@ void ThinPointwiseFuser::AddNode(const GpuInfo& gpu_info, int node_index) { - auto op_type = OperationTypeFromString(node->operation.type); - if (op_type == OperationType::RELU) { - ReLUAttributes* attr = -- absl::any_cast(&node->operation.attributes); -+ std::any_cast(&node->operation.attributes); - AddReluNode(*attr); - } else if (op_type == OperationType::PRELU) { - PReLUAttributes* attr = -- absl::any_cast(&node->operation.attributes); -+ std::any_cast(&node->operation.attributes); - AddPreluNode(*attr); - } else if (op_type == OperationType::ADD) { - Node* prev_node = nodes_[node_index - 1]; -@@ -514,12 +514,12 @@ void ThinPointwiseFuser::AddNode(const GpuInfo& gpu_info, int node_index) { - AddElementwiseOneInputNode(gpu_info, op_type); - } else if (op_type == OperationType::DEPTHWISE_CONVOLUTION) { - DepthwiseConvolution2DAttributes* attr = -- absl::any_cast( -+ std::any_cast( - &node->operation.attributes); - AddDepthwiseConvNode(gpu_info, *attr); - } else if (op_type == OperationType::CONVOLUTION_2D) { - Convolution2DAttributes* attr = -- absl::any_cast(&node->operation.attributes); -+ std::any_cast(&node->operation.attributes); - if (IsConv1x1(*attr) && node_index != 0) { - AddConv1x1Node(gpu_info, *attr, node_index == nodes_.size() - 1); - } else { -diff --git a/tensorflow/lite/delegates/gpu/common/transformations/add_bias.cc b/tensorflow/lite/delegates/gpu/common/transformations/add_bias.cc -index ae3e4e54..d8ceeec7 100644 ---- a/tensorflow/lite/delegates/gpu/common/transformations/add_bias.cc -+++ b/tensorflow/lite/delegates/gpu/common/transformations/add_bias.cc -@@ -59,12 +59,12 @@ class AddBias : public NodeTransformation { - "runtime input."}; - } - auto& attr = -- absl::any_cast(node->operation.attributes); -+ std::any_cast(node->operation.attributes); - return FillBias(attr.weights.shape.o, &attr.bias); - } - if (node->operation.type == - ToString(OperationType::CONVOLUTION_TRANSPOSED)) { -- auto& attr = absl::any_cast( -+ auto& attr = std::any_cast( - node->operation.attributes); - return FillBias(attr.weights.shape.o, &attr.bias); - } -@@ -76,17 +76,17 @@ class AddBias : public NodeTransformation { - "with one " - "runtime input."}; - } -- auto& attr = absl::any_cast( -+ auto& attr = std::any_cast( - node->operation.attributes); - return FillBias(attr.weights.shape.o * attr.weights.shape.i, &attr.bias); - } - if (node->operation.type == ToString(OperationType::FULLY_CONNECTED)) { - auto& attr = -- absl::any_cast(node->operation.attributes); -+ std::any_cast(node->operation.attributes); - return FillBias(attr.weights.shape.o, &attr.bias); - } - if (node->operation.type == ToString(OperationType::FULLY_CONNECTED_INT8)) { -- auto& attr = absl::any_cast( -+ auto& attr = std::any_cast( - node->operation.attributes); - return FillBias(attr.weights.shape.o, &attr.bias); - } -diff --git a/tensorflow/lite/delegates/gpu/common/transformations/fuse_add_to_conv.cc b/tensorflow/lite/delegates/gpu/common/transformations/fuse_add_to_conv.cc -index 673502f2..3b386d80 100644 ---- a/tensorflow/lite/delegates/gpu/common/transformations/fuse_add_to_conv.cc -+++ b/tensorflow/lite/delegates/gpu/common/transformations/fuse_add_to_conv.cc -@@ -37,8 +37,8 @@ namespace { - void FuseBiasWithAddAttributes(const ElementwiseAttributes& add_attr, - const int channels, - Tensor* bias) { -- auto add = absl::get_if>(&add_attr.param); -- auto add_scalar = absl::get_if(&add_attr.param); -+ auto add = std::get_if>(&add_attr.param); -+ auto add_scalar = std::get_if(&add_attr.param); - if (bias->data.empty()) { - *bias = MakeZeroTensor(Linear(channels)); - } -@@ -63,35 +63,35 @@ class MergeConvolutionWithAdd : public SequenceTransformation { - return {TransformStatus::SKIPPED, ""}; - } - ElementwiseAttributes add_attr = -- absl::any_cast(add_node.operation.attributes); -- if (!absl::holds_alternative>( -+ std::any_cast(add_node.operation.attributes); -+ if (!std::holds_alternative>( - add_attr.param) && -- !absl::holds_alternative(add_attr.param)) { -+ !std::holds_alternative(add_attr.param)) { - return {TransformStatus::DECLINED, - "This fuse applicable only for broadcast or scalar addition."}; - } - - if (conv_node.operation.type == ToString(OperationType::CONVOLUTION_2D)) { - Convolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseConvolution2DWithAdd(add_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::CONVOLUTION_TRANSPOSED)) { - ConvolutionTransposedAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseConvolutionTransposedWithAdd(add_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::DEPTHWISE_CONVOLUTION)) { - DepthwiseConvolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseDepthwiseConvolution2DWithAdd(add_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::FULLY_CONNECTED)) { - FullyConnectedAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseFullyConnectedWithAdd(add_attr, conv_attr); - } else { -@@ -110,8 +110,8 @@ class MergeConvolutionWithAdd : public SequenceTransformation { - - void FuseAddWithConvolution2D(const ElementwiseAttributes& add_attr, - Convolution2DAttributes* attr) { -- auto add = absl::get_if>(&add_attr.param); -- auto add_scalar = absl::get_if(&add_attr.param); -+ auto add = std::get_if>(&add_attr.param); -+ auto add_scalar = std::get_if(&add_attr.param); - if (attr->bias.data.empty()) { - attr->bias = MakeZeroTensor( - Linear(attr->weights.shape.o)); -@@ -147,17 +147,17 @@ class MergeAddWithConvolution : public SequenceTransformation { - return {TransformStatus::SKIPPED, ""}; - } - ElementwiseAttributes add_attr = -- absl::any_cast(add_node.operation.attributes); -- if (!absl::holds_alternative>( -+ std::any_cast(add_node.operation.attributes); -+ if (!std::holds_alternative>( - add_attr.param) && -- !absl::holds_alternative(add_attr.param)) { -+ !std::holds_alternative(add_attr.param)) { - return {TransformStatus::DECLINED, - "This fuse applicable only for broadcast or scalar addition."}; - } - - if (conv_node.operation.type == ToString(OperationType::CONVOLUTION_2D)) { - Convolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - if (conv_attr->groups != 1) { - return {TransformStatus::DECLINED, -diff --git a/tensorflow/lite/delegates/gpu/common/transformations/fuse_mul_to_conv.cc b/tensorflow/lite/delegates/gpu/common/transformations/fuse_mul_to_conv.cc -index 41bd485a..98523a3a 100644 ---- a/tensorflow/lite/delegates/gpu/common/transformations/fuse_mul_to_conv.cc -+++ b/tensorflow/lite/delegates/gpu/common/transformations/fuse_mul_to_conv.cc -@@ -53,10 +53,10 @@ class MergeConvolutionWithMul : public SequenceTransformation { - } - - ElementwiseAttributes mul_attr = -- absl::any_cast(mul_node.operation.attributes); -- if (!absl::holds_alternative>( -+ std::any_cast(mul_node.operation.attributes); -+ if (!std::holds_alternative>( - mul_attr.param) && -- !absl::holds_alternative(mul_attr.param)) { -+ !std::holds_alternative(mul_attr.param)) { - return { - TransformStatus::DECLINED, - "This fuse applicable only for broadcast or scalar multiplication."}; -@@ -64,25 +64,25 @@ class MergeConvolutionWithMul : public SequenceTransformation { - - if (conv_node.operation.type == ToString(OperationType::CONVOLUTION_2D)) { - Convolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseConvolution2DWithMultiply(mul_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::CONVOLUTION_TRANSPOSED)) { - ConvolutionTransposedAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseConvolutionTransposedWithMultiply(mul_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::DEPTHWISE_CONVOLUTION)) { - DepthwiseConvolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseDepthwiseConvolution2DWithMultiply(mul_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::FULLY_CONNECTED)) { - FullyConnectedAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseFullyConnectedWithMultiply(mul_attr, conv_attr); - } else { -@@ -117,10 +117,10 @@ class MergeMulWithConvolution : public SequenceTransformation { - } - - ElementwiseAttributes mul_attr = -- absl::any_cast(mul_node.operation.attributes); -- if (!absl::holds_alternative>( -+ std::any_cast(mul_node.operation.attributes); -+ if (!std::holds_alternative>( - mul_attr.param) && -- !absl::holds_alternative(mul_attr.param)) { -+ !std::holds_alternative(mul_attr.param)) { - return { - TransformStatus::DECLINED, - "This fuse applicable only for broadcast or scalar multiplication."}; -@@ -128,25 +128,25 @@ class MergeMulWithConvolution : public SequenceTransformation { - - if (conv_node.operation.type == ToString(OperationType::CONVOLUTION_2D)) { - Convolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseMultiplyWithConvolution2D(mul_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::CONVOLUTION_TRANSPOSED)) { - ConvolutionTransposedAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseMultiplyWithConvolutionTransposed(mul_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::DEPTHWISE_CONVOLUTION)) { - DepthwiseConvolution2DAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseMultiplyWithDepthwiseConvolution2D(mul_attr, conv_attr); - } else if (conv_node.operation.type == - ToString(OperationType::FULLY_CONNECTED)) { - FullyConnectedAttributes* conv_attr = -- absl::any_cast( -+ std::any_cast( - &conv_node.operation.attributes); - FuseMultiplyWithFullyConnected(mul_attr, conv_attr); - } else { -@@ -175,8 +175,8 @@ std::unique_ptr NewMergeMulWithConvolution() { - - void FuseConvolution2DWithMultiply(const ElementwiseAttributes& mul_attr, - Convolution2DAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int d = 0; d < attr->weights.shape.o; ++d) { - const float multiplier = mul ? mul->data[d] : *mul_scalar; - for (int s = 0; s < attr->weights.shape.i; ++s) { -@@ -196,8 +196,8 @@ void FuseConvolution2DWithMultiply(const ElementwiseAttributes& mul_attr, - void FuseDepthwiseConvolution2DWithMultiply( - const ElementwiseAttributes& mul_attr, - DepthwiseConvolution2DAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int g = 0; g < attr->weights.shape.o; ++g) { - for (int s = 0; s < attr->weights.shape.i; ++s) { - const int d = s * attr->weights.shape.o + g; -@@ -218,8 +218,8 @@ void FuseDepthwiseConvolution2DWithMultiply( - void FuseConvolutionTransposedWithMultiply( - const ElementwiseAttributes& mul_attr, - ConvolutionTransposedAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int d = 0; d < attr->weights.shape.o; ++d) { - const float multiplier = mul ? mul->data[d] : *mul_scalar; - for (int s = 0; s < attr->weights.shape.i; ++s) { -@@ -238,8 +238,8 @@ void FuseConvolutionTransposedWithMultiply( - - void FuseFullyConnectedWithMultiply(const ElementwiseAttributes& mul_attr, - FullyConnectedAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int d = 0; d < attr->weights.shape.o; ++d) { - const float multiplier = mul ? mul->data[d] : *mul_scalar; - for (int s = 0; s < attr->weights.shape.i; ++s) { -@@ -254,8 +254,8 @@ void FuseFullyConnectedWithMultiply(const ElementwiseAttributes& mul_attr, - - void FuseMultiplyWithConvolution2D(const ElementwiseAttributes& mul_attr, - Convolution2DAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int s = 0; s < attr->weights.shape.i; ++s) { - const float multiplier = mul ? mul->data[s] : *mul_scalar; - for (int d = 0; d < attr->weights.shape.o; ++d) { -@@ -272,8 +272,8 @@ void FuseMultiplyWithConvolution2D(const ElementwiseAttributes& mul_attr, - void FuseMultiplyWithDepthwiseConvolution2D( - const ElementwiseAttributes& mul_attr, - DepthwiseConvolution2DAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int s = 0; s < attr->weights.shape.i; ++s) { - const float multiplier = mul ? mul->data[s] : *mul_scalar; - for (int g = 0; g < attr->weights.shape.o; ++g) { -@@ -290,8 +290,8 @@ void FuseMultiplyWithDepthwiseConvolution2D( - void FuseMultiplyWithConvolutionTransposed( - const ElementwiseAttributes& mul_attr, - ConvolutionTransposedAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int s = 0; s < attr->weights.shape.i; ++s) { - const float multiplier = mul ? mul->data[s] : *mul_scalar; - for (int d = 0; d < attr->weights.shape.o; ++d) { -@@ -307,8 +307,8 @@ void FuseMultiplyWithConvolutionTransposed( - - void FuseMultiplyWithFullyConnected(const ElementwiseAttributes& mul_attr, - FullyConnectedAttributes* attr) { -- auto mul = absl::get_if>(&mul_attr.param); -- auto mul_scalar = absl::get_if(&mul_attr.param); -+ auto mul = std::get_if>(&mul_attr.param); -+ auto mul_scalar = std::get_if(&mul_attr.param); - for (int s = 0; s < attr->weights.shape.i; ++s) { - const float multiplier = mul ? mul->data[s] : *mul_scalar; - for (int d = 0; d < attr->weights.shape.o; ++d) { -diff --git a/tensorflow/lite/delegates/gpu/common/transformations/merge_densify.cc b/tensorflow/lite/delegates/gpu/common/transformations/merge_densify.cc -index 4befb35d..2fc09ef6 100644 ---- a/tensorflow/lite/delegates/gpu/common/transformations/merge_densify.cc -+++ b/tensorflow/lite/delegates/gpu/common/transformations/merge_densify.cc -@@ -71,7 +71,7 @@ class MergeDensify : public NodeTransformation { - - // Create a copy of the const tensor with a cast from BHWC to OHWI. - const Tensor& src = -- absl::any_cast(&densify_node->operation.attributes) -+ std::any_cast(&densify_node->operation.attributes) - ->tensor; - Tensor dst; - dst.id = src.id; -@@ -90,10 +90,10 @@ class MergeDensify : public NodeTransformation { - - // Update CONV_2D / DEPTHWISE_CONV_2D weights. - if (node->operation.type == ToString(OperationType::CONVOLUTION_2D)) { -- absl::any_cast(&node->operation.attributes) -+ std::any_cast(&node->operation.attributes) - ->weights = std::move(dst); - } else { -- absl::any_cast( -+ std::any_cast( - &node->operation.attributes) - ->weights = std::move(dst); - } -diff --git a/tensorflow/lite/delegates/gpu/common/transformations/merge_padding_with.cc b/tensorflow/lite/delegates/gpu/common/transformations/merge_padding_with.cc -index 509d715f..8a6f47ba 100644 ---- a/tensorflow/lite/delegates/gpu/common/transformations/merge_padding_with.cc -+++ b/tensorflow/lite/delegates/gpu/common/transformations/merge_padding_with.cc -@@ -56,7 +56,7 @@ class MergePaddingWith2DOperation : public SequenceTransformation { - Node* op_node = sequence.back(); - - PadAttributes pad_attr = -- absl::any_cast(pad_node->operation.attributes); -+ std::any_cast(pad_node->operation.attributes); - - if (pad_attr.type != PaddingContentType::ZEROS) { - return {TransformStatus::DECLINED, "Only Zero padding is supported."}; -@@ -67,7 +67,7 @@ class MergePaddingWith2DOperation : public SequenceTransformation { - "Pad has non-zero padding on non HW axis."}; - } - -- Attr* node_attr = absl::any_cast(&op_node->operation.attributes); -+ Attr* node_attr = std::any_cast(&op_node->operation.attributes); - absl::Status status = RemovePrecedingNode(graph, pad_node, op_node); - if (!status.ok()) { - return {TransformStatus::INVALID, -@@ -128,7 +128,7 @@ class MergePaddingWithAddOperation : public NodeTransformation { - } - - PadAttributes pad_attr = -- absl::any_cast(node->operation.attributes); -+ std::any_cast(node->operation.attributes); - - if (pad_attr.type != PaddingContentType::ZEROS) { - return {TransformStatus::DECLINED, "Only Zero padding is supported."}; -@@ -151,13 +151,13 @@ class MergePaddingWithAddOperation : public NodeTransformation { - } - - ElementwiseAttributes add_attr = -- absl::any_cast(add_node->operation.attributes); -+ std::any_cast(add_node->operation.attributes); - const bool is_add_hwc = -- absl::holds_alternative>(add_attr.param); -+ std::holds_alternative>(add_attr.param); - const bool is_add_linear = -- absl::holds_alternative>( -+ std::holds_alternative>( - add_attr.param); -- const bool is_add_scalar = absl::holds_alternative(add_attr.param); -+ const bool is_add_scalar = std::holds_alternative(add_attr.param); - if (is_add_hwc || is_add_linear || is_add_scalar) { - return {TransformStatus::SKIPPED, - "Cannot remove padding when ADD has constant argument."}; -diff --git a/tensorflow/lite/delegates/gpu/common/transformations/remove_noop.cc b/tensorflow/lite/delegates/gpu/common/transformations/remove_noop.cc -index ceb66dd5..30366f8b 100644 ---- a/tensorflow/lite/delegates/gpu/common/transformations/remove_noop.cc -+++ b/tensorflow/lite/delegates/gpu/common/transformations/remove_noop.cc -@@ -86,13 +86,13 @@ std::unique_ptr NewRemoveSingleInputAdd() { - if (node->operation.type != type) { - return false; - } -- auto& attr = absl::any_cast( -+ auto& attr = std::any_cast( - node->operation.attributes); -- return !absl::holds_alternative>( -+ return !std::holds_alternative>( - attr.param) && -- !absl::holds_alternative>( -+ !std::holds_alternative>( - attr.param) && -- !absl::holds_alternative(attr.param); -+ !std::holds_alternative(attr.param); - }); - } - -@@ -118,7 +118,7 @@ class RemoveIdentityReshape : public NodeTransformation { - } - auto input_shape = graph->FindInputs(node->id)[0]->tensor.shape; - const auto& reshape_attr = -- absl::any_cast(node->operation.attributes); -+ std::any_cast(node->operation.attributes); - if (input_shape != reshape_attr.new_shape) { - return {TransformStatus::SKIPPED, ""}; - } -@@ -152,7 +152,7 @@ class RemoveIdentityStridedSlice : public NodeTransformation { - auto input = graph->FindInputs(node->id)[0]; - auto output = graph->FindOutputs(node->id)[0]; - const auto& slice_attr = -- absl::any_cast(node->operation.attributes); -+ std::any_cast(node->operation.attributes); - if (input->tensor.shape != output->tensor.shape) { - return {TransformStatus::SKIPPED, ""}; - } diff --git a/ports/tensorflow-lite/fix-sources.patch b/ports/tensorflow-lite/fix-sources.patch index 1b43b4e2..07eca648 100644 --- a/ports/tensorflow-lite/fix-sources.patch +++ b/ports/tensorflow-lite/fix-sources.patch @@ -1,5 +1,17 @@ +diff --git a/tensorflow/lite/delegates/xnnpack/weight_cache.cc b/tensorflow/lite/delegates/xnnpack/weight_cache.cc +index aa730738..3023167c 100644 +--- a/tensorflow/lite/delegates/xnnpack/weight_cache.cc ++++ b/tensorflow/lite/delegates/xnnpack/weight_cache.cc +@@ -20,6 +20,7 @@ limitations under the License. + #if defined(_MSC_VER) + #include + #define F_OK 0 ++#pragma warning(disable:4996) + #else + #include + #include diff --git a/third_party/xla/third_party/tsl/tsl/platform/ml_dtypes.h b/third_party/xla/third_party/tsl/tsl/platform/ml_dtypes.h -index c25efc2f..23a04428 100644 +index 916be8db..e2df0d5f 100644 --- a/third_party/xla/third_party/tsl/tsl/platform/ml_dtypes.h +++ b/third_party/xla/third_party/tsl/tsl/platform/ml_dtypes.h @@ -16,8 +16,8 @@ limitations under the License. @@ -7,22 +19,9 @@ index c25efc2f..23a04428 100644 #define TENSORFLOW_TSL_PLATFORM_ML_DTYPES_H_ -#include "ml_dtypes/include/float8.h" // from @ml_dtypes --#include "ml_dtypes/include/int4.h" // from @ml_dtypes +-#include "ml_dtypes/include/intn.h" // from @ml_dtypes +#include "ml_dtypes/float8.h" // from @ml_dtypes -+#include "ml_dtypes/int4.h" // from @ml_dtypes ++#include "ml_dtypes/intn.h" // from @ml_dtypes namespace tsl { - using float8_e4m3fn = ml_dtypes::float8_e4m3fn; -diff --git a/third_party/xla/xla/types.h b/third_party/xla/xla/types.h -index ef9dd11d..9cdc3965 100644 ---- a/third_party/xla/xla/types.h -+++ b/third_party/xla/xla/types.h -@@ -23,7 +23,7 @@ limitations under the License. - - #include "absl/strings/str_format.h" - #include "Eigen/Core" // from @eigen_archive // IWYU pragma: export --#include "ml_dtypes/include/int4.h" // from @ml_dtypes // IWYU pragma: export -+#include "ml_dtypes/int4.h" // from @ml_dtypes - - namespace xla { - + using float8_e4m3fn = ::ml_dtypes::float8_e4m3fn; diff --git a/ports/tensorflow-lite/portfile.cmake b/ports/tensorflow-lite/portfile.cmake index 2771a981..89908de1 100644 --- a/ports/tensorflow-lite/portfile.cmake +++ b/ports/tensorflow-lite/portfile.cmake @@ -24,8 +24,7 @@ vcpkg_from_github( tensorflow-pr-62037.patch fix-cmake-vcpkg.patch fix-cmake-c-api.patch - # fix-sources.patch - # fix-source-abseil.patch + fix-sources.patch ) file(REMOVE_RECURSE diff --git a/ports/tensorflow-lite/vcpkg.json b/ports/tensorflow-lite/vcpkg.json index c8d1b4f2..70496b6f 100644 --- a/ports/tensorflow-lite/vcpkg.json +++ b/ports/tensorflow-lite/vcpkg.json @@ -4,7 +4,6 @@ "description": "Open standard for machine learning interoperability", "homepage": "https://www.tensorflow.org/", "license": "Apache-2.0", - "supports": "!android", "dependencies": [ "abseil", "eigen3", diff --git a/test/azure-port-android.txt b/test/azure-port-android.txt index 9c056ae7..b79f0434 100644 --- a/test/azure-port-android.txt +++ b/test/azure-port-android.txt @@ -5,3 +5,4 @@ abseil fft2d nsync ruy +tensorflow-lite diff --git a/versions/t-/tensorflow-lite.json b/versions/t-/tensorflow-lite.json index a22c2d7b..59a43f78 100644 --- a/versions/t-/tensorflow-lite.json +++ b/versions/t-/tensorflow-lite.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "3031713fd7b9f72f7bc4637e23c98a8c099f6cf9", + "git-tree": "b93138f72ccd56459af730e81f945b252115f312", "version-semver": "2.17.0", "port-version": 0 }, From 03761d158099cc4edff298e25278a7ee7ea347b2 Mon Sep 17 00:00:00 2001 From: luncliff Date: Tue, 10 Sep 2024 00:16:37 +0900 Subject: [PATCH 5/5] [tensorflow-lite] find_library xnnpack in Linux --- ports/tensorflow-lite/fix-cmake-vcpkg.patch | 2 +- versions/t-/tensorflow-lite.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/tensorflow-lite/fix-cmake-vcpkg.patch b/ports/tensorflow-lite/fix-cmake-vcpkg.patch index 862c55fe..8a167b9f 100644 --- a/ports/tensorflow-lite/fix-cmake-vcpkg.patch +++ b/ports/tensorflow-lite/fix-cmake-vcpkg.patch @@ -196,7 +196,7 @@ index b79818f3..b646abf5 100644 - find_package(fp16_headers REQUIRED) - find_package(XNNPACK REQUIRED) + find_path(FP16_INCLUDE_DIRS "fp16.h" REQUIRED) -+ find_library(XNNPACK_LIBRARY NAMES xnnpack REQUIRED) ++ find_library(XNNPACK_LIBRARY NAMES xnnpack XNNPACK REQUIRED) populate_tflite_source_vars("delegates/xnnpack" TFLITE_DELEGATES_XNNPACK_SRCS FILTER ".*(_test|_tester)\\.(cc|h)" diff --git a/versions/t-/tensorflow-lite.json b/versions/t-/tensorflow-lite.json index 59a43f78..b4a91f7c 100644 --- a/versions/t-/tensorflow-lite.json +++ b/versions/t-/tensorflow-lite.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "b93138f72ccd56459af730e81f945b252115f312", + "git-tree": "61e178dd578fc92b12a0a35b9a507dbb91eaead3", "version-semver": "2.17.0", "port-version": 0 },