Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow lite in Android App #67699

Open
LiangZhaoSRA opened this issue May 16, 2024 · 4 comments
Open

Tensorflow lite in Android App #67699

LiangZhaoSRA opened this issue May 16, 2024 · 4 comments
Assignees
Labels
comp:lite TF Lite related issues type:bug Bug

Comments

@LiangZhaoSRA
Copy link

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.3

Custom code

Yes

OS platform and distribution

Ubuntu 20.04

Mobile device

Galaxy S24

Python version

3.8

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

Got the following error when try to run a tflite model on GPU:
model
W/System.err(30515): Ignoring failed delegate application: java.lang.IllegalArgumentException: Internal error: Failed to apply delegate: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors.

When I visualize the model using Netron, there is no dynamic-sized tensor (see attached file).
model

Standalone code to reproduce the issue

W/System.err(30515): Ignoring failed delegate application: java.lang.IllegalArgumentException: Internal error: Failed to apply delegate: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors.

Relevant log output

W/System.err(30515): Ignoring failed delegate application: java.lang.IllegalArgumentException: Internal error: Failed to apply delegate: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors.
@google-ml-butler google-ml-butler bot added the type:bug Bug label May 16, 2024
@sawantkumar sawantkumar added the comp:lite TF Lite related issues label May 20, 2024
@sawantkumar
Copy link

hi @LiangZhaoSRA ,

If possible , can you share me the .tflite file please

@LiangZhaoSRA
Copy link
Author

@sawantkumar Attaches is the tflite file. Thanks.
model.zip

@sawantkumar
Copy link

Hi @LiangZhaoSRA ,

I inspected your model using custom code and I found out that your model has dynamic sized tensors . If possible can you provide me the model conversion code.

Dynamic tensors found:
Name: Where_101;StatefulPartitionedCall/Where_101, Shape: [0 1]
Name: Squeeze_83;StatefulPartitionedCall/Squeeze_83, Shape: [0]
Name: GatherV2_83;StatefulPartitionedCall/GatherV2_83;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_78;StatefulPartitionedCall/GatherV2_78;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_79;StatefulPartitionedCall/GatherV2_79;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_71;StatefulPartitionedCall/GatherV2_71;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_66;StatefulPartitionedCall/GatherV2_66;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_67;StatefulPartitionedCall/GatherV2_67;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_59;StatefulPartitionedCall/GatherV2_59;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_54;StatefulPartitionedCall/GatherV2_54;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_55;StatefulPartitionedCall/GatherV2_55;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_12;StatefulPartitionedCall/GatherV2_12;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_13;StatefulPartitionedCall/GatherV2_13;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_26;StatefulPartitionedCall/GatherV2_26;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_27;StatefulPartitionedCall/GatherV2_27;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_40;StatefulPartitionedCall/GatherV2_40;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_41;StatefulPartitionedCall/GatherV2_41;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_5;StatefulPartitionedCall/GatherV2_5;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2;StatefulPartitionedCall/GatherV2;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_1;StatefulPartitionedCall/GatherV2_1;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_47;StatefulPartitionedCall/GatherV2_47;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_42;StatefulPartitionedCall/GatherV2_42;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]
Name: GatherV2_43;StatefulPartitionedCall/GatherV2_43;GatherV2_99/axis;StatefulPartitionedCall/GatherV2_99/axis, Shape: [0]

@sawantkumar sawantkumar added the stat:awaiting response Status - Awaiting response from author label May 28, 2024
@LiangZhaoSRA
Copy link
Author

Hi Sawant,
I converted the torch model to tflite via torch to onnx, onnx to tensorflow and tensorflow to tflite. Attached are the scripts for model conversion. Please let me know if you have any questions. Thanks.
tr2lite.zip

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:lite TF Lite related issues type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants