From 742ccbb9c1a2f879a56ea66029cf8bf44a3e2f7a Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 25 Jun 2024 15:33:22 -0700 Subject: [PATCH] Add tensorflow support for 16k page sizes on arm64 Tested both libtensorflowlite.so and libtensorflowlite_jni.so to ensure both libraries are 16k ELF aligned with this change: $ objdump -p bazel-bin/tensorflow/lite/libtensorflowlite.so | grep LOAD | awk '{ print $1 " " $NF }' LOAD 2**14 LOAD 2**14 $ objdump -p bazel-bin/tensorflow/lite/java/libtensorflowlite_jni.so | grep LOAD | awk '{ print $1 " " $NF }' LOAD 2**14 LOAD 2**14 PiperOrigin-RevId: 646629366 --- tensorflow/lite/build_def.bzl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tensorflow/lite/build_def.bzl b/tensorflow/lite/build_def.bzl index 2814d0da630889..c01e5234beddd2 100644 --- a/tensorflow/lite/build_def.bzl +++ b/tensorflow/lite/build_def.bzl @@ -181,13 +181,22 @@ def tflite_linkopts_no_undefined(): }), ) +def tflite_pagesize_linkopts(): + """Defines linker flags for setting the page size.""" + return select({ + clean_dep("//tensorflow:android_arm64"): [ + "-Wl,-z,max-page-size=16384", + ], + "//conditions:default": [], + }) + def tflite_linkopts(): """Defines linker flags for linking TFLite binary.""" - return tflite_linkopts_unstripped() + tflite_symbol_opts() + return tflite_linkopts_unstripped() + tflite_symbol_opts() + tflite_pagesize_linkopts() def tflite_jni_linkopts(): """Defines linker flags for linking TFLite binary with JNI.""" - return tflite_jni_linkopts_unstripped() + tflite_symbol_opts() + return tflite_jni_linkopts_unstripped() + tflite_symbol_opts() + tflite_pagesize_linkopts() def tflite_jni_binary( name,