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

Didn't find op for builtin opcode 'CONV_2D' version '3'. An older version of this builtin might be supported. Are you using an old TFLite binary with a newer model? #2645

Closed
rishita-asl opened this issue Jul 28, 2024 · 6 comments
Labels

Comments

@rishita-asl
Copy link

I am trying to run the Mini speech commands example and am facing the error Didn't find op for builtin opcode 'CONV_2D' version '3'. An older version of this builtin might be supported. Are you using an old TFLite binary with a newer model? at setup() and then error tflite micro requested feature data size 536907080 doesn't match 1960 in loop().

I trained my model following the example : https://colab.research.google.com/github/tensorflow/tflite-micro/blob/main/tensorflow/lite/micro/examples/micro_speech/train/train_micro_speech_model.ipynb#scrollTo=rNQdAplJV1fz
with the only change of WANTED_WORDS = "on,off,stop,go"

TFLite micro example: only changed the g_model[] with the model generated after training using the above notebook, and the kCategoryLabels values as "on, off, stop, go"

Tensorflow version : 2.15.0
Board: Arduino BLE sense Nano

@dmckinnon
Copy link

I had exactly the same problems, and can now offer some help. Firstly, on the opcode front, you're using tensorflow 2.15 (I used 2.16 cos that's what I had locally). You need 1.x - and yeah, Colab says "colab doesn't like tensorflow 1, use tensorflow 2" really unhelpfully. However, this was someone else's experience: https://discuss.tinyml.seas.harvard.edu/t/micro-speech-example-from-tensorflow-on-an-esp32/376/7
Tensorflow 1 worked for them since TF 2 uses a Conv2d instead of a DWConv. I'm going to give that a go and see if I can get this working. Ideally I keep this tab open and report back with my experience, but if this is my final answer since I forgot, apologies to all future readers. Also, I hope tflite-micro updates with tf 2 opcodes cos that's going to get annoying for other models

As for the feature data size error, I also encountered this - this was so confusing! Is that memory getting stomped on or something? Never figured out if this was the case, but the example creates the feature_provider as a global pointer, and then makes a static instance of the object in setup() and redirects the global pointer to this. I made a global object instead of a global pointer and this avoided the problem.
It's worth noting that when I compiled and ran the example, this did not happen, only when I added my own model. My guess is that since the size of my own model changed, there is a memory clobbering happening in heap and by putting it on stack this bypassed the problem?

@rishita-asl
Copy link
Author

I was able to run the example by locally setting up Python 3.6 and Tensorflow version 1.15 to train the model. Could you share the code where you have modified the feature provider to make it an global object instead. Thanks in advance.

Also for training the model in python instead of using the example train.py have you had any success in generating your own model and running it using tensorflow lite? I tried creating a model by extracting the Spectogram features and then MFCC from the audio wav files and training the a conv2D model similar to how its implemented in the train.py example but wasn't able to run the inference using tf lite micro library. Any suggestions/help would be really appreciated.

@dmckinnon
Copy link

i don't have the code on me now but it was just making the global pointer a global object and then creating it before setup(), like
`
FeatureProvider f;
// the line that creates the buffer here
f = FeatureProvider(kFeatureSize, theBufferArgItNeeds);

void setup()
{
// ... etc
`
and then in the two other references i think you just change -> to . of course

The only customisations I made to the model were changing the words detected, nothing actually structural, so can't help there sorry. Cheers for the version suggestions, going to try that.

@dmckinnon
Copy link

For posterity I used Tensorflow 1.15 and managed to retrain the model and get this working on my arduino as well, same setup as rishita-asl. Note that tensorflow 1.15 doesn't like any python above 3.7, so you probably need a pyenv with just 3.6. If you are unfamiliar, use conda like I did cos it made this super easy

Copy link
Contributor

"This issue is being marked as stale due to inactivity. Remove label or comment to prevent closure in 5 days."

@github-actions github-actions bot added the Stale label Sep 16, 2024
Copy link
Contributor

"This issue is being closed because it has been marked as
stale for 5 days with no further activity."

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants