1/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15#ifndef TENSORFLOW_LITE_KERNELS_OP_MACROS_H_
16#define TENSORFLOW_LITE_KERNELS_OP_MACROS_H_
17
18#include <cstdio>
19#include <cstdlib>
20
21
22// Report Error for unsupported type by op 'op_name' and returns kTfLiteError.
23#define TF_LITE_UNSUPPORTED_TYPE(context, type, op_name) \
24 do { \
25 TF_LITE_KERNEL_LOG((context), "%s:%d Type %s is unsupported by op %s.", \
26 __FILE__, __LINE__, TfLiteTypeGetName(type), \
27 (op_name)); \
28 return kTfLiteError; \
29 } while (0)
30
31#define TFLITE_ABORT abort()
32
33#if defined(NDEBUG)
34#define TFLITE_ASSERT_FALSE (static_cast<void>(0))
35#else
36#define TFLITE_ASSERT_FALSE TFLITE_ABORT
37#endif
38
39#define TF_LITE_FATAL(msg) \
40 do { \
41 fprintf(stderr, "%s\n", (msg)); \
42 TFLITE_ABORT; \
43 } while (0)
44
45#define TF_LITE_ASSERT(x) \
46 do { \
47 if (!(x)) TF_LITE_FATAL(#x); \
48 } while (0)
49
50#define TF_LITE_ASSERT_EQ(x, y) \
51 do { \
52 if ((x) != (y)) TF_LITE_FATAL(#x " didn't equal " #y); \
53 } while (0)
54
55#endif // TENSORFLOW_LITE_KERNELS_OP_MACROS_H_
56