• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_COMPATIBILITY_H_
16 #define TENSORFLOW_LITE_KERNELS_INTERNAL_COMPATIBILITY_H_
17 
18 #include <cstdint>
19 
20 #include "tensorflow/lite/kernels/op_macros.h"
21 
22 #ifndef TFLITE_DCHECK
23 #define TFLITE_DCHECK(condition) (condition) ? (void)0 : TFLITE_ASSERT_FALSE
24 #endif
25 
26 #ifndef TFLITE_DCHECK_EQ
27 #define TFLITE_DCHECK_EQ(x, y) ((x) == (y)) ? (void)0 : TFLITE_ASSERT_FALSE
28 #endif
29 
30 #ifndef TFLITE_DCHECK_NE
31 #define TFLITE_DCHECK_NE(x, y) ((x) != (y)) ? (void)0 : TFLITE_ASSERT_FALSE
32 #endif
33 
34 #ifndef TFLITE_DCHECK_GE
35 #define TFLITE_DCHECK_GE(x, y) ((x) >= (y)) ? (void)0 : TFLITE_ASSERT_FALSE
36 #endif
37 
38 #ifndef TFLITE_DCHECK_GT
39 #define TFLITE_DCHECK_GT(x, y) ((x) > (y)) ? (void)0 : TFLITE_ASSERT_FALSE
40 #endif
41 
42 #ifndef TFLITE_DCHECK_LE
43 #define TFLITE_DCHECK_LE(x, y) ((x) <= (y)) ? (void)0 : TFLITE_ASSERT_FALSE
44 #endif
45 
46 #ifndef TFLITE_DCHECK_LT
47 #define TFLITE_DCHECK_LT(x, y) ((x) < (y)) ? (void)0 : TFLITE_ASSERT_FALSE
48 #endif
49 
50 // TODO(ahentz): Clean up: We should stick to the DCHECK versions.
51 #ifndef TFLITE_CHECK
52 #define TFLITE_CHECK(condition) (condition) ? (void)0 : TFLITE_ABORT
53 #endif
54 
55 #ifndef TFLITE_CHECK_EQ
56 #define TFLITE_CHECK_EQ(x, y) ((x) == (y)) ? (void)0 : TFLITE_ABORT
57 #endif
58 
59 #ifndef TFLITE_CHECK_NE
60 #define TFLITE_CHECK_NE(x, y) ((x) != (y)) ? (void)0 : TFLITE_ABORT
61 #endif
62 
63 #ifndef TFLITE_CHECK_GE
64 #define TFLITE_CHECK_GE(x, y) ((x) >= (y)) ? (void)0 : TFLITE_ABORT
65 #endif
66 
67 #ifndef TFLITE_CHECK_GT
68 #define TFLITE_CHECK_GT(x, y) ((x) > (y)) ? (void)0 : TFLITE_ABORT
69 #endif
70 
71 #ifndef TFLITE_CHECK_LE
72 #define TFLITE_CHECK_LE(x, y) ((x) <= (y)) ? (void)0 : TFLITE_ABORT
73 #endif
74 
75 #ifndef TFLITE_CHECK_LT
76 #define TFLITE_CHECK_LT(x, y) ((x) < (y)) ? (void)0 : TFLITE_ABORT
77 #endif
78 
79 // TODO(ahentz): Clean up.
80 using int8 = std::int8_t;
81 using uint8 = std::uint8_t;
82 using int16 = std::int16_t;
83 using uint16 = std::uint16_t;
84 using int32 = std::int32_t;
85 using uint32 = std::uint32_t;
86 
87 // TFLITE_DEPRECATED()
88 //
89 // Duplicated from absl/base/macros.h to avoid pulling in that library.
90 // Marks a deprecated class, struct, enum, function, method and variable
91 // declarations. The macro argument is used as a custom diagnostic message (e.g.
92 // suggestion of a better alternative).
93 //
94 // Example:
95 //
96 //   class TFLITE_DEPRECATED("Use Bar instead") Foo {...};
97 //   TFLITE_DEPRECATED("Use Baz instead") void Bar() {...}
98 //
99 // Every usage of a deprecated entity will trigger a warning when compiled with
100 // clang's `-Wdeprecated-declarations` option. This option is turned off by
101 // default, but the warnings will be reported by clang-tidy.
102 #if defined(__clang__) && __cplusplus >= 201103L
103 #define TFLITE_DEPRECATED(message) __attribute__((deprecated(message)))
104 #endif
105 
106 #ifndef TFLITE_DEPRECATED
107 #define TFLITE_DEPRECATED(message)
108 #endif
109 
110 #endif  // TENSORFLOW_LITE_KERNELS_INTERNAL_COMPATIBILITY_H_
111