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_TASKS_LSTM_NORMALIZATION_H_ 17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASKS_LSTM_NORMALIZATION_H_ 18 19 #include "tensorflow/lite/delegates/gpu/common/operations.h" 20 #include "tensorflow/lite/delegates/gpu/common/status.h" 21 #include "tensorflow/lite/delegates/gpu/common/task/gpu_operation.h" 22 #include "tensorflow/lite/delegates/gpu/common/types.h" 23 24 namespace tflite { 25 namespace gpu { 26 27 // Implements tensor_utils::MeanStddevNormalization 28 class MeanStdDevNormalization : public GPUOperation { 29 public: 30 explicit MeanStdDevNormalization(const OperationDef& definition, 31 const GpuInfo& gpu_info, 32 const int tensor_slices); 33 GetPossibleKernelWorkGroups(TuningType tuning_type,const GpuInfo & gpu_info,const KernelInfo & kernel_info,std::vector<int3> * work_groups)34 void GetPossibleKernelWorkGroups( 35 TuningType tuning_type, const GpuInfo& gpu_info, 36 const KernelInfo& kernel_info, 37 std::vector<int3>* work_groups) const override { 38 work_groups->push_back(work_group_size_); 39 } 40 int3 GetGridSize() const override; 41 42 // Move only 43 MeanStdDevNormalization(MeanStdDevNormalization&& kernel) = default; 44 MeanStdDevNormalization& operator=(MeanStdDevNormalization&& kernel) = 45 default; 46 MeanStdDevNormalization(const MeanStdDevNormalization&) = delete; 47 MeanStdDevNormalization& operator=(const MeanStdDevNormalization&) = delete; 48 49 private: 50 std::string GetNormalizationCode(const GpuInfo& gpu_info); 51 }; 52 53 MeanStdDevNormalization CreateMeanStdDevNormalization( 54 const OperationDef& definition, const GpuInfo& gpu_info, 55 const int tensor_slices); 56 57 } // namespace gpu 58 } // namespace tflite 59 60 #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASKS_LSTM_NORMALIZATION_H_ 61