react-native-fast-tflite icon indicating copy to clipboard operation
react-native-fast-tflite copied to clipboard

Mhp23 patch 1

Open Mhp23 opened this issue 1 year ago • 6 comments

  • Excluded arm64 simulators from the pod
  • Updating docs to run app on iOS simulators

Since the current stable version of TensorFlow Lite doesn't support arm64 simulators, building the app is failing for Apple Silicon (It appears that this issue is resolved in the TensorFlow Lite nightly version). Therefore, in this PR, the arm64 simulator is excluded, and instructions for running the app directly on x86_64 architecture simulators from the command line are added to the documentation.

Mhp23 avatar Jan 23 '24 09:01 Mhp23

Hey - thanks for your PR!

It appears that this issue is resolved in the TensorFlow Lite nightly version

I am building TensorFlow Lite from source from their current main - so if they fixed the issue, it should be resolved. I did manage to run the example app on a simulator before, are you seeing errors or what was the motivation of this PR?

mrousavy avatar Jan 23 '24 10:01 mrousavy

@mrousavy You're welcome! Running the app on a physical device is OK, but when I've trying to run the app on a simulator with arm64 architecture, it threw the following errors and for run the app, I had to use Rosetta, and I decided to submit this PR that might be helpful for running the app on simulator with x86_64 architecture on Apple silicon chips. (Additionally, because TF doesn't support arm64 yet I excluded that)

Building for iOS Simulator, but linking in object file built for iOS, file '*/node_modules/react-native-fast-tflite/ios/TensorFlowLiteC.framework/TensorFlowLiteC' for architecture arm64
Linker command failed with exit code 1 (use -v to see invocation)

Mhp23 avatar Jan 23 '24 12:01 Mhp23

Ah I see - I think this approach is not really good since it blocks simulators / makes it harder to use on simulators.

I think we can compile TensorFlowLiteC for simulator as well (see build-tensorflow-ios.sh), I don't have any time to look into this right now though. I'll leave this open for now for reference in the future.

mrousavy avatar Jan 23 '24 13:01 mrousavy

See https://github.com/mrousavy/react-native-fast-tflite/pull/26

mrousavy avatar Jan 23 '24 14:01 mrousavy

Same issue here, why it blocks simulators, I think it'd run in simulator as @Mhp23 mentioned.

Chasty avatar Jan 23 '24 22:01 Chasty

I found this tensorflow PR from 2022 that was supposed to enable tflite to build for arm64 simulators: https://github.com/tensorflow/tensorflow/pull/55777

Is it possible we just need to add --config=ios_sim_arm64 to the build script as indicated in that PR?

computerjazz avatar Feb 23 '24 21:02 computerjazz