-
Notifications
You must be signed in to change notification settings - Fork 74.1k
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
TFLite: Support grouped convolutions #40044
Comments
@srjoglekar246 Do you know if anyone is looking into that? |
@srjoglekar246 @talumbau Do you have any information whether this is on the roadmap? |
Hi, |
Sorry for the late reply on this :-(. @talumbau is looking into this, and has a plan forward. We were busy with some other bugs last quarter, but we have a TODO for it to land this quarter. Thanks for your patience! |
news? related: Group convolutions for CPUs |
If I wanted to try and attempt this, where would I start? This seems relevant because in python it's just a different kernel shape. https://www.tensorflow.org/lite/guide/ops_version#change_c_structures_and_kernel_implementation |
Does this issue have any progress? TF version == 2.5.0 experiment model
and convert command |
I know this won't be helpful to everyone, but this is my special work-around so far. If this is confusing, please ignore it. I implemented GoupConvolusion with the standard Conv2D and Split, Concat, although I may have failed to transpose the weights. This model is chaotic. PINTO0309/PINTO_model_zoo#15 I have been waiting for this issue to be resolved for a long time. |
I meet the same problem, when my h5 model trans to tflite, I use tflite to do inference, but conv2d with groups failed. Does this issue have any progress? |
I also faced the same issue. |
I made a work around in my repo Github leondgarse/keras_cv_attention_models, that replacing
We have a discussion here Freezing a trained keras CV attention model #17, where you can find more detail usage. |
Hi,
|
You need to use SELECT OPS. Add the following code for that
|
But inference still fails. I convert and infer this way:
It fails with:
|
Works for me, thx! Tensorflow Verison: 2.7.0 |
Any update on this issue ? Does tflite now support group convolution ? |
System information
Motivation
#25818 added support for native grouped convolutions a year ago. This feature is now also available via Keras layers in the latest nightly release (#36773, #39516).
Converting a model using grouped convolutions to TFLite works fine, though the TFLite runtime currently doesn't support this feature and will throw an error when trying to allocate the Tensors.
It would be great to have this feature available in TFLite in order to have consistent behaviour accross TensorFlow and TFLite. The PRs linked above provide more detail about why this feature something that people would want to use.
Standalone code to reproduce the issue
The issue can be reproduced using this colab notebook.
Any other info / logs
I guess adding a reference implementation and implementing optimized kernels in the XNNPack delegate would be pretty straight forward as it already has native support for grouped convolutions:
tensorflow/tensorflow/lite/delegates/xnnpack/xnnpack_delegate.cc
Line 1072 in add80cd
Though, I am not sure how much effort it would be to support it in the other optimized code paths with Ruy.
If there is a fundamental reason why support for grouped convolutions cannot be added to TFLite it would be great to handle this in the MLIR based converter and translate native TF grouped convolutions to a naive loop based implementation using
tfl.split
andtfl.concat
which would allow people to use TF group convolutions and and fall back to a loop based implementation in TFLite for now.The text was updated successfully, but these errors were encountered: