TF_LITE_MAYBE_KERNEL_LOG with a check for non-null context

A variant of TF_LITE_KERNEL_LOG that allows passing context = nullptr to dynamically disable logging

PiperOrigin-RevId: 309275462
Change-Id: Ifdcbb9ada5013612923a631c2beec755a735ffbd
This commit is contained in:
Marat Dukhan 2020-04-30 12:20:03 -07:00 committed by TensorFlower Gardener
parent 3df3300d58
commit c878390581
2 changed files with 16 additions and 0 deletions

View File

@ -155,8 +155,16 @@ void TfLiteFloatArrayFree(TfLiteFloatArray* a);
do { \
(context)->ReportError((context), __VA_ARGS__); \
} while (false)
#define TF_LITE_MAYBE_KERNEL_LOG(context, ...) \
do { \
if ((context) != nullptr) { \
(context)->ReportError((context), __VA_ARGS__); \
} \
} while (false)
#else // TF_LITE_STRIP_ERROR_STRINGS
#define TF_LITE_KERNEL_LOG(context, ...)
#define TF_LITE_MAYBE_KERNEL_LOG(context, ...)
#endif // TF_LITE_STRIP_ERROR_STRINGS
// Check whether value is true, and if not return kTfLiteError from

View File

@ -155,8 +155,16 @@ void TfLiteFloatArrayFree(TfLiteFloatArray* a);
do { \
(context)->ReportError((context), __VA_ARGS__); \
} while (false)
#define TF_LITE_MAYBE_KERNEL_LOG(context, ...) \
do { \
if ((context) != nullptr) { \
(context)->ReportError((context), __VA_ARGS__); \
} \
} while (false)
#else // TF_LITE_STRIP_ERROR_STRINGS
#define TF_LITE_KERNEL_LOG(context, ...)
#define TF_LITE_MAYBE_KERNEL_LOG(context, ...)
#endif // TF_LITE_STRIP_ERROR_STRINGS
// Check whether value is true, and if not return kTfLiteError from