skip to Main Content

I am trying to cross compile Tensorflow Lite (2.5, nightly build) for iOS. I would like to build a static framework. Here is the build command I used:

bazel build --config=ios_arm64 -c opt //tensorflow/lite/ios:TensorFlowLiteC_framework

The TensorFlowLiteC_framework target is defined in tensorflow/tensorflow/lite/ios/BUILD.apple as

tflite_ios_static_framework(
    name = "TensorFlowLiteC_framework",
    hdrs = [
        ":c_api.h",
        ":common.h",
        ":xnnpack_delegate.h",
        "//tensorflow/lite/c:c_api_types.h",
    ],
    allowlist_symbols_file = ":allowlist_TensorFlowLiteC.txt",
    bundle_name = "TensorFlowLiteC",
    minimum_os_version = TFL_MINIMUM_OS_VERSION,
    deps = [
        ":tensorflow_lite_c",
    ],
)

I had expected the resulting framework to be a static framework, but it appears to be a dynamic framework instead. Inside the TensorFlowLiteC.framework folder, there is a binary file TensorFlowLiteC. If I do file TensorFlowLiteC, I get:

TensorFlowLiteC: Mach-O universal binary with 1 architecture: [arm64:Mach-O 64-bit object arm64]
TensorFlowLiteC (for architecture arm64):   Mach-O 64-bit object arm64

This appears to be a dynamic lib file to me. As far as I know, if this was a static archive, I should have gotten: current ar archive.

Is there a way to actually build Tensorflow Lite into an actual static framework for iOS?

2

Answers


  1. If you want to use the static framework, you can build the TensorFlowLiteC static framework with the following command:

    bazel build --config=ios_fat -c opt //tensorflow/lite/ios:TensorFlowLiteC_static_framework
    
    Login or Signup to reply.
  2. The object in the output indicates the file is an object file. It’s not an archive of object files though, but a single object file.

    The framework google distributes as ‘dynamic’ is actually a static framework, and command that should produce a static framework does not work in 2022.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search