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 #ifndef TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILE_OP_H_ 16 #define TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILE_OP_H_ 17 18 #include <memory> 19 20 #include "tensorflow/core/framework/op_kernel.h" 21 #include "tensorflow/core/tpu/kernels/tpu_compile_op_common.h" 22 23 namespace tensorflow { 24 namespace tpu { 25 // The TPUCompile operator compiles a Tensorflow function into a 26 // TPU executable to be run by TPUExecute. 27 // 28 class TpuCompileOp : public OpKernel { 29 public: 30 explicit TpuCompileOp(OpKernelConstruction* ctx); 31 ~TpuCompileOp() override = default; 32 33 void Compute(OpKernelContext* ctx) override; 34 35 private: 36 std::unique_ptr<TpuCompileOpKernelCommon> impl_; 37 38 TF_DISALLOW_COPY_AND_ASSIGN(TpuCompileOp); 39 }; 40 41 // The TPUCompile operator compiles a MLIR module into a 42 // TPU executable to be run by TPUExecute. 43 // 44 class TpuCompileMlirOp : public OpKernel { 45 public: 46 explicit TpuCompileMlirOp(OpKernelConstruction* ctx); 47 ~TpuCompileMlirOp() override = default; 48 49 void Compute(OpKernelContext* ctx) override; 50 51 private: 52 std::unique_ptr<TpuCompileOpKernelCommon> impl_; 53 54 TF_DISALLOW_COPY_AND_ASSIGN(TpuCompileMlirOp); 55 }; 56 57 class TpuCompileSucceededAssertOp : public OpKernel { 58 public: TpuCompileSucceededAssertOp(OpKernelConstruction * ctx)59 explicit TpuCompileSucceededAssertOp(OpKernelConstruction* ctx) 60 : OpKernel(ctx) {} 61 ~TpuCompileSucceededAssertOp() override = default; 62 63 void Compute(OpKernelContext* ctx) override; 64 65 private: 66 TF_DISALLOW_COPY_AND_ASSIGN(TpuCompileSucceededAssertOp); 67 }; 68 } // namespace tpu 69 } // namespace tensorflow 70 71 #endif // TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILE_OP_H_ 72