• 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 #ifndef TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASK_WORK_GROUP_PICKING_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASK_WORK_GROUP_PICKING_H_
18 
19 #include <vector>
20 
21 #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
22 #include "tensorflow/lite/delegates/gpu/common/kernel_info.h"
23 #include "tensorflow/lite/delegates/gpu/common/task/tuning_type.h"
24 #include "tensorflow/lite/delegates/gpu/common/types.h"
25 #include "tensorflow/lite/delegates/gpu/common/workgroup_selection.h"
26 
27 namespace tflite {
28 namespace gpu {
29 
30 // multiplier can be power of two only
31 void GetPossibleWorkGroupsXYMultipleOf(int multiplier, const GpuInfo& gpu_info,
32                                        const KernelInfo& kernel_info,
33                                        const int3& grid,
34                                        WorkGroupSizeAlignment z_alignment,
35                                        std::vector<int3>* work_groups);
36 
37 void GetPossibleWorkGroupsXMultipleOf(int multiplier, const GpuInfo& gpu_info,
38                                       const KernelInfo& kernel_info,
39                                       const int3& grid,
40                                       WorkGroupSizeAlignment z_alignment,
41                                       std::vector<int3>* work_groups);
42 
43 int3 GetWorkGroupXY128ConvLinear(const int3& grid);
44 
45 int3 GetWorkGroupXY128Simple(const int3& grid);
46 int3 GetWorkGroupXY128Conv(const int3& grid);
47 
48 bool XY128RequiresMoreWorkGroupsThenXY128Linear(int width, int height);
49 
50 void GetPossibleWorkGroups(TuningType tuning_type, const GpuInfo& gpu_info,
51                            const KernelInfo& kernel_info, const int3& grid,
52                            std::vector<int3>* work_groups);
53 
54 void GetPossibleWorkGroupsConv(TuningType tuning_type, const GpuInfo& gpu_info,
55                                const KernelInfo& kernel_info, const int3& grid,
56                                std::vector<int3>* work_groups);
57 
58 // returns first work group from wgs that has size not bigger than max_wg_size
59 // if no suitable groups among wgs, returns {1, 1, 1}
60 int3 GetFirstSuitableWorkGroup(const std::vector<int3>& wgs, int max_wg_size);
61 
62 }  // namespace gpu
63 }  // namespace tflite
64 
65 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASK_WORK_GROUP_PICKING_H_
66