tflite-micro/tensorflow/lite/micro/docs/logging.md
Vamsi Krishna Manchala f1a1f96282
Update READMEs to include logging recommendations
TFLM recommends the use of MicroPrintf for logging messages to the terminal. This PR adds that information to the existing documentation.

BUG=http://b/245802069
2022-11-23 03:22:16 +00:00

1.7 KiB

Message Logging in TFLite Micro

TFLM currently support MicroPrintf to log errors or messages to the terminal. This is a light-weight printf-lite utility available to log messages to the terminal. The MicroPrintf calls are designed to be ignored or optimized-out by the compiler, during deployment, if TF_LITE_STRIP_ERROR_STRINGS environment flag is set. This is useful to reduce the binary size of the TFLM application.

To use MicroPrintf in your application code or kernel implementations:

Include this header file:

#include "tensorflow/lite/micro/micro_log.h"

Introduce this Bazel BUILD dependency:

"//tensorflow/lite/micro:micro_log",

Example usage:

size_t buffer_size = 1024;
...
MicroPrintf("Failed to allocate buffer of size- %d", buffer_size);

MicroPrintf("TFLM is the best! Bring ML to Embedded targets!");

Do Not Use:

TFLM does not support/recommend the use of TF_LITE_KERNEL_LOG and TF_LITE_REPORT_ERROR to log errors or messages to the terminal.