tflite-android-transformers icon indicating copy to clipboard operation
tflite-android-transformers copied to clipboard

New method to set shape of model inputs

Open fuzhenxin opened this issue 4 years ago • 1 comments

For tensorflow>=2.2.0, the model._set_inputs failed in https://github.com/huggingface/tflite-android-transformers/blob/dcd6da1bfb28e3cd6bc83b58a112cdcd3d6cc2fe/models_generation/gpt2.py#L7 , and the model.inputs and model.outpus are all None. The following error will happen when running in Android: java.lang.IllegalStateException: Internal error: Unexpected failure when preparing tensor allocations: tensorflow/lite/kernels/kernel_util.cc:249 d1 == d2 || d1 == 1 || d2 == 1 was not true. For tensorflow<=2.1.0, the error will not happen.

The added code set inputs shape of model by adding an additional layer, and it works for both tensorflow>=2.2 and tensorflow<2.2

fuzhenxin avatar Jun 28 '20 16:06 fuzhenxin

Thank you. Can confirm this is working and necessary in TF >=2.2

jipson7 avatar Jul 06 '20 13:07 jipson7