xref: /aosp_15_r20/external/tensorflow/tensorflow/lite/delegates/gpu/common/selectors/simple_selectors.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_SELECTORS_SIMPLE_SELECTORS_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_SELECTORS_SIMPLE_SELECTORS_H_
18 
19 #include <memory>
20 
21 #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
22 #include "tensorflow/lite/delegates/gpu/common/operations.h"
23 #include "tensorflow/lite/delegates/gpu/common/shape.h"
24 #include "tensorflow/lite/delegates/gpu/common/status.h"
25 #include "tensorflow/lite/delegates/gpu/common/task/gpu_operation.h"
26 
27 namespace tflite {
28 namespace gpu {
29 
30 std::unique_ptr<GPUOperation> SelectLSTM(const OperationDef& op_def,
31                                          const GpuInfo& gpu_info);
32 
33 std::unique_ptr<GPUOperation> SelectReLU(const ReLUAttributes& attr,
34                                          const OperationDef& op_def);
35 
36 std::unique_ptr<GPUOperation> SelectPReLU(const PReLUAttributes& attr,
37                                           const GpuInfo& gpu_info,
38                                           const OperationDef& op_def);
39 
40 std::unique_ptr<GPUOperation> SelectPooling(const Pooling2DAttributes& attr,
41                                             const GpuInfo& gpu_info,
42                                             const OperationDef& op_def);
43 
44 std::unique_ptr<GPUOperation> SelectMaxUnpooling(
45     const MaxUnpooling2DAttributes& attr, const GpuInfo& gpu_info,
46     const OperationDef& op_def);
47 
48 void SelectAdd(const OperationDef& op_def, const std::vector<int>& channels,
49                int dst_channels, std::unique_ptr<GPUOperation>* ptr);
50 
51 absl::Status SelectGather(const GatherAttributes& attr,
52                           const OperationDef& op_def,
53                           std::unique_ptr<GPUOperation>* ptr);
54 
55 absl::Status SelectResize(const Resize2DAttributes& attr,
56                           const OperationDef& op_def,
57                           std::unique_ptr<GPUOperation>* ptr);
58 
59 std::unique_ptr<GPUOperation> SelectResampler(const OperationDef& op_def,
60                                               const GpuInfo& gpu_info);
61 
62 absl::Status SelectConcat(const ConcatAttributes& attr,
63                           const std::vector<int>& channels,
64                           const OperationDef& op_def, const GpuInfo& gpu_info,
65                           std::unique_ptr<GPUOperation>* ptr);
66 
67 std::unique_ptr<GPUOperation> SelectDWConvolutionDynamicWeights(
68     const DepthwiseConvolution2DAttributes& attr, const GpuInfo& gpu_info,
69     const OperationDef& op_def);
70 
71 void SelectReshape(int src_channels, int dst_channels,
72                    const OperationDef& op_def,
73                    std::unique_ptr<GPUOperation>* ptr);
74 
75 void SelectPadding(const PadAttributes& attr, const OperationDef& op_def,
76                    std::unique_ptr<GPUOperation>* ptr);
77 
78 void SelectStridedSlice(const SliceAttributes& attr, const OperationDef& op_def,
79                         std::unique_ptr<GPUOperation>* ptr);
80 
81 std::unique_ptr<GPUOperation> SelectReduce(const std::set<Axis>& axis_to_reduce,
82                                            const BHWC& src_shape,
83                                            OperationType op_type,
84                                            const OperationDef& op_def,
85                                            const GpuInfo& gpu_info);
86 
87 void SelectSoftmax(const BHWC& shape, const OperationDef& op_def,
88                    std::unique_ptr<GPUOperation>* ptr);
89 
90 void SelectSpaceToDepth(const SpaceToDepthAttributes& attr,
91                         const OperationDef& op_def,
92                         std::unique_ptr<GPUOperation>* ptr);
93 
94 void SelectDepthToSpace(const SpaceToDepthAttributes& attr,
95                         const OperationDef& op_def,
96                         std::unique_ptr<GPUOperation>* ptr);
97 
98 void SelectSplit(const SplitAttributes& attr, const GpuInfo& gpu_info,
99                  const std::vector<int>& channels, const OperationDef& op_def,
100                  std::unique_ptr<GPUOperation>* ptr);
101 
102 std::unique_ptr<GPUOperation> SelectTile(const OperationDef& op_def,
103                                          const BHWC& src_shape);
104 
105 void SelectTranspose(const TransposeAttributes& attr,
106                      const OperationDef& op_def,
107                      std::unique_ptr<GPUOperation>* ptr);
108 
109 std::unique_ptr<GPUOperation> SelectWinograd4x4To36(const GpuInfo& gpu_info,
110                                                     const Padding2D& padding,
111                                                     const OperationDef& op_def);
112 
113 std::unique_ptr<GPUOperation> SelectWinograd36To4x4(
114     const GpuInfo& gpu_info, const OperationDef& op_def,
115     const tflite::gpu::Tensor<Linear, DataType::FLOAT32>& biases);
116 
117 std::unique_ptr<GPUOperation> SelectQuantizeAndDequantize(
118     const QuantizeAndDequantizeAttributes& attr, const OperationDef& op_def);
119 
120 void SelectCast(const OperationDef& op_def, const GpuInfo& gpu_info,
121                 std::unique_ptr<GPUOperation>* ptr);
122 
123 void SelectCumsum(const OperationDef& op_def, const CumsumAttributes& attr,
124                   std::unique_ptr<GPUOperation>* ptr);
125 
126 void SelectOneHot(const OperationDef& op_def, const OneHotAttributes& attr,
127                   std::unique_ptr<GPUOperation>* ptr);
128 
129 void SelectSelectV2(const OperationDef& op_def, const SelectV2Attributes& attr,
130                     std::unique_ptr<GPUOperation>* ptr);
131 
132 }  // namespace gpu
133 }  // namespace tflite
134 
135 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_SELECTORS_SIMPLE_SELECTORS_H_
136