• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 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 
16 // This file declares types used by the pure C inference API defined in c_api.h,
17 // some of which are also used in the C++ and C kernel and interpreter APIs.
18 
19 #ifndef TENSORFLOW_LITE_C_C_API_TYPES_H_
20 #define TENSORFLOW_LITE_C_C_API_TYPES_H_
21 
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 // Define TFL_CAPI_EXPORT macro to export a function properly with a shared
29 // library.
30 #ifdef SWIG
31 #define TFL_CAPI_EXPORT
32 #else
33 #if defined(_WIN32)
34 #ifdef TFL_COMPILE_LIBRARY
35 #define TFL_CAPI_EXPORT __declspec(dllexport)
36 #else
37 #define TFL_CAPI_EXPORT __declspec(dllimport)
38 #endif  // TFL_COMPILE_LIBRARY
39 #else
40 #define TFL_CAPI_EXPORT __attribute__((visibility("default")))
41 #endif  // _WIN32
42 #endif  // SWIG
43 
44 typedef enum TfLiteStatus {
45   kTfLiteOk = 0,
46 
47   // Generally referring to an error in the runtime (i.e. interpreter)
48   kTfLiteError = 1,
49 
50   // Generally referring to an error from a TfLiteDelegate itself.
51   kTfLiteDelegateError = 2,
52 
53   // Generally referring to an error in applying a delegate due to
54   // incompatibility between runtime and delegate, e.g., this error is returned
55   // when trying to apply a TfLite delegate onto a model graph that's already
56   // immutable.
57   kTfLiteApplicationError = 3
58 } TfLiteStatus;
59 
60 // Types supported by tensor
61 typedef enum {
62   kTfLiteNoType = 0,
63   kTfLiteFloat32 = 1,
64   kTfLiteInt32 = 2,
65   kTfLiteUInt8 = 3,
66   kTfLiteInt64 = 4,
67   kTfLiteString = 5,
68   kTfLiteBool = 6,
69   kTfLiteInt16 = 7,
70   kTfLiteComplex64 = 8,
71   kTfLiteInt8 = 9,
72   kTfLiteFloat16 = 10,
73   kTfLiteFloat64 = 11,
74   kTfLiteComplex128 = 12,
75   kTfLiteUInt64 = 13,
76   kTfLiteResource = 14,
77   kTfLiteVariant = 15,
78   kTfLiteUInt32 = 16,
79 } TfLiteType;
80 
81 // Legacy. Will be deprecated in favor of TfLiteAffineQuantization.
82 // If per-layer quantization is specified this field will still be populated in
83 // addition to TfLiteAffineQuantization.
84 // Parameters for asymmetric quantization. Quantized values can be converted
85 // back to float using:
86 //     real_value = scale * (quantized_value - zero_point)
87 typedef struct TfLiteQuantizationParams {
88   float scale;
89   int32_t zero_point;
90 } TfLiteQuantizationParams;
91 
92 #ifdef __cplusplus
93 }  // extern C
94 #endif
95 #endif  // TENSORFLOW_LITE_C_C_API_TYPES_H_
96