From 2a61c1652e47d6e9916f22e9714f623c28edbaa6 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 6 Jun 2017 07:57:37 -0700 Subject: [PATCH] In cpu compiler's CompileAheadOfTime, pass ordering when compiling entry computation. PiperOrigin-RevId: 158140349 --- .../compiler/xla/service/cpu/cpu_compiler.cc | 6 +++-- .../compiler/xla/service/cpu/ir_emitter.h | 22 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc index 623dd567da0..92a905bed65 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc @@ -397,7 +397,8 @@ StatusOr> CpuCompiler::Compile( llvm::Function * ir_function, ir_emitter.EmitComputation( embedded_computation, embedded_computation->name(), - /*is_entry_computation=*/computation_is_parallel)); + /*is_entry_computation=*/computation_is_parallel, + /*instruction_order=*/nullptr)); // If this computation is parallel, remember it in the function name map. // This way we know what function to execute when we try to run code for // the Call instruction. @@ -625,7 +626,8 @@ CpuCompiler::CompileAheadOfTime(std::vector> modules, TF_ASSIGN_OR_RETURN( llvm::Function * entry_function, ir_emitter.EmitComputation(computation, entry_point_name, - /*is_entry_computation=*/true)); + /*is_entry_computation=*/true, + &module_sequence.at(computation))); entry_function->setName(llvm_ir::AsStringRef(entry_point_name)); diff --git a/tensorflow/compiler/xla/service/cpu/ir_emitter.h b/tensorflow/compiler/xla/service/cpu/ir_emitter.h index b564b359b07..ebb7296a075 100644 --- a/tensorflow/compiler/xla/service/cpu/ir_emitter.h +++ b/tensorflow/compiler/xla/service/cpu/ir_emitter.h @@ -67,17 +67,23 @@ class IrEmitter : public DfsHloVisitorWithDefault { ~IrEmitter() override; // Emit and return the given HLO computation as an LLVM IR - // function. function_name_prefix is the desired name of the function. If the - // name is not unique among already emitted functions then a suffix is - // appended to make the name unique. is_entry_computation indicates that this - // is the entry computation of the HLO module. If 'instruction_order' is given - // then the HLO instructions are emitted in the given order. In this case, - // 'instruction_order' must be a topological sort of the set of nodes - // accessible from the root of the computation. + // function. + // + // function_name_prefix is the desired name of the function. If the name is + // not unique among already emitted functions then a suffix is appended to + // make the name unique. + // + // is_entry_computation indicates that this is the entry computation of the + // HLO module. + // + // If 'instruction_order' is not NULL, then the HLO instructions are emitted + // in the given order. In this case, 'instruction_order' must be a + // topological sort of the set of nodes accessible from the root of the + // computation. StatusOr EmitComputation( HloComputation* computation, const string& function_name_prefix, bool is_entry_computation, - std::vector* instruction_order = nullptr); + std::vector* instruction_order); protected: //