From d27dad7ce8c423c5483cb69c3ee9061a89005ee1 Mon Sep 17 00:00:00 2001
From: Justin Carpentier <justin.carpentier@inria.fr>
Date: Mon, 20 Feb 2023 21:21:24 +0100
Subject: [PATCH] core: fix alignement issues for Eigen::Tensor

---
 include/eigenpy/alignment.hpp | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/include/eigenpy/alignment.hpp b/include/eigenpy/alignment.hpp
index 4bca14d..d37af70 100644
--- a/include/eigenpy/alignment.hpp
+++ b/include/eigenpy/alignment.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023, INRIA
+ * Copyright 2023 INRIA
  */
 
 #ifndef __eigenpy_alignment_hpp__
@@ -67,6 +67,23 @@ struct referent_storage<
       typename eigenpy::aligned_storage<referent_size<T &>::value>::type type;
 };
 
+#ifdef EIGENPY_WITH_TENSOR_SUPPORT
+template <typename Scalar, int Rank, int Options, typename IndexType>
+struct referent_storage<Eigen::Tensor<Scalar, Rank, Options, IndexType> &> {
+  typedef Eigen::Tensor<Scalar, Rank, Options, IndexType> T;
+  typedef
+      typename eigenpy::aligned_storage<referent_size<T &>::value>::type type;
+};
+
+template <typename Scalar, int Rank, int Options, typename IndexType>
+struct referent_storage<
+    const Eigen::Tensor<Scalar, Rank, Options, IndexType> &> {
+  typedef Eigen::Tensor<Scalar, Rank, Options, IndexType> T;
+  typedef
+      typename eigenpy::aligned_storage<referent_size<T &>::value>::type type;
+};
+#endif
+
 template <typename Scalar, int Options>
 struct referent_storage<Eigen::Quaternion<Scalar, Options> &> {
   typedef Eigen::Quaternion<Scalar, Options> T;
-- 
GitLab