1 /* Copyright 2021 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_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_HARDWARES_GPU_HARDWARE_H_ 17 #define TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_HARDWARES_GPU_HARDWARE_H_ 18 19 #include "tensorflow/compiler/mlir/lite/experimental/tac/hardwares/target_hardware.h" 20 #include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h" 21 22 namespace mlir { 23 namespace TFL { 24 namespace tac { 25 // Gpu hardware class which handles GPU capabilities in TFLite. 26 // This is used by TAC to get op supported/ op cost estimates on GPU. 27 class GpuHardware : public TargetHardware { 28 public: 29 static constexpr char kId[] = "GPU"; 30 mlir::RewritePatternSet GetTransformations( 31 MLIRContext* context) const override; 32 GetTypeId()33 mlir::TypeID GetTypeId() const override { 34 return mlir::TypeID::get<GpuHardware>(); 35 } 36 37 double GetHardwareSwitchingCost(const TargetHardware* from, 38 size_t buffer_size) const override; 39 }; 40 } // namespace tac 41 } // namespace TFL 42 } // namespace mlir 43 44 #endif // TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_HARDWARES_GPU_HARDWARE_H_ 45