Android C/C++ API 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
@Qinlong275,
For using flex ops for C/C++ we need to enable Flex delegate by linking a TensorFlow Lite Flex delegate shared library. You can build it with Bazel as the following command.


> bazel build -c opt --config=monolithic tensorflow/lite/delegates/flex:tensorflowlite_flex

Also please take a look at this issue for reference.
https://github.com/tensorflow/tensorflow/issues/61495
https://github.com/tensorflow/tensorflow/issues/61743

Thank you!

 > @Qinlong275为了 在 C/C++ 中使用 Flex 操作，我们需要通过链接 TensorFlow Lite Flex 委托共享库来启用 Flex 委托。您可以使用 Bazel 构建它，如下命令。
> 
> > bazel build -c opt --config=monolithic tensorflow/lite/delegates/flex:tensorflowlite_flex
> 
> 还请您看看这个问题并提供参考。 [#61495 ](https://github.com/tensorflow/tensorflow/issues/61495) #61743
> 
> 谢谢你！
I want to build the tensorflowlite_flex so to use on android platform.
I build tensorflowlite_flex occur the follow error!  (Mac M1 pro, bazel verison 6.3.2-homebrew)
Repository rule _tf_http_archive defined at:
  /Users/qinlong/android/tensorflow/third_party/repo.bzl:89:35: in <toplevel>
ERROR: /private/var/tmp/_bazel_qinlong/4d0b12327583c8b4e37f0824509a394f/external/llvm-project/llvm/BUILD.bazel:158:11: Illegal ambiguous match on configurable attribute "defines" in @llvm-project//llvm:config:
@llvm-project//llvm:macos_arm64
@bazel_tools//src/conditions:darwin
Multiple matches are not allowed unless one is unambiguously more specialized or they resolve to the same value. See https://bazel.build/reference/be/functions#select.
ERROR: Analysis of target '//tensorflow/lite/delegates/flex:tensorflowlite_flex' failed; build aborted: 
INFO: Elapsed time: 6.111s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 1 target confi\
![企业微信20231220-100627](https://github.com/tensorflow/tensorflow/assets/30921763/6b3a58c3-1cdb-41c9-b00f-f05f90c91994)
![企业微信20231220-100644](https://github.com/tensorflow/tensorflow/assets/30921763/573d56d9-635f-4a65-8087-baf8c32b4226)
 > @Qinlong275, For using flex ops for C/C++ we need to enable Flex delegate by linking a TensorFlow Lite Flex delegate shared library. You can build it with Bazel as the following command.
> 
> > bazel build -c opt --config=monolithic tensorflow/lite/delegates/flex:tensorflowlite_flex
> 
> Also please take a look at this issue for reference. #61495 #61743
> 
> Thank you!

Fine, I resolve the problem by the follow code:
bazel build -c opt \
--config=monolithic \
--config=android_arm64 tensorflow/lite/delegates/flex:tensorflowlite_flex
(add the --config=android_arm64 param, then build libtensorflowlite_flex.so success!!!) 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/62662">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/62662">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

tf 2.12.0

### Custom code

Yes

### OS platform and distribution

mac apple m1; android studio

### Mobile device

HuaWei Nova6

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

I run my custom tflite model on androidstudio use C API(SO library), then occur these error:

  E  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
2023-12-19 12:44:34.993  3039-5562  tflite                  com...cent.karaoke.tNetInterpretApp  E  Node number 622 (FlexDepthwiseConv2dNative) failed to prepare.
2023-12-19 12:44:34.993  3039-5562  tflite                  com...cent.karaoke.tNetInterpretApp  E  Failed to allocate tensors!

I think maybe  the AcquireFlexDelegate has not work?, I find the source code, the AcquireFlexDelegate looks like a __attribute__((weak)) symbal.  I have loaded the libtensorflowlite_gpu_jni.so before start the interpret.



### Standalone code to reproduce the issue

```shell
if (is_android)
    #依赖的三方库
    add_library(TFLITE_CORE SHARED IMPORTED)
    set_target_properties(TFLITE_CORE PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/tflite/libs/android/${ANDROID_ABI}/libtensorflowlite_jni.so)

    add_library(TFLITE_FLEX SHARED IMPORTED)
    set_target_properties(TFLITE_FLEX PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/tflite/libs/android/${ANDROID_ABI}/libtensorflowlite_flex_jni.so)

    add_library(TFLITE_GPU_DELEGATE SHARED IMPORTED)
    set_target_properties(TFLITE_GPU_DELEGATE PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/tflite/libs/android/${ANDROID_ABI}/libtensorflowlite_gpu_jni.so)

    target_link_libraries(TNET_SOURCE
            TFLITE_CORE
            TFLITE_FLEX
            TFLITE_GPU_DELEGATE
            )

endif ()
```


### Relevant log output

_No response_