Skip to content

The size of "Select TensorFlow ops library" aka. libtensorflowlite_flex.so cannot be decreased #3273

@hayhan

Description

@hayhan

See the link below:
https://ai.google.dev/edge/litert/build/reduce_binary_size.md#building_custom_c_shared_objects_2

I am using the select tf ops in my tflite model. The ops are "save" and "restore". For these two ops, I have to build the full version libtensorflowlite_flex.so, which size is toooo big (160M from version 2.14.1, and 208M from version 2.18.1).

I followed the instructions at the link above to customize the flex lib as following:


  1. mkdir tensorflow_src/tmp
  2. create a BUILD file with content below in folder tmp.
load("//tensorflow/lite/delegates/flex:build_def.bzl", "tflite_flex_shared_library")
tflite_flex_shared_library(
    name = "tensorflowlite_flex",
    models = [
        "cic.tflite",
    ],
)
  1. Put my tflite model cic.tflite in folder tmp too
  2. bazel build -c opt --config=monolithic //tmp:tensorflowlite_flex

I tried both tensorflow v2.14.1 & 2.18.1, with both amd64 & arm64 gcc toolchain (gcc 12.4 & 13.3). The generated libtensorflowlite_flex.so size doesn't get affected.

What might be wrong?

Thanks!

Metadata

Metadata

Assignees

Labels

status:awaiting LiteRTerinformation is sufficient and the issue is escalatedtype:bugBugtype:docs-bugFor documentation bugstype:flex-opsFor issues related to building flex-ops or dynamic reduction in LiteRT resource consumption

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions