Tensorflow TF ops - CPU Factory not registered
@BasilZinsli,
Could you please share the colab link or simple standalone code with supporting files to reproduce the issue in our environment and the tensorflow version you are using. It helps us in localizing the issue faster. Thank you! @tilakrayal 
Thank you for your fast response! I work with @BasilZinsli on this project. Hereafter you can find the whole project as zip:

https://drive.proton.me/urls/GPQ76SS1J4#WKIT4NEkhHBH

Note that the folder "PA_Emotion_Detection_Python_Model" contains a legacy project which the current project was built upon. The actual code is in "Voiceswap". Spleeter.swift is the class of interest. We converted the 2stems spleeter model into tflite and want to run it on iOS. 

Thank you in advance! @tilakrayal and to reproduce the error, just hit the play button on the app after building it. 
- currently the app is using the selfmade build of TFOPS via bazel as mentioned above.
- runing the pod installed version for TFOPS also throws an error which also should be solved in my opinion.

thanks for your help! 
Best Regards Hi @fabiancannaheim, @BasilZinsli, I tried building your project but I run into this issue:

```
One of the paths in DEVELOPMENT_ASSET_PATHS does not exist: /path/to/App/AudioPlayer/Prevew Content
```

I checked that path from where I unzipped the archive and that path does indeed not exist, should I remove this from Development Assets? Are the development assets in some other location in the archive? Let me know how you think I should best proceed. Thanks. Hi @pkgoogle 
Thanks for answering. I guess the preview does not work without the simulater anyways, it is becuase of the Pods.
You can remove it I guess, or create the folder it asks for. But the preview does not need to work to reproduce the problem i guess.

Let me know if I can help further.
Thanks again

 @pkgoogle oh and very important, please use the AppV1 branch. Totally forgot to tell you Hi @BasilZinsli, Now it's complaining about these 2 models missing (2stems and 4stems):

![image](https://github.com/tensorflow/tensorflow/assets/132095473/239af99f-216c-4729-afda-ca295329de89)

I'm not understanding what you mean by the AppV1 branch, is that a subdirectory in the uploaded zip or are you referring to a repo? If it is a repo, can you point me to the repo?
 Hey @pkgoogle 

Sorry i made a mistake mistake in my thinking. It is a git repo but we send you the essential part of it as ZIP. So no branches for you. 

I see the mistake, we had the models saved in a different folder, i will send them here:
https://drive.google.com/file/d/1nWW3TIvbg_f4usNddwwglwYSOqDbIoQx/view?usp=sharing

Make sure to drag them into the voiceswap and hit copy items so the files a correctly linked into the xcode project.

Thank you!


 Hi @BasilZinsli, so I followed your instructions and I was actually able to run the app and hit play on Emulator. I did do this so that it could run on emulator:

![image](https://github.com/tensorflow/tensorflow/assets/132095473/0fd027b1-48cb-4641-a1cf-6e9b43af4275)

Console output (I hit play a couple of times):

```
2024-04-12 13:36:46.278163-0700 App[17567:1256634] [SwiftUI] Reading a Namespace property outside View.body. This will result in identifiers that never match any other identifier.
2024-04-12 13:36:47.379210-0700 App[17567:1257886] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000720540> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2024-04-12 13:36:47.553785-0700 App[17567:1257964] [AMCP]  38411          HALC_ProxyIOContext.cpp:1329  HALC_ProxyIOContext::IOWorkLoop: skipping cycle due to overload
2024-04-12 13:36:47.568176-0700 App[17567:1256634] Initialized TensorFlow Lite runtime.
INFO: Initialized TensorFlow Lite runtime.
2024-04-12 13:36:48.260436-0700 App[17567:1257964] [AMCP]  38411          HALC_ProxyIOContext.cpp:1329  HALC_ProxyIOContext::IOWorkLoop: skipping cycle due to overload
0.0
0.1546936
[0.0, 0.1546936, 0.06842053, 0.02947998, 0.12677014, 0.21240246, 0.20684814, 0.15496826, 0.22085571, 0.23931885, 0.34414673, 0.39282238, 0.26080322, 0.35849, 0.43966675, 0.36972058, 0.32791138, 0.40118408, 0.4326172, 0.2223512, 0.29861462, 0.40655518, 0.23242188, 0.16989136, 0.16012585, 0.20785522, 0.1984253, 0.14593518, 0.09185791, 0.05581665, 0.14602661, 0.14328015, 0.051300168, -0.026397824, 0.0019836426, 0.07058716, 0.08828735, -0.14208972, -0.2237854, 0.03527832, -0.022949219, -0.15008545, -0.19873047, -0.22698975, -0.20520008, -0.12213135, -0.045654297, -0.21685791, -0.29281628, -0.18814099, -0.13778675, -0.04638672, -0.0071105957, 0.041412354, 0.17886353, 0.11175537, 0.058380127, 0.1972351, 0.2889099, 0.38058472, 0.414734, 0.27072144, 0.3463745, 0.5189514, 0.44750965, 0.32089233, 0.2972107, 0.41915894, 0.6077881, 0.47155774, 0.24908447, 0.4510498, 0.48709106, 0.33963013, 0.29187024, 0.31436157, 0.21914673, 0.09072876, 0.24047852, 0.22073364, 0.18740833, 0.29693604, 0.10269165, 0.034851074, 0.13198853, 0.013793945, 0.13748169, 0.24127197, 0.14208984, 0.12869263, 0.13903809, 0.101379395, 0.071624875, 0.2015382, 0.23123157, 0.023101807, 0.069610596, 0.110687256, 0.019653201, 0.090026855]
TEST1
[1, 2, 44100]
Input details: Tensor(name: "waveform", dataType: App.Tensor.DataType.float32, shape: App.Tensor.Shape(rank: 2, dimensions: [1, 2]), data: 8 bytes, quantizationParameters: nil)
TEST2
TEST3
TEST4
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
TensorFlow Lite Error: Node number 41 (FlexTranspose) failed to prepare.
Error processing Spleeter: Must call allocateTensors().
First Chunk played.
<AVAudioPCMBuffer@0x6000007ed600: 176400/176400 bytes> 0
Timer tick - Elapsed Time: 0.0010600090026855469 seconds
All chunks have been played.
2024-04-12 13:36:51.025764-0700 App[17567:1257878] [SwiftUI] Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.
Timer tick
0.0
0.1546936
[0.0, 0.1546936, 0.06842053, 0.02947998, 0.12677014, 0.21240246, 0.20684814, 0.15496826, 0.22085571, 0.23931885, 0.34414673, 0.39282238, 0.26080322, 0.35849, 0.43966675, 0.36972058, 0.32791138, 0.40118408, 0.4326172, 0.2223512, 0.29861462, 0.40655518, 0.23242188, 0.16989136, 0.16012585, 0.20785522, 0.1984253, 0.14593518, 0.09185791, 0.05581665, 0.14602661, 0.14328015, 0.051300168, -0.026397824, 0.0019836426, 0.07058716, 0.08828735, -0.14208972, -0.2237854, 0.03527832, -0.022949219, -0.15008545, -0.19873047, -0.22698975, -0.20520008, -0.12213135, -0.045654297, -0.21685791, -0.29281628, -0.18814099, -0.13778675, -0.04638672, -0.0071105957, 0.041412354, 0.17886353, 0.11175537, 0.058380127, 0.1972351, 0.2889099, 0.38058472, 0.414734, 0.27072144, 0.3463745, 0.5189514, 0.44750965, 0.32089233, 0.2972107, 0.41915894, 0.6077881, 0.47155774, 0.24908447, 0.4510498, 0.48709106, 0.33963013, 0.29187024, 0.31436157, 0.21914673, 0.09072876, 0.24047852, 0.22073364, 0.18740833, 0.29693604, 0.10269165, 0.034851074, 0.13198853, 0.013793945, 0.13748169, 0.24127197, 0.14208984, 0.12869263, 0.13903809, 0.101379395, 0.071624875, 0.2015382, 0.23123157, 0.023101807, 0.069610596, 0.110687256, 0.019653201, 0.090026855]
TEST1
[1, 2, 44100]
Input details: Tensor(name: "waveform", dataType: App.Tensor.DataType.float32, shape: App.Tensor.Shape(rank: 2, dimensions: [44100, 2]), data: 352800 bytes, quantizationParameters: nil)
TEST2
TEST3
TEST4
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
TensorFlow Lite Error: Node number 41 (FlexTranspose) failed to prepare.
Error processing Spleeter: Must call allocateTensors().
First Chunk played.
<AVAudioPCMBuffer@0x6000007ee1e0: 176400/176400 bytes> 0
Timer tick - Elapsed Time: 0.0001779794692993164 seconds
All chunks have been played.
2024-04-12 13:37:33.643700-0700 App[17567:1260166] [SwiftUI] Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.
Timer tick
0.0
0.1546936
[0.0, 0.1546936, 0.06842053, 0.02947998, 0.12677014, 0.21240246, 0.20684814, 0.15496826, 0.22085571, 0.23931885, 0.34414673, 0.39282238, 0.26080322, 0.35849, 0.43966675, 0.36972058, 0.32791138, 0.40118408, 0.4326172, 0.2223512, 0.29861462, 0.40655518, 0.23242188, 0.16989136, 0.16012585, 0.20785522, 0.1984253, 0.14593518, 0.09185791, 0.05581665, 0.14602661, 0.14328015, 0.051300168, -0.026397824, 0.0019836426, 0.07058716, 0.08828735, -0.14208972, -0.2237854, 0.03527832, -0.022949219, -0.15008545, -0.19873047, -0.22698975, -0.20520008, -0.12213135, -0.045654297, -0.21685791, -0.29281628, -0.18814099, -0.13778675, -0.04638672, -0.0071105957, 0.041412354, 0.17886353, 0.11175537, 0.058380127, 0.1972351, 0.2889099, 0.38058472, 0.414734, 0.27072144, 0.3463745, 0.5189514, 0.44750965, 0.32089233, 0.2972107, 0.41915894, 0.6077881, 0.47155774, 0.24908447, 0.4510498, 0.48709106, 0.33963013, 0.29187024, 0.31436157, 0.21914673, 0.09072876, 0.24047852, 0.22073364, 0.18740833, 0.29693604, 0.10269165, 0.034851074, 0.13198853, 0.013793945, 0.13748169, 0.24127197, 0.14208984, 0.12869263, 0.13903809, 0.101379395, 0.071624875, 0.2015382, 0.23123157, 0.023101807, 0.069610596, 0.110687256, 0.019653201, 0.090026855]
TEST1
[1, 2, 44100]
Input details: Tensor(name: "waveform", dataType: App.Tensor.DataType.float32, shape: App.Tensor.Shape(rank: 2, dimensions: [44100, 2]), data: 352800 bytes, quantizationParameters: nil)
TEST2
TEST3
TEST4
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
TensorFlow Lite Error: Node number 41 (FlexTranspose) failed to prepare.
Error processing Spleeter: Must call allocateTensors().
First Chunk played.
<AVAudioPCMBuffer@0x6000007e0a20: 176400/176400 bytes> 0
Timer tick - Elapsed Time: 6.198883056640625e-05 seconds
All chunks have been played.
2024-04-12 13:37:40.196745-0700 App[17567:1257879] [SwiftUI] Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.
Timer tick
0.0
0.1546936
[0.0, 0.1546936, 0.06842053, 0.02947998, 0.12677014, 0.21240246, 0.20684814, 0.15496826, 0.22085571, 0.23931885, 0.34414673, 0.39282238, 0.26080322, 0.35849, 0.43966675, 0.36972058, 0.32791138, 0.40118408, 0.4326172, 0.2223512, 0.29861462, 0.40655518, 0.23242188, 0.16989136, 0.16012585, 0.20785522, 0.1984253, 0.14593518, 0.09185791, 0.05581665, 0.14602661, 0.14328015, 0.051300168, -0.026397824, 0.0019836426, 0.07058716, 0.08828735, -0.14208972, -0.2237854, 0.03527832, -0.022949219, -0.15008545, -0.19873047, -0.22698975, -0.20520008, -0.12213135, -0.045654297, -0.21685791, -0.29281628, -0.18814099, -0.13778675, -0.04638672, -0.0071105957, 0.041412354, 0.17886353, 0.11175537, 0.058380127, 0.1972351, 0.2889099, 0.38058472, 0.414734, 0.27072144, 0.3463745, 0.5189514, 0.44750965, 0.32089233, 0.2972107, 0.41915894, 0.6077881, 0.47155774, 0.24908447, 0.4510498, 0.48709106, 0.33963013, 0.29187024, 0.31436157, 0.21914673, 0.09072876, 0.24047852, 0.22073364, 0.18740833, 0.29693604, 0.10269165, 0.034851074, 0.13198853, 0.013793945, 0.13748169, 0.24127197, 0.14208984, 0.12869263, 0.13903809, 0.101379395, 0.071624875, 0.2015382, 0.23123157, 0.023101807, 0.069610596, 0.110687256, 0.019653201, 0.090026855]
TEST1
[1, 2, 44100]
Input details: Tensor(name: "waveform", dataType: App.Tensor.DataType.float32, shape: App.Tensor.Shape(rank: 2, dimensions: [44100, 2]), data: 352800 bytes, quantizationParameters: nil)
TEST2
TEST3
TEST4
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
TensorFlow Lite Error: Node number 41 (FlexTranspose) failed to prepare.
Error processing Spleeter: Must call allocateTensors().
First Chunk played.
<AVAudioPCMBuffer@0x600000753c40: 176400/176400 bytes> 0
Timer tick - Elapsed Time: 7.200241088867188e-05 seconds
All chunks have been played.
2024-04-12 13:37:45.869375-0700 App[17567:1260558] [SwiftUI] Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.
Timer tick
```

This doesn't look like your error... can you maybe see if you can get this far? Thanks. hey @pkgoogle 

thanks for your efforts, i will try that out. But as you can see in errorcode, I guess I was already past that error:

Your 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
TensorFlow Lite Error: Node number 41 (FlexTranspose) failed to prepare.

in my Log:

Created TensorFlow Lite delegate for select TF ops.



Excluding Arm64 would simply deactivate the build for Phones right?
Because the problem in my eyes is with the X86 build.


Best wishes Hi @BasilZinsli, I'm having issues integrating the built TensorFlowLiteSelectTfOps.framework with the project, while I work on that, have you tried using this on a real iPhone? This issue might only occur on emulator. This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/65302">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/65302">No</a>

**System information**
-iMac Retina 5K, 27-inch, 2017
-OS 13.5.2


**Provide the text output from tflite_convert**

```
2024-04-09 10:54:09.109505+0200 App[91449:6577901] Initialized TensorFlow Lite runtime.
INFO: Initialized TensorFlow Lite runtime.
2024-04-09 10:54:09.110104+0200 App[91449:6577901] Created TensorFlow Lite delegate for select TF ops.
INFO: Created TensorFlow Lite delegate for select TF ops.
TensorFlow Lite Error: Failed to initialize TensorFlow context: CPU Factory not registered. Did you link in threadpool_device?
TensorFlow Lite Error: Restored original execution plan after delegate application failure.
Failed to create the interpreter: Failed to create the interpreter.
Failed to create Spleeter instance.
```

**Standalone code to reproduce the issue** 
Let me know if you want to recieve the xcode project as ZIP, it is a big project
Iphone function has not been tested yet. Issue is on simulater

**Any other info / logs**

We tried many things so far found in other posts.
Bazel build tfops framwork to include x86 support:

bazel build -c opt --config=ios_x86_64 \       
  //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework

Linker Flags:
$(inherited) -ObjC -l"c++" -framework TensorFlowLite -framework TensorFlowLiteSelectTfOps -u _TF_AcquireFlexDelegate

this flag:
-u _TF_AcquireFlexDelegate
eliminated the error that flex delegate could have been found but now with own TF ops Framwork and this flag this error persists.


Without own build (using nightly build PODs) not even TF ops could been found.

Thanks for any help





