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 #ifndef TF_LITE_STATIC_MEMORY 80 // TODO(b/162019032): Consider removing these type-aliases. 81 using int8 = std::int8_t; 82 using uint8 = std::uint8_t; 83 using int16 = std::int16_t; 84 using uint16 = std::uint16_t; 85 using int32 = std::int32_t; 86 using uint32 = std::uint32_t; 87 #endif // !defined(TF_LITE_STATIC_MEMORY) 88 89 // TFLITE_DEPRECATED() 90 // 91 // Duplicated from absl/base/macros.h to avoid pulling in that library. 92 // Marks a deprecated class, struct, enum, function, method and variable 93 // declarations. The macro argument is used as a custom diagnostic message (e.g. 94 // suggestion of a better alternative). 95 // 96 // Example: 97 // 98 // class TFLITE_DEPRECATED("Use Bar instead") Foo {...}; 99 // TFLITE_DEPRECATED("Use Baz instead") void Bar() {...} 100 // 101 // Every usage of a deprecated entity will trigger a warning when compiled with 102 // clang's `-Wdeprecated-declarations` option. This option is turned off by 103 // default, but the warnings will be reported by clang-tidy. 104 #if defined(__clang__) && __cplusplus >= 201103L 105 #define TFLITE_DEPRECATED(message) __attribute__((deprecated(message))) 106 #endif 107 108 #ifndef TFLITE_DEPRECATED 109 #define TFLITE_DEPRECATED(message) 110 #endif 111 112 #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_COMPATIBILITY_H_ 113