Add an XLA_ALIGN macro.

PiperOrigin-RevId: 267506609
This commit is contained in:
A. Unique TensorFlower 2019-09-05 19:08:27 -07:00 committed by TensorFlower Gardener
parent b05de9d975
commit fb657674fc

View File

@ -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<float, 4> 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