-
Notifications
You must be signed in to change notification settings - Fork 10
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
xformer is built with files from tensorflow instead of lib_tflite_micro #924
Comments
Hi Andres, thank you. Let me take a look. Bazel is unfortunately not that straightforward, but the project is tied to it due to the Tensorflow dependency. I didn't quite understand the 8-bit bias. Why would be bias be 8-bit? |
I wrote you an email about the 8-bit bias issue a few days ago. However, this is not relevant to this issue. I was just trying to get the model to move past that problem to see what else needs patching. |
Btw, this is not a suspicion. I confirmed that the symbols being linked come from the tensorflow code: I compiled the project with debug symbols and I ran the following:
|
I figured this one out. I had to add ai_tools/xformer/lib_tflmc.BUILD Lines 5 to 19 in 9b32da3
While it makes sense from a build system point-of-view, I think this is a massive footgun. In my case, I was able to notice that the wrong file was being compiled in because I was trying to add a new function. However, if I had tried to just change an existing function, I'd have wasted even more time chasing myself around the room trying to figure out why my changes are not working. Right now, it's even hard to tell whether there currently are patches that are not being included in xformer due to the source file not being listed in |
Thank you @andresovela for investigating this. Tensorflow and tflite-micro used to be the same repo, but since they split into two repos, it's difficult to manage this in a clean manner. They both use |
That's not a bad idea. I'll propose it upstream and see if I can get a discussion going. |
#928 adds in the namespace changes |
I've spent the last few days trying to integrate some TFLM patches into xformer, but I failed to add some simple changes due to what I now know is duplicated dependencies.
I'll describe how I found out that the xformer build pulls in files from the wrong repository as best as I can:
I wanted to patch in int8 bias support for CONV_2D in TFLM. So I added the following code here (
ai_tools/third_party/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/kernels/conv.cc
):That seemed to work, but it complained about a missing int8_t implementation for
MultiplyByQuantizedMultiplier()
defined here (ai_tools/third_party/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/kernels/internal/common.h
).So I proceeded to add the missing function both to
common.h
andcommon.cc
located inai_tools/third_party/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/kernels/internal/
, but the linker somehow does not see the implementation I just added inai_tools/third_party/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/kernels/internal/common.cc
.After some experimentation, I found out that if I removed my changes to conv.cc (the diff shown above is no longer relevant from now on), I could actually comment out the int32/int64 impls for
MultiplyByQuantizedMultiplier()
incommon.cc
, but leave the declarations incommon.h
untouched, and the program would still build. The linker somehow is able to find the implementations for these functions elsewhere. Note that if I remove the function prototypes fromcommon.h
, the program does not compile anymore:So the conclusion is that the build system is using the function prototypes from
ai_tools/third_party/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/kernels/internal/common.h
, but it is not using the implementations fromai_tools/third_party/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/kernels/internal/common.cc
.After two days of investigation, I found out that the implementations being used are actually from
ai_tools/xformer/bazel-xformer/external/org_tensorflow/tensorflow/lite/kernels/internal/common.cc
. It looks like this is a copy of the tensorflow repo that gets downloaded by Bazel when you build xformer.I found this comment in the BUILD file:
ai_tools/xformer/BUILD
Lines 258 to 264 in 9b32da3
All of this is to say that I find this duplication rather unintuitive, and it results in xformer unintentionally being built not with the source code from https://github.com/xmos/lib_tflite_micro, but rather code from https://github.com/tensorflow/tensorflow
I am not familiar with the Bazel build system, so I haven't been able to find a solution for this yet.
The text was updated successfully, but these errors were encountered: