Home | History | Annotate | Download | only in cpu
      1 /* Copyright 2017 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_XLA_SERVICE_CPU_ELEMENTAL_IR_EMITTER_H_
     17 #define TENSORFLOW_COMPILER_XLA_SERVICE_CPU_ELEMENTAL_IR_EMITTER_H_
     18 
     19 #include "llvm/IR/IRBuilder.h"
     20 #include "llvm/IR/Module.h"
     21 #include "llvm/IR/Value.h"
     22 #include "tensorflow/compiler/xla/service/cpu/ir_emitter.h"
     23 #include "tensorflow/compiler/xla/service/elemental_ir_emitter.h"
     24 #include "tensorflow/compiler/xla/service/hlo_instruction.h"
     25 #include "tensorflow/compiler/xla/statusor.h"
     26 
     27 namespace xla {
     28 namespace cpu {
     29 
     30 class CpuElementalIrEmitter : public ElementalIrEmitter {
     31  public:
     32   CpuElementalIrEmitter(const HloModuleConfig& module_config,
     33                         IrEmitter* ir_emitter, llvm::Module* module)
     34       : ElementalIrEmitter(module_config, module, ir_emitter->ir_builder()),
     35         ir_emitter_(ir_emitter) {}
     36 
     37   llvm_ir::ElementGenerator MakeElementGenerator(
     38       const HloInstruction* hlo,
     39       const HloToElementGeneratorMap& operand_to_generator) const override;
     40 
     41  protected:
     42   StatusOr<llvm::Value*> EmitFloatUnaryOp(
     43       const HloInstruction* op, llvm::Value* operand_value) const override;
     44   StatusOr<llvm::Value*> EmitAtan2(PrimitiveType prim_type, llvm::Value* lhs,
     45                                    llvm::Value* rhs) const override;
     46 
     47   IrEmitter* ir_emitter_;
     48 };
     49 
     50 }  // namespace cpu
     51 }  // namespace xla
     52 
     53 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_CPU_ELEMENTAL_IR_EMITTER_H_
     54