aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/kernels/eigen_support.cc
diff options
context:
space:
mode:
authorGravatar Yu-Cheng Ling <ycling@google.com>2018-07-17 19:25:21 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-17 19:28:58 -0700
commitff4945f86e04d403cdf46c19392b2041bc75c2ad (patch)
tree5225a27a89663fcfb77faa1fd0fddd41c845c435 /tensorflow/contrib/lite/kernels/eigen_support.cc
parent9ecd9a48843a21ea0afc68ecaed454a31b5d20d5 (diff)
Align TFLite tensors to 16 bytes for EIGEN_DONT_ALIGN
PiperOrigin-RevId: 205015541
Diffstat (limited to 'tensorflow/contrib/lite/kernels/eigen_support.cc')
-rw-r--r--tensorflow/contrib/lite/kernels/eigen_support.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/kernels/eigen_support.cc b/tensorflow/contrib/lite/kernels/eigen_support.cc
index 4f0d020793..e542ad0765 100644
--- a/tensorflow/contrib/lite/kernels/eigen_support.cc
+++ b/tensorflow/contrib/lite/kernels/eigen_support.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include <utility>
+#include "tensorflow/contrib/lite/arena_planner.h"
#include "tensorflow/contrib/lite/kernels/internal/optimized/eigen_spatial_convolutions.h"
#include "tensorflow/contrib/lite/kernels/op_macros.h"
@@ -23,6 +24,16 @@ namespace tflite {
namespace eigen_support {
namespace {
+#ifndef EIGEN_DONT_ALIGN
+// Eigen may require buffers to be algiend to 16, 32 or 64 bytes depending on
+// hardware architecture and build configurations.
+// If the static assertion fails, try to increase `kDefaultTensorAlignment` to
+// in `arena_planner.h` to 32 or 64.
+static_assert(
+ kDefaultTensorAlignment % EIGEN_MAX_ALIGN_BYTES == 0,
+ "kDefaultArenaAlignment doesn't comply with Eigen alignment requirement.");
+#endif // EIGEN_DONT_ALIGN
+
// We have a single global threadpool for all convolution operations. This means
// that inferences started from different threads may block each other, but
// since the underlying resource of CPU cores should be consumed by the