tensorflow / tensorflow/tflite-support

TF Lite NNAPI delegate doesn't work with tf.keras.layers.CenterCrop layer

Open
#719 8 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
441
Forks
146
PR merge metrics
No merged PRs in 30d

Description

Not sure if this is the correct place to report this problem, or I should report it at tensorflow/tensorflow repository.

As said here, using Keras preprocessing layers as part of our model is recommended because:

Data augmentation will run on-device, synchronously with the rest of your layers, and benefit from GPU acceleration.

When you export your model using model.save, the preprocessing layers will be saved along with the rest of your model. If you later deploy this model, it will automatically standardize images (according to the configuration of your layers). This can save you from the effort of having to reimplement that logic server-side.

Unfortunately, if you add tf.keras.layers.CenterCrop preprocessing layer to your model, you will get this error when you try to run the converted tflite model using NNAPI delegate:
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.

I don't see why would CenterCrop layer cause dynamic-sized tensors if we explicitly specify inputShape, seems like a bug. Using other Keras preprocessing layers like tf.keras.layers.Rescaling work just fine.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.