From fb657674fc2fa6afd17951957502ccf85bae8d71 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Thu, 5 Sep 2019 19:08:27 -0700 Subject: [PATCH] Add an XLA_ALIGN macro. PiperOrigin-RevId: 267506609 --- tensorflow/compiler/xla/cpu_function_runtime.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tensorflow/compiler/xla/cpu_function_runtime.h b/tensorflow/compiler/xla/cpu_function_runtime.h index 281ca5b2203..0c3355cbbfb 100644 --- a/tensorflow/compiler/xla/cpu_function_runtime.h +++ b/tensorflow/compiler/xla/cpu_function_runtime.h @@ -138,6 +138,17 @@ class BufferInfo { // Align to 64-bytes, to mimic tensorflow::Allocator::kAllocatorAlignment. constexpr size_t kAlign = 64; +// When declaring variables that will be passed to an XLA instance as input via +// set_arg_data(), be it a regular input or a resource variable in the graph, +// the C++ variables must be aligned. +// +// Example usage: +// XLA_ALIGN std::array arg_x; +// XLA_ALIGN float arg_y; +// xla_instance.set_arg_data(0, arg_x.date()); +// xla_instance.set_arg_data(0, &arg_y); +#define XLA_ALIGN alignas(xla::cpu_function_runtime::kAlign) + // AlignedBufferBytes returns the sum of the size of each buffer in // `buffer_infos`, skipping constants, on-stack buffers and, if // allocate_entry_params is false, entry parameters. There are `n` entries in