|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TENSORFLOW_LITE_KERNELS_OP_MACROS_H_ |
|
|
#define TENSORFLOW_LITE_KERNELS_OP_MACROS_H_ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TF_LITE_MCU_DEBUG_LOG |
|
|
|
|
|
#include "edge-impulse-sdk/tensorflow/lite/micro/debug_log.h" |
|
|
|
|
|
#define DEBUG_LOG(x) \ |
|
|
do { \ |
|
|
DebugLog(x); \ |
|
|
} while (0) |
|
|
|
|
|
inline void InfiniteLoop() { |
|
|
DEBUG_LOG("HALTED\n"); |
|
|
while (1) { |
|
|
} |
|
|
} |
|
|
|
|
|
#define TFLITE_ABORT InfiniteLoop(); |
|
|
|
|
|
#else |
|
|
|
|
|
#include <cstdio> |
|
|
#include <cstdlib> |
|
|
|
|
|
#define DEBUG_LOG(x) \ |
|
|
do { \ |
|
|
fprintf(stderr, "%s", (x)); \ |
|
|
} while (0) |
|
|
|
|
|
|
|
|
#define TF_LITE_UNSUPPORTED_TYPE(context, type, op_name) \ |
|
|
do { \ |
|
|
TF_LITE_KERNEL_LOG((context), "%s:%d Type %s is unsupported by op %s.", \ |
|
|
__FILE__, __LINE__, TfLiteTypeGetName(type), \ |
|
|
(op_name)); \ |
|
|
return kTfLiteError; \ |
|
|
} while (0) |
|
|
|
|
|
#define TFLITE_ABORT abort() |
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(NDEBUG) || defined(ARDUINO) |
|
|
#define TFLITE_ASSERT_FALSE (static_cast<void>(0)) |
|
|
#else |
|
|
#define TFLITE_ASSERT_FALSE TFLITE_ABORT |
|
|
#endif |
|
|
|
|
|
#define TF_LITE_FATAL(msg) \ |
|
|
do { \ |
|
|
DEBUG_LOG(msg); \ |
|
|
DEBUG_LOG("\nFATAL\n"); \ |
|
|
TFLITE_ABORT; \ |
|
|
} while (0) |
|
|
|
|
|
#define TF_LITE_ASSERT(x) \ |
|
|
do { \ |
|
|
if (!(x)) TF_LITE_FATAL(#x); \ |
|
|
} while (0) |
|
|
|
|
|
#define TF_LITE_ASSERT_EQ(x, y) \ |
|
|
do { \ |
|
|
if ((x) != (y)) TF_LITE_FATAL(#x " didn't equal " #y); \ |
|
|
} while (0) |
|
|
|
|
|
#endif |
|
|
|