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:


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.