edhair
edhair

Reputation: 195

Reduce TFLite binary size android

Is there a way to reduce the tensorflow-lite binary size for android, so that it will only contain the ops that the model is using? I know that there is an experimental way of select tensorflow ops (https://www.tensorflow.org/lite/guide/ops_select#known_limitations) to use in tflite but i need it the other way around to reduce my binary.

At the moment the whole tflite dependency is about 3.8 MB with all ABI´s. I just thought if it is possible to reduce even this with something like "dselective header registration" and compile my own small tflite.aar that only supports the ops that my model needs? On this page https://www.tensorflow.org/lite/guide there is a hint that exactly says what I need but there is no information about how to do this? Or do I miss something?

enter image description here

I already have a fully working bazel environment and are able to build the AAR from the tensorflow sources but the size is the same like the maven dependency.

Upvotes: 0

Views: 704

Answers (2)

Paul Mundt
Paul Mundt

Reputation: 509

In addition to the information already provided, the Android quickstart tutorial also recommends stripping out ABIs you don't need to support from the AAR in order to save on size, as the AAR includes support for all ABIs by default. There's more on that here: https://www.tensorflow.org/lite/guide/android

Upvotes: 0

yyoon
yyoon

Reputation: 3855

There's a recently added official document on reducing binary size.

https://www.tensorflow.org/lite/guide/reduce_binary_size

Please take a look.

Upvotes: 0

Related Questions