• 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_WORKGROUP_SELECTION_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_WORKGROUP_SELECTION_H_
18 
19 #include <vector>
20 
21 namespace tflite {
22 namespace gpu {
23 
24 // PRECISE assume that WorkGroupSize * k = GridSize;
25 // NO_ALIGNMENT no restrictions;
26 // We need PRECISE when we don't have check in kernel for boundaries
27 // If we have the check, we can use PRECISE or NO_ALIGNMENT as well.
28 enum class WorkGroupSizeAlignment { PRECISE, NO_ALIGNMENT };
29 
30 std::vector<int> GetPossibleSizes(int number,
31                                   WorkGroupSizeAlignment z_alignment);
32 
33 // Specializations exist for int3 and uint3 in the .cc file
34 
35 template <typename T>
36 std::vector<T> GenerateWorkGroupSizes(
37     const T& grid, int min_work_group_total_size, int max_work_group_total_size,
38     const T& max_work_group_sizes, WorkGroupSizeAlignment x_alignment,
39     WorkGroupSizeAlignment y_alignment, WorkGroupSizeAlignment z_alignment);
40 
41 template <typename T>
42 void GenerateWorkGroupSizesAlignedToGrid(const T& grid,
43                                          const T& max_work_group_size,
44                                          const int max_work_group_total_size,
45                                          std::vector<T>* work_groups);
46 
47 }  // namespace gpu
48 }  // namespace tflite
49 
50 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_WORKGROUP_SELECTION_H_
51