1/* Copyright 2019 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
16#ifndef TENSORFLOW_C_TF_DATATYPE_H_
17#define TENSORFLOW_C_TF_DATATYPE_H_
18
19#include <stddef.h>
20
21// Macro to control visibility of exported symbols in the shared library (.so,
22// .dylib, .dll).
23// This duplicates the TF_EXPORT macro definition in
24// tensorflow/core/platform/macros.h in order to keep this .h file independent
25// of any other includes.
26#ifdef SWIG
27#define TF_CAPI_EXPORT
28#else
29#if defined(_WIN32)
30#ifdef TF_COMPILE_LIBRARY
31#define TF_CAPI_EXPORT __declspec(dllexport)
32#else
33#define TF_CAPI_EXPORT __declspec(dllimport)
34#endif // TF_COMPILE_LIBRARY
35#else
36#define TF_CAPI_EXPORT __attribute__((visibility("default")))
37#endif // _WIN32
38#endif // SWIG
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44// --------------------------------------------------------------------------
45// TF_DataType holds the type for a scalar value. E.g., one slot in a tensor.
46// The enum values here are identical to corresponding values in types.proto.
47typedef enum TF_DataType {
48 TF_FLOAT = 1,
49 TF_DOUBLE = 2,
50 TF_INT32 = 3, // Int32 tensors are always in 'host' memory.
51 TF_UINT8 = 4,
52 TF_INT16 = 5,
53 TF_INT8 = 6,
54 TF_STRING = 7,
55 TF_COMPLEX64 = 8, // Single-precision complex
56 TF_COMPLEX = 8, // Old identifier kept for API backwards compatibility
57 TF_INT64 = 9,
58 TF_BOOL = 10,
59 TF_QINT8 = 11, // Quantized int8
60 TF_QUINT8 = 12, // Quantized uint8
61 TF_QINT32 = 13, // Quantized int32
62 TF_BFLOAT16 = 14, // Float32 truncated to 16 bits. Only for cast ops.
63 TF_QINT16 = 15, // Quantized int16
64 TF_QUINT16 = 16, // Quantized uint16
65 TF_UINT16 = 17,
66 TF_COMPLEX128 = 18, // Double-precision complex
67 TF_HALF = 19,
68 TF_RESOURCE = 20,
69 TF_VARIANT = 21,
70 TF_UINT32 = 22,
71 TF_UINT64 = 23,
72} TF_DataType;
73
74// TF_DataTypeSize returns the sizeof() for the underlying type corresponding
75// to the given TF_DataType enum value. Returns 0 for variable length types
76// (eg. TF_STRING) or on failure.
77TF_CAPI_EXPORT extern size_t TF_DataTypeSize(TF_DataType dt);
78
79#ifdef __cplusplus
80} /* end extern "C" */
81#endif
82
83#endif // TENSORFLOW_C_TF_DATATYPE_H_
84