xref: /aosp_15_r20/external/tensorflow/tensorflow/lite/delegates/gpu/common/tasks/elementwise.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_TASKS_ELEMENTWISE_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASKS_ELEMENTWISE_H_
18 
19 #include <string>
20 
21 #include "tensorflow/lite/delegates/gpu/common/operations.h"
22 #include "tensorflow/lite/delegates/gpu/common/status.h"
23 #include "tensorflow/lite/delegates/gpu/common/task/gpu_operation.h"
24 
25 namespace tflite {
26 namespace gpu {
27 
28 // Creates simple one input operation without any parameters, for example
29 // log, sin, cos, etc.
30 GPUOperation CreateElementwiseOneInput(const GpuInfo& gpu_info,
31                                        const OperationDef& definition,
32                                        const OperationType& op_type);
33 
34 // Creates simple one input operation without any parameters, for example
35 // log, sin, cos, etc.
36 // Can broadcast input.
37 GPUOperation CreateElementwiseOneInputWithBroadcast(
38     const GpuInfo& gpu_info, const OperationDef& definition,
39     const OperationType& op_type, const BHWC& input_shape,
40     const BHWC& output_shape);
41 
42 // Creates simple two input(first input is runtime tensor and second input is
43 // constant or linear/hwc tensor) operation, for example sub, div and etc.
44 GPUOperation CreateElementwise(const GpuInfo& gpu_info,
45                                const OperationDef& definition,
46                                const OperationType& op_type,
47                                const ElementwiseAttributes& attr);
48 
49 // Creates simple two input(first input is runtime tensor and second input is
50 // constant or linear/hwc tensor) operation, for example sub, div and etc.
51 // Can broadcast input.
52 GPUOperation CreateElementwiseWithBroadcast(const GpuInfo& gpu_info,
53                                             const OperationDef& definition,
54                                             const OperationType& op_type,
55                                             const ElementwiseAttributes& attr,
56                                             const BHWC& input_shape,
57                                             const BHWC& output_shape);
58 
59 // Creates simple two input(2 runtime tensors) operation, for example
60 // sub, div and etc.
61 GPUOperation CreateElementwiseTwoInput(const OperationDef& definition,
62                                        const OperationType& op_type,
63                                        const BHWC& shape);
64 
65 // Creates simple two input(2 runtime tensors) operation, for example
66 // sub, div and etc.
67 // Can broadcast first and second input simultaneously.
68 GPUOperation CreateElementwiseTwoInputWithBroadcast(
69     const OperationDef& definition, const OperationType& op_type,
70     const BHWC& first_input_shape, const BHWC& second_input_shape,
71     const BHWC& output_shape);
72 
73 }  // namespace gpu
74 }  // namespace tflite
75 
76 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASKS_ELEMENTWISE_H_
77