Skip to content

Idea: Temporary Workaround for Native C++ 16KB Memory Page Compatibility #38

@yong1020

Description

@yong1020

Hi everyone!

I’d like to share an idea that might help others who are running into issues with the recent 16KB memory page policy.

I experimented with rebuilding libtensorflowlite.so for arm64-v8a devices so that it aligns with a 16KB memory page size.

If you’d like to try it out, you can replace the following files in your project with the rebuilt versions:


🔧 Build Details

  • TensorFlow version: 2.12.0
    I couldn’t determine the exact TensorFlow version used in the original project, so I explored compatibility with TFLiteEngine and found that 2.12.0 worked.
  • OS: Ubuntu 20.04
  • Build tool: Bazel 5.3.0 (compatible with TF 2.12.0)
  • NDK version: 21.4.7075529
  • Build command:
    $ bazel build -c opt \
      --config=android_arm64 \
      --linkopt='-Wl,-z,max-page-size=0x4000' \
      //tensorflow/lite:libtensorflowlite.so
  • Build Result:
    If you see 0x4000 in the alignment field, it means that the build successfully applied the 16KB memory page size:
    $ readelf -lW bazel-bin/tensorflow/lite/libtensorflowlite.so | grep LOAD
      LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x462ffc 0x462ffc R E 0x4000
      LOAD           0x4632c8 0x00000000004672c8 0x00000000004672c8 0x00eb28 0x0160a8 RW  0x4000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions