• 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 #include "tensorflow/lite/delegates/gpu/cl/cl_image_format.h"
17 
18 namespace tflite {
19 namespace gpu {
20 namespace cl {
21 
ToChannelOrder(int num_channels)22 cl_channel_order ToChannelOrder(int num_channels) {
23   switch (num_channels) {
24     case 1:
25       return CL_R;
26     case 2:
27       return CL_RG;
28     case 3:
29       return CL_RGB;
30     case 4:
31       return CL_RGBA;
32     default:
33       return -1;
34   }
35 }
36 
ToImageChannelType(DataType data_type)37 cl_channel_type ToImageChannelType(DataType data_type) {
38   switch (data_type) {
39     case DataType::FLOAT32:
40       return CL_FLOAT;
41     case DataType::FLOAT16:
42       return CL_HALF_FLOAT;
43     default:
44       return -1;
45   }
46 }
47 
48 }  // namespace cl
49 }  // namespace gpu
50 }  // namespace tflite
51