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 OperationDef& op_def); 42 43 std::unique_ptr<GPUOperation> SelectMaxUnpooling( 44 const MaxUnpooling2DAttributes& attr, const OperationDef& op_def); 45 46 void SelectAdd(const OperationDef& op_def, const std::vector<int>& channels, 47 int dst_channels, std::unique_ptr<GPUOperation>* ptr); 48 49 absl::Status SelectResize(const Resize2DAttributes& attr, 50 const OperationDef& op_def, 51 std::unique_ptr<GPUOperation>* ptr); 52 53 absl::Status SelectConcat(const ConcatAttributes& attr, 54 const std::vector<int>& channels, 55 const OperationDef& op_def, const GpuInfo& gpu_info, 56 std::unique_ptr<GPUOperation>* ptr); 57 58 std::unique_ptr<GPUOperation> SelectDWConvolutionDynamicWeights( 59 const DepthwiseConvolution2DAttributes& attr, const GpuInfo& gpu_info, 60 const OperationDef& op_def); 61 62 void SelectReshape(int src_channels, int dst_channels, 63 const OperationDef& op_def, 64 std::unique_ptr<GPUOperation>* ptr); 65 66 void SelectPadding(const PadAttributes& attr, const OperationDef& op_def, 67 std::unique_ptr<GPUOperation>* ptr); 68 69 void SelectStridedSlice(const SliceAttributes& attr, const OperationDef& op_def, 70 std::unique_ptr<GPUOperation>* ptr); 71 72 std::unique_ptr<GPUOperation> SelectReduce(const std::set<Axis>& axis_to_reduce, 73 const BHWC& src_shape, 74 OperationType op_type, 75 const OperationDef& op_def, 76 const GpuInfo& gpu_info); 77 78 void SelectSoftmax(const BHWC& shape, const OperationDef& op_def, 79 std::unique_ptr<GPUOperation>* ptr); 80 81 void SelectSpaceToDepth(const SpaceToDepthAttributes& attr, 82 const OperationDef& op_def, 83 std::unique_ptr<GPUOperation>* ptr); 84 85 absl::Status SelectSplit(const SplitAttributes& attr, 86 const OperationDef& op_def, 87 std::unique_ptr<GPUOperation>* ptr); 88 89 void SelectTranspose(const TransposeAttributes& attr, 90 const OperationDef& op_def, 91 std::unique_ptr<GPUOperation>* ptr); 92 93 std::unique_ptr<GPUOperation> SelectWinograd4x4To36(const GpuInfo& gpu_info, 94 const Padding2D& padding, 95 const OperationDef& op_def); 96 97 std::unique_ptr<GPUOperation> SelectWinograd36To4x4( 98 const GpuInfo& gpu_info, const OperationDef& op_def, 99 const tflite::gpu::Tensor<Linear, DataType::FLOAT32>& biases); 100 101 std::unique_ptr<GPUOperation> SelectQuantizeAndDequantize( 102 const QuantizeAndDequantizeAttributes& attr, const OperationDef& op_def); 103 104 } // namespace gpu 105 } // namespace tflite 106 107 #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_SELECTORS_SIMPLE_SELECTORS_H_ 108