Skip to content

Conversation

@lgirdwood
Copy link
Member

Integrates Tensorflow micro edition using xtensa optimized kernels into SOF as a module. WIP.

@lgirdwood
Copy link
Member Author

@lyakh see the Readme for the extra steps needed to link archives to the llext module. We are linking a C and C++17 library to the llext module.

@lyakh
Copy link
Collaborator

lyakh commented Apr 2, 2025

@lgirdwood please try this version of your second patch.
0001-WIP-llext-cmake-Add-support-for-passing-more-config-.patch.txt
It works for me for a small dummy library. In llext CMakeLists.txt I then add

@@ -9,4 +9,7 @@ sof_llext_build("drc"
 		../drc_hifi4.c
 		../drc_math_hifi3.c
 	LIB openmodules
+	DEPENDS mytestlib
+	DEPEND_PATH /path/to/testlib/lib
+	INCLUDES /path/to/testlib/include
 )

@lgirdwood
Copy link
Member Author

@lgirdwood please try this version of your second patch. 0001-WIP-llext-cmake-Add-support-for-passing-more-config-.patch.txt It works for me for a small dummy library. In llext CMakeLists.txt I then add

@@ -9,4 +9,7 @@ sof_llext_build("drc"
 		../drc_hifi4.c
 		../drc_math_hifi3.c
 	LIB openmodules
+	DEPENDS mytestlib
+	DEPEND_PATH /path/to/testlib/lib
+	INCLUDES /path/to/testlib/include
 )

Thanks, this seems to have done the trick, I've had to add c++, c m and gcc to the depends to link TFLM. Will cleanup and upstream it.

@lgirdwood lgirdwood force-pushed the lrg/topic/tflm branch 2 times, most recently from 486217e to 8e7d05f Compare April 4, 2025 11:04
@lgirdwood lgirdwood force-pushed the lrg/topic/tflm branch 3 times, most recently from 10042e9 to c3cfacb Compare April 13, 2025 14:34
@lgirdwood lgirdwood changed the title [SKIP SOFCI TEST] WIP: Add tensorflow micro module. staging: Add tensorflow micro module. Apr 13, 2025
@lgirdwood lgirdwood marked this pull request as ready for review April 13, 2025 14:35
@lgirdwood
Copy link
Member Author

Ready for staging.

Copy link
Contributor

@jsarha jsarha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to get this to compile, but it failed. The make file tried to look for sources under ${BASE_DIR}/tflm-micro , but the code is cloned under ${BASE_DIR}/tflite-micro.

Copy link
Contributor

@marcinszkudlinski marcinszkudlinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why special scripts/tensorflow-clone.sh script? We do use west, just add the repos there

@lgirdwood
Copy link
Member Author

Tried to get this to compile, but it failed. The make file tried to look for sources under ${BASE_DIR}/tflm-micro , but the code is cloned under ${BASE_DIR}/tflite-micro.

Thanks fixed, the built-in config was using the wrong directory but llext was building fine.

@lgirdwood
Copy link
Member Author

Why special scripts/tensorflow-clone.sh script? We do use west, just add the repos there

That was my initial intention too, but I could only get this working with a west manifest in each child module repo (and this would be difficult/slow to upstream). I think the script is fine to unblock us today as either someone with better west know how or updates to west could fix this in the future.

This is staging quality and adds a TFLM module based on micro_speech example to
do audio classification.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, but nothing worth blocking the PR.

```
CONFIG_CPP=y
CONFIG_STD_CPP17=y
CONFIG_SOF_STAGING=y
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be an overlay alike sof/app/shell_overlay.conf or sof/app/perf_overlay.conf.

g_arena, kArenaSize);

// and allocate the tensors
if (interpreter->AllocateTensors() != kTfLiteOk) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a tflite API question, but wondering can "interpreter" be NULL/nullptr here? Maybe this is ok and the new operator is just overloaded.

@kv2019i kv2019i merged commit 8cd3bb8 into thesofproject:main May 2, 2025
43 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants