aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
diff options
context:
space:
mode:
authorGravatar Sanjoy Das <sanjoy@google.com>2018-07-27 13:24:46 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-27 13:28:38 -0700
commit388d0d860110a19a9d133fe4de85f8f6fa060cde (patch)
treece12ca4a32266f4a4bc5101e65b0123f810f1373 /tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
parent90fe37ab8d056c56a5127e9b7ae237c04a7907ec (diff)
Use constant buffer allocations for XLA:CPU
This is simpler than the corresponding change to XLA:GPU because on XLA:CPU all instructions are codegened so we can always embed a pointer to the constant global variable directly in the generated LLVM IR. PiperOrigin-RevId: 206363887
Diffstat (limited to 'tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc')
-rw-r--r--tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
index fb9540b7ef..3a5394dac6 100644
--- a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
+++ b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
@@ -60,6 +60,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
+#include "tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.h"
#include "tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.h"
#include "tensorflow/compiler/xla/service/llvm_ir/fused_ir_emitter.h"
#include "tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.h"
@@ -2411,8 +2412,8 @@ std::unique_ptr<KernelThunk> IrEmitterUnnested::BuildKernelThunk(
llvm::Value* loc;
if (slice.allocation()->is_constant()) {
loc = ir_emitter_context_->llvm_module()->getGlobalVariable(
- llvm_ir::AsStringRef(
- ConstantBufferAllocationToGlobalName(*slice.allocation())));
+ llvm_ir::AsStringRef(llvm_ir::ConstantBufferAllocationToGlobalName(
+ *slice.allocation())));
CHECK_NE(loc, nullptr);
} else {
loc = b_.CreateInBoundsGEP(kernel_args.at(slice.allocation()),
@@ -3428,7 +3429,7 @@ Status IrEmitterUnnested::EmitConstantGlobals() {
continue;
}
- const Literal& literal = LiteralForConstantAllocation(allocation);
+ const Literal& literal = llvm_ir::LiteralForConstantAllocation(allocation);
const bool should_emit_initializer = ShouldEmitLiteralInLlvmIr(literal);
llvm::ArrayType* global_type =
llvm::ArrayType::get(b_.getInt8Ty(), allocation.size());
@@ -3453,7 +3454,8 @@ Status IrEmitterUnnested::EmitConstantGlobals() {
global_type, /*isConstant=*/should_emit_initializer,
llvm::GlobalValue::ExternalLinkage,
/*Initializer=*/initializer,
- llvm_ir::AsStringRef(ConstantBufferAllocationToGlobalName(allocation)));
+ llvm_ir::AsStringRef(
+ llvm_ir::ConstantBufferAllocationToGlobalName(allocation)));
global_for_const->setAlignment(kConstantBufferAlignBytes);
ir_emitter_context_->llvm_module()->getGlobalList().push_back(
global_for_const);