espressif / esp-tflite-micro

TensorFlow Lite Micro for Espressif Chipsets
Apache License 2.0
365 stars 79 forks source link

esp_nn.h File During Compilation with -D ESP_NN (TFMIC-34) #91

Closed pravee625 closed 1 month ago

pravee625 commented 1 month ago

When I include the -D ESP_NN flag in my platformio.ini, I encounter the following error during compilation:

Compiling .pio\build\esp-wrover-kit\libde0\tfmicro\tensorflow\lite\micro\kernels\esp_nn\add.cc.o Compiling .pio\build\esp-wrover-kit\libde0\tfmicro\tensorflow\lite\micro\kernels\esp_nn\conv.cc.o lib/tfmicro/tensorflow/lite/micro/kernels/esp_nn/add.cc:34:10: fatal error: esp_nn.h: No such file or directory




When I remove the -D ESP_NN flag from my platformio.ini, the compilation is successful.

Is the esp_nn.h file not present in the esp-tflite-micro library? How can I properly include the ESP-NN library while compiling in PlatformIO?

I am attaching my platformio.ini file for your reference image

vikramdattu commented 1 month ago

@pravee625 is this issue still valid after https://github.com/espressif/esp-tflite-micro/issues/93 is addressed?

pravee625 commented 1 month ago

@vikramdattu Yes, I am still unable to compile with -D ESP_NN if declared in my platformio.ini file

if ESP_NN is declared in platformio.ini then esp_nn.h file is required https://github.com/espressif/esp-tflite-micro/blob/e63e91b37c52e8085a6af83048aafc8b0ddaf1a2/tensorflow/lite/micro/kernels/esp_nn/add.cc#L34 and I am unable to find that file in the current repo...

vikramdattu commented 1 month ago

Hi @pravee625 esp-nn is separate component and with esp-idf's build system, it gets pulled in transparently as a dependency to esp-tflite-micro. This happens via dependency specified in idf_component.yml: https://github.com/espressif/esp-tflite-micro/blob/e63e91b37c52e8085a6af83048aafc8b0ddaf1a2/idf_component.yml#L10-L12


For platform.io, can you please follow this piece of documentation? esp-nn can be cloned from here and you can then add it manually as per above documentation.

pravee625 commented 1 month ago

Thanks for the help @vikramdattu. My code is working fine, and esp_nn is successfully integrated. You can close this issue as well as the other issue: https://github.com/espressif/esp-tflite-micro/issues/90. The previous issue was also caused by esp_nn optimizations not being included. Now, my inference time has decreased from 900ms to 200ms. image

vikramdattu commented 1 month ago

Hi @pravee625 thanks for the confirmation. Closing this issue!