• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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 #ifndef TENSORFLOW_LITE_DELEGATES_GPU_COMMON_DATA_TYPE_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_DATA_TYPE_H_
18 
19 #include <stddef.h>
20 #include <string>
21 
22 namespace tflite {
23 namespace gpu {
24 
25 enum class DataType {
26   UNKNOWN = 0,
27   FLOAT16 = 1,
28   FLOAT32 = 2,
29   FLOAT64 = 3,
30   UINT8 = 4,
31   INT8 = 5,
32   UINT16 = 6,
33   INT16 = 7,
34   UINT32 = 8,
35   INT32 = 9,
36   UINT64 = 10,
37   INT64 = 11,
38   BOOL = 12,
39 };
40 
41 size_t SizeOf(DataType data_type);
42 
43 std::string ToString(DataType data_type);
44 
45 std::string ToCLDataType(DataType data_type, int vec_size = 1);
46 
47 std::string ToMetalDataType(DataType data_type, int vec_size = 1);
48 
49 DataType ToMetalTextureType(DataType data_type);
50 
51 // When add_precision enabled it will add:
52 //   highp for INT32/UINT32/FLOAT32
53 //   mediump for INT16/UINT16/FLOAT16(if explicit_fp16 not enabled)
54 //   lowp for INT8/UINT8
55 std::string ToGlslShaderDataType(DataType data_type, int vec_size = 1,
56                                  bool add_precision = false,
57                                  bool explicit_fp16 = false);
58 
59 }  // namespace gpu
60 }  // namespace tflite
61 
62 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_DATA_TYPE_H_
63