TFLite build fix for XCode with clang 21 Fixes errors like the following: ```cpp [build] third_party/tensorflow/tensorflow/lite/kernels/elementwise.cc:304:14: error: no matching function for call to 'EvalImpl' [build] 304 | return EvalImpl<int32_t>(context, node, std::abs<int32_t>, type); [build] | ^~~~~~~~~~~~~~~~~ [build] third_party/tensorflow/tensorflow/lite/kernels/elementwise.cc:243:21: note: candidate function template not viable: no overload of 'abs' matching 'std::function<int32_t (int32_t)>' (aka 'function<int (int)>') for 3rd argument ```
diff --git a/CMakeLists.txt b/CMakeLists.txt index a329f38..7e21739 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -564,6 +564,7 @@ "tar -xzf tensorflow.tar.gz; " "cd tensorflow; " "patch -p1 < ../tensorflow-designated-initializers.patch; " + "patch -p1 < ../tensorflow-elementwise.patch; " "cd ..; " "tar -xzf deps_cmake.tar.gz; " "cp deps_cmake/abseil-cpp.cmake ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tensorflow/tensorflow/lite/tools/cmake/modules; "
diff --git a/third_party/tensorflow-elementwise.patch b/third_party/tensorflow-elementwise.patch new file mode 100644 index 0000000..a6603fd --- /dev/null +++ b/third_party/tensorflow-elementwise.patch
@@ -0,0 +1,21 @@ +--- a/tensorflow/lite/kernels/elementwise.cc ++++ b/tensorflow/lite/kernels/elementwise.cc +@@ -293,14 +293,16 @@ + switch (type) { + case kTfLiteFloat32: +- return EvalImpl<float>(context, node, std::abs<float>, type); ++ return EvalImpl<float>(context, node, ++ [](float v) { return std::abs(v); }, type); + case kTfLiteInt8: + return AbsEvalQuantized<int8_t>(context, node, type); + case kTfLiteInt16: + return input->quantization.type == kTfLiteNoQuantization + ? AbsInt16EvalImpl(context, node, type) + : AbsEvalQuantized<int16_t>(context, node, type); + case kTfLiteInt32: +- return EvalImpl<int32_t>(context, node, std::abs<int32_t>, type); ++ return EvalImpl<int32_t>(context, node, ++ [](int32_t v) { return std::abs(v); }, type); + default: + TF_LITE_KERNEL_LOG(context, "Current data type %%s is not supported.", + TfLiteTypeGetName(type));