tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone
https://tensorflow.org
Apache License 2.0
182.68k stars 73.89k forks source link

TFLite: cyclic dependency error Tflite simple opaque delegate #65146

Closed suyash-narain closed 1 week ago

suyash-narain commented 1 month ago

I am using tf v2.14 and would like to build tflite opaque delegate such that its references are included in the tflite shared library libtensorflowlite.so

when i include simple_opaque_delegate build targets in the tflite BUILD file //tensorflow/lite/BUILD, I get the cyclic dependency error:

ERROR: /tensorflow/tensorflow/lite/BUILD:479:23: in cc_library rule //tensorflow/lite:framework_stable: cycle in dependency graph:
    //tensorflow/lite:libtensorflowlite.so (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
    //tensorflow/lite/kernels:builtin_ops_all_linked (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
.-> //tensorflow/lite:framework_stable (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite:cc_api_stable (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/delegates/external:external_delegate (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/delegates/utils:simple_opaque_delegate (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/c:c_api_experimental (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/c:c_api (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/core/c:c_api (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite:create_op_resolver_with_builtin_ops (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/core:create_op_resolver_with_builtin_ops (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/core/kernels:builtin_ops (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/kernels:builtin_op_kernels (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
|   //tensorflow/lite/kernels:variable_op_kernels (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
`-- //tensorflow/lite:framework_stable (adc6a2edc02c0f50690f56ac867f112f9172c147f91c4ef0c8b89d477f7c8720)
ERROR: analysis of target '//tensorflow/lite:libtensorflowlite.so' failed; build aborted

I add the build target below this line: https://github.com/tensorflow/tensorflow/blob/50d63587561074139dba4053c8023d5ea8fd6cf7/tensorflow/lite/BUILD#L750 adding it as a dep to build the tensorflowlite shared library //tensorflow/lite/delegates/utils:simple_opaque_delegate

how do i ensure simple_opaque_delegate is built and its symbols present in the tensorflowlite shared library? If i replace simple_opaque_delegate with simple_delegate, i don't get this error though and shared library builds perfectly. thanks

LakshmiKalaKadali commented 3 weeks ago

Hi @suyash-narain, As per my knowledge, the error you are encountering is a classic cyclic dependency issue when building the TensorFlow Lite library. First try the following commands to resolve the cyclic dependency. git submodule foreach git clean -dfx git submodule update and instead of including simple_opaque_delegate directly in libtensorflowlite.so, try to build it as a separate static library. This library can then be linked with applications that need the delegate functionality, without requiring it to be part of the core TensorFlow Lite library. Have you tried with latest TF 2.16.1 stable version?. If not resolved with this, please help us with reproducible code to resolve the issue. Thank You

github-actions[bot] commented 2 weeks ago

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.

github-actions[bot] commented 1 week ago

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.

google-ml-butler[bot] commented 1 week ago

Are you satisfied with the resolution of your issue? Yes No