xmos / ai_tools

AI applications and tools
Other
25 stars 10 forks source link

How to build the audio_network example? #918

Closed andresovela closed 4 months ago

andresovela commented 4 months ago

I guess this question is more about how to use the build system.

I ran xmake inside examples/audio_network. I already have the required libs but the build system warns about version mismatches. What's the intended way to manage dependencies using xmake? If I delete all my libs and download the required versions for this example somehow, I'll break other applications that depend on the versions I currently have.

This is the output I get:

Checking build modules
Checking https://www.xmos.com for required libraries
Found version 1.0.0 of lib_src. Download [y/n]? y
Unzip to: /home/andy/dev/projects/xmos/ai_tools/examples/audio_network/./../../.. [y/n]? y
WARNING: Required version of lib_logging is >=2.1.0 and actual version has greater major version: 3.2.0. There could be API incompatibilities.
WARNING: Required version of lib_logging is >=2.0.0 and actual version has greater major version: 3.2.0. There could be API incompatibilities.
WARNING: Required version of lib_mic_array is >=4.6.0 and actual version has greater major version: 5.2.0. There could be API incompatibilities.
WARNING: Required version of lib_xassert is >=3.0.0 and actual version has greater major version: 4.2.0. There could be API incompatibilities.
WARNING: Required version of lib_xassert is >=2.0.0 and actual version has greater major version: 4.2.0. There could be API incompatibilities.
Using build modules: lib_xua(4.1.0) lib_i2c(5.0.0) lib_src(1.0.0) lib_xcore_math(2.2.0) lib_adat(1.2.0) lib_locks(2.2.0) lib_logging(3.2.0) lib_mic_array(5.2.0) lib_spdif(6.1.0) lib_sw_pll(2.2.0) lib_xassert(4.2.0) lib_xud(2.3.2)
Rebuild .build/_iflag.rsp
Analyzing model_audioi16.tflite.cpp
../src/model_audioi16.tflite.cpp:13714:31: warning: Dereferencing a function pointer whose declaration has no fptrgroup. The stack size will not be calculable. [-Wxcore-fptrgroup]
      tflNodes[i].user_data = registrations[used_ops[i]].init(&ctx, (const char*)tflNodes[i].builtin_data, tflNodes[i].custom_initial_data_size);
                              ^
../src/model_audioi16.tflite.cpp:13753:29: warning: Dereferencing a function pointer whose declaration has no fptrgroup. The stack size will not be calculable. [-Wxcore-fptrgroup]
      TfLiteStatus status = registrations[used_ops[i]].prepare(&ctx, &tflNodes[i]);
                            ^
../src/model_audioi16.tflite.cpp:13579:27: warning: Dereferencing a function pointer whose declaration has no fptrgroup. The stack size will not be calculable. [-Wxcore-fptrgroup]
    TfLiteStatus status = registrations[used_ops[i]].invoke(&ctx, &tflNodes[i]);
                          ^
3 warnings generated.
Analyzing support.cpp
Analyzing Util.cpp
Analyzing data_path.c
Analyzing dsp.c
../src/dsp.c:8:10: fatal error: 'src_ff3_fir_coefs.h' file not found
#include "src_ff3_fir_coefs.h"
         ^
1 error generated.
xmake[1]: *** [.build/src/dsp.c.pca.xml.decouple] Error 1
xmake: *** [analyze] Error 2

I'll appreciate any guidance here :)

henkmuller commented 4 months ago

Hi Andres,

The version mismatches should mostly be ok; the one exception is the file it downloaded. We're in the process of making the download grab the latest version of GitHub, instead xmake found a really old version on-line!

Remove lib_src and clone GitHub.com/xmos/lib_src in its place.

xmake clean && xmake

and it ought to compile.

The xmake clean is normally not necessary, but replacing a whole library underneath it may confuse the dependencies slightly.

andresovela commented 4 months ago

Thanks, that did get me farther but it failed with this:

Creating audio_network.xe
model_audioi16.tflite.cpp: Warning: Undefined reference to '_ZN6tflite3ops5micro5xcore18Register_XC_pad_v2Ev'
model_audioi16.tflite.cpp: Error: Undefined reference to '_ZN6tflite3ops5micro5xcore18Register_XC_pad_v2Ev'
xmake[1]: *** [bin//audio_network.xe] Error 1
xmake: *** [bin//audio_network.xe] Error 2
henkmuller commented 4 months ago

model_audioi16.tflite.cpp is probably generated with an old version of xcore-opt than the latest; I probably shouldn't have checked it in

andresovela commented 4 months ago

I tried to regenerate the cpp with xcore-opt v1.2.0 (latest?), and it fails with this error:

xcore-opt model_audioi16.tflite -o model_audioi16.tflite
model_audioi16.tflite:0:0: warning: loc("4X"("model_audioi16.tflite":0:0)) : Quadratic approximation error of 17 larger than set threshold of 1, therefore reverting to reference op!
Inspect the output, and if suitable, set a higher threshold with --xcore-quadratic-lookup-error.

Failed to get registration from op code CUSTOM

AllocateTensors() failed
<unknown>:0: error: Could not set up compile
panickal-xmos commented 4 months ago

Hi @andresovela, that's the optimized model. That is probably out-of-date now. denoise_16x8.tflite is the source model. Could you please try with that one?

andresovela commented 4 months ago

Ah I see. I was able to build the example but now I don't really know what it's supposed to do. I ran xrun --xscope bin/audio_network.xe and don't see any output (not sure if there should be or not). I also don't see the evk as an available sound card on my PC.

panickal-xmos commented 4 months ago

This model was prepared to be used in an example app as a CES demo. Let me try to find more information.

henkmuller commented 4 months ago

I think you may have the evaluation kit https://www.xmos.com/xk-evk-xu316 ? The software is designed to run on the multi-channel audio board; the same chip but different audio hardware https://www.xmos.com/xk-audio-316-mc-ab

andresovela commented 4 months ago

Ah okay, yes, I have the XK-EVK-XU316

andresovela commented 4 months ago

I'll close this issue since I don't have the right EVK to test it.