-
Notifications
You must be signed in to change notification settings - Fork 74k
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
Unable to Import and Use FlexDelegate in TensorFlowLite in iOS #67538
Comments
@tanpengshi The FlexDelegate functionality is integrated within the TensorFlow Lite interpreter itself when built with Select Ops enabled. Could you please upgrade to the latest TF version and let us know as the older TF versions are not actively supported. Thank you! |
I have tried invoking the interpreter and I get the error
TensorFlow Lite Error: Select TensorFlow op(s), included in the given model, is(are) not supported by this interpreter. Make sure you apply/link the Flex delegate before inference. For the Android, it can be resolved by adding "org.tensorflow:tensorflow-lite-select-tf-ops" dependency. See instructions: https://www.tensorflow.org/lite/guide/ops_select I have already "import TensorFlowLiteSelectTfOps" in my Swift file. I have accidentally deleted the CoreMLDelegate and also the MetalDelegate from the library. Would it cause this error? I have deleted these libraries and I don't know how to recover them. When I do:
The files are still missing. I really appreciate your help! I have come very close to the solution for my App! |
@tanpengshi Directly recovering deleted libraries from within your project isn't possible. Could you try to use the latest TFlite version as newer versions might include these delegates within the framework itself, eliminating the need for separate libraries. After reinstalling/updating, clean and rebuild your project to ensure the changes take effect. Thank you! |
Are you suggesting that I recreate a new project? Now i proceed to try a more conventional method using the Podfile:
But when I build my project, I get: When I check the 'Pods' directory, I don't see a 'resources-to-copy-FacialRecognition' file |
I am now able to solved the issue above and the TensorFlow Lite model with SelectOps is able to successfully run by following the suggestion here: However my app size is over 200MB because of the library! Hence, I need to do a Selective Build which effectively return me to the first solution. In my Podfile, I did for the first solution:
In my TensorFlowLiteSwift.podspec file, I have:
But using this method, with MetalDelegate and CoreMLDelegate libraries deleted, I have FlexDelegate not found error. |
@tanpengshi Thank you for the update. Glad the issue has been resolved. |
Sure, we can close this issue, and I will open a next one regarding the new issue |
@tanpengshi Thank you! |
IDE: Xcode 15
Platform: iOS17
TensorFlow version: r2.9
I am developing both iOS and Android apps that are running with TensorFlow Lite model. Because my model uses LSTM, I have to make use of TFSelectOps.
In addition, because the TensorFlowLiteSelectTFOps library is large in memory size, I have to do a selective build. After much effort, I have succeeded in making my TensorFlowLite model running smoothly on the Android app based on the selectively built libraries.
On the iOS however, I used a bazel build:
to generate the:
After that I edited the TensorFlowLiteSwift.podspec and TensorFlowLiteSelectTfOps.podspec to include these 2 frameworks, then I successfully built the library on XCode, using Podfile. I have gone very far and I am able to import TensorFlowLiteSelectTfOps in my codes and run the "Interpreter" variable:
There are no errors which is good, but the problem is I cannot find and import the FlexDelegate library because my TFlite model runs on SelectOps. There are no FlexDelegate swift files that were being built.
Thanks in advance! And I hope to complete my iOS project.
The text was updated successfully, but these errors were encountered: