Error compiling Arduino Library for XIAO ESP32S3 Sense

Question/Issue:
Hi all.
I’m trying to deploy a Vision project - just an example - by detecting plants or lamps, but when compiling the project for the XIAO ESP32S3 Sense (same as an ESP32 EYE CAM), I get the following errors:

/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp: In function 'TfLiteStatus tflite::{anonymous}::Prepare(TfLiteContext*, TfLiteNode*)':
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp:1789:67: error: either all initializer clauses should be designated or none of them should be
 1789 |                                 .channels = input->dims->data[3], 1
      |                                                                   ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp:1793:68: error: either all initializer clauses should be designated or none of them should be
 1793 |                                 .channels = output->dims->data[3], 1
      |                                                                    ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp:1795:80: error: either all initializer clauses should be designated or none of them should be
 1795 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp: In function 'void tflite::{anonymous}::EvalQuantizedPerChannel(TfLiteContext*, TfLiteNode*, const TfLiteConvParams&, const NodeData&, const TfLiteEvalTensor*, const TfLiteEvalTensor*, const TfLiteEvalTensor*, TfLiteEvalTensor*)':
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp:1883:58: error: either all initializer clauses should be designated or none of them should be
 1883 |                                 .channels = input_depth, 1
      |                                                          ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp:1887:59: error: either all initializer clauses should be designated or none of them should be
 1887 |                                 .channels = output_depth, 1
      |                                                           ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/conv.cpp:1889:80: error: either all initializer clauses should be designated or none of them should be
 1889 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp: In function 'void tflite::{anonymous}::EvalQuantizedPerChannel(TfLiteContext*, TfLiteNode*, const TfLiteDepthwiseConvParams&, const NodeData&, const TfLiteEvalTensor*, const TfLiteEvalTensor*, const TfLiteEvalTensor*, TfLiteEvalTensor*)':
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp:1727:58: error: either all initializer clauses should be designated or none of them should be
 1727 |                                 .channels = input_depth, 1
      |                                                          ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp:1731:59: error: either all initializer clauses should be designated or none of them should be
 1731 |                                 .channels = output_depth, 1
      |                                                           ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp:1733:80: error: either all initializer clauses should be designated or none of them should be
 1733 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp: In function 'TfLiteStatus tflite::{anonymous}::Prepare(TfLiteContext*, TfLiteNode*)':
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp:1836:67: error: either all initializer clauses should be designated or none of them should be
 1836 |                                 .channels = input->dims->data[3], 1
      |                                                                   ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp:1840:68: error: either all initializer clauses should be designated or none of them should be
 1840 |                                 .channels = output->dims->data[3], 1
      |                                                                    ^
/home/feiticeir0/Documents/Arduino/libraries/XIAO_Lamps_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/depthwise_conv.cpp:1842:80: error: either all initializer clauses should be designated or none of them should be
 1842 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^

exit status 1

Compilation error: exit status 1

Project ID:
Project ID is: 305878

This is based on this tutorial from edge impulse - https://www.youtube.com/watch?v=2wvbgsjpt2U&ab_channel=EdgeImpulse

It’s an image classification project - Is a lamp or a plant - or nothing.

Context/Use case:

I’m just trying an example to deploy .

Any help would be appreciated. Thank you

1 Like

Hi all.
I’ve solved the problem by using the solution from here:
https://www.hackster.io/mjrobot/tinyml-made-easy-image-classification-cb42ae#toc-connecting-sense-module–expansion-board-2

Just editing the file ei_classifier_config.h in exported Arduino library folder: /scr/edge-impulse-sdk/classifier/:

Disabling #define EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN 1 and set it to 0 will allow the project to compile .

Thank you

5 Likes

Great thanks for sharing the solution @feiticeir0 !

Best

Eoin

Hi all.
I’ve solved the problem by using the solution from here too, in my case I had the same issue, and it was figured out by using the pointed-out solution.

Thanks so much.

Thank you so much for posting the solution as well. Really appreciate this saving my time😁

I don’t think this is the best way to do this. Correct me if I’m wrong, but I think you’re just disabling ESP_NN, which will significantly slow down performance. Instead just fill in the missing property names where it shows the errors (3rd one is .channels and 4th one is .extra)

1 Like

Can you explain in detail. What to do?

c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp: In function 'TfLiteStatus tflite::{anonymous}::Prepare(TfLiteContext*, TfLiteNode*)':
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1789:67: error: either all initializer clauses should be designated or none of them should be
 1789 |                                 .channels = input->dims->data[3], 1
      |                                                                   ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1793:68: error: either all initializer clauses should be designated or none of them should be
 1793 |                                 .channels = output->dims->data[3], 1
      |                                                                    ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1795:80: error: either all initializer clauses should be designated or none of them should be
 1795 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp: In function 'void tflite::{anonymous}::EvalQuantizedPerChannel(TfLiteContext*, TfLiteNode*, const TfLiteConvParams&, const NodeData&, const TfLiteEvalTensor*, const TfLiteEvalTensor*, const TfLiteEvalTensor*, TfLiteEvalTensor*)':
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1883:58: error: either all initializer clauses should be designated or none of them should be
 1883 |                                 .channels = input_depth, 1
      |                                                          ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1887:59: error: either all initializer clauses should be designated or none of them should be
 1887 |                                 .channels = output_depth, 1
      |                                                           ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1889:80: error: either all initializer clauses should be designated or none of them should be
 1889 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp: In function 'void tflite::{anonymous}::EvalQuantizedPerChannel(TfLiteContext*, TfLiteNode*, const TfLiteDepthwiseConvParams&, const NodeData&, const TfLiteEvalTensor*, const TfLiteEvalTensor*, const TfLiteEvalTensor*, TfLiteEvalTensor*)':
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp:1727:58: error: either all initializer clauses should be designated or none of them should be
 1727 |                                 .channels = input_depth, 1
      |                                                          ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp:1731:59: error: either all initializer clauses should be designated or none of them should be
 1731 |                                 .channels = output_depth, 1
      |                                                           ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp:1733:80: error: either all initializer clauses should be designated or none of them should be
 1733 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp: In function 'TfLiteStatus tflite::{anonymous}::Prepare(TfLiteContext*, TfLiteNode*)':
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp:1836:67: error: either all initializer clauses should be designated or none of them should be
 1836 |                                 .channels = input->dims->data[3], 1
      |                                                                   ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp:1840:68: error: either all initializer clauses should be designated or none of them should be
 1840 |                                 .channels = output->dims->data[3], 1
      |                                                                    ^
c:\Users\SHISHIR\Documents\libraries\SafeSightCurrencyIdentification_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\depthwise_conv.cpp:1842:80: error: either all initializer clauses should be designated or none of them should be
 1842 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};
      |                                                                                ^

exit status 1

Compilation error: exit status 1

I am getting this error

So you see the compiler points out all the loose numbers. Although this is a standard way to write this the Arduino compiler doesn’t like it. So instead of writing Type x = {0,1,0} you should write Type x = {y=0, z=1,d=0}

@ThatGuy Thanks for pointing out the solution. Im afraid though, many people still will not know what exactly to do. I will try to go into more detail, so people like me will understand.

Let me explain the problem first. The program has multiple code lines like this one:
data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};

The attributes width and height are designated (AFAIK that means, the name is explicitly stated when assigning the value). The other attributes are not designated though (just the value 0 but no name of the attribute given)! With older compiler versions this mix seems to have worked. But not anymore.

So we need to either delete .width and .height (but then whe need to be sure, that the order of the attributes is right) or we need to add the names for the other two attributes.

In …\src\edge-impulse-sdk\porting\espressif\ESP-NN\include\esp_nn_defs.h we can find the definition of the used data structure:

/**
 * @brief structure to club data dims
 * this structure can be used for input, output and filter
 */
typedef struct data_dims {
    int32_t width;
    int32_t height;
    int32_t channels;

    int32_t extra; // can be used as batch or any other param
} data_dims_t;

What you need to do:
1. Check the Arduino IDE error message. It tells you the files and lines you need to change. For example:

...\src\edge-impulse-sdk\tensorflow\lite\micro\kernels\conv.cpp:1889:80: error: either all initializer clauses should be designated or none of them should be
 1889 |     data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};

2. Open the file and go to the given line (in this case line 1889).

3. Add the missing names in front of the attributes. For example:
data_dims_t filter_dims = {.width = filter_width, .height = filter_height, .channels = 0, .extra = 0};

4. Save, exit files, recompile.

1 Like

I made all of the changes to the parameters for each code line. However, I still receive the exact same error even though the changes were made.

I was thinking that the issue was because the library being used is using the ZIP file of the Edge Impulse, and therefore won’t receive the updates because what is being edited is the separate extracted file. Please let me know if you have any ideas. Thank you!

We’ll get this fixed in the SDK as well. @AIWintermuteAI will update when this has landed.

Yeah, the issue comes from upstream tflite micro kernels for ESP32…

I’ll fix it in our fork and then make a PR to upstream as well.
Meanwhile, if anyone is blocked by this, downgrading Arduino ESP32 core version will solve this - bear in mind that we officially support and test on 2.0.4 ESP32 Arduino Core. See similar issue here Fix for compilation error when using arduino-esp32 core v3.x - #2 by Eoin.

The fix has now been merged and will enter production within this week.