I'm doing a little experimenting with the unsupported Eigen Tensor library. In the documentation, there's a little example showing how to resize a tensor object:
Tensor<float, 3> t_3d(2, 3, 4);
t_3d = Tensor<float, 3>(3, 4, 3);
When I compile a main() which basically consists of those two lines, I get a bunch of verbiage from the compiler:
In file included from /usr/local/include/eigen3/unsupported/Eigen/CXX11/Tensor:88:0,
from tensor_test.cpp:6:
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h: In instantiation of ‘struct Eigen::TensorEvaluator<const Eigen::Tensor<float, 3>, Eigen::DefaultDevice>’:
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h:96:70: required from ‘struct Eigen::TensorEvaluator<const Eigen::TensorAssignOp<Eigen::Tensor<float, 3>, const Eigen::Tensor<float, 3> >, Eigen::DefaultDevice>’
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:406:14: required from ‘Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>& Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>::operator=(const Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>&) [with Scalar_ = float; int NumIndices_ = 3; int Options_ = 0; IndexType_ = long int]’
tensor_test.cpp:29:36: required from here
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h:156:71: warning: ignoring attributes on template argument ‘Eigen::PacketType<float, Eigen::DefaultDevice>::type {aka __vector(4) float}’ [-Wignored-attributes]
PacketAccess = (internal::unpacket_traits<PacketReturnType>::size > 1),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h: In instantiation of ‘struct Eigen::TensorEvaluator<Eigen::Tensor<float, 3>, Eigen::DefaultDevice>’:
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h:100:65: required from ‘struct Eigen::TensorEvaluator<const Eigen::TensorAssignOp<Eigen::Tensor<float, 3>, const Eigen::Tensor<float, 3> >, Eigen::DefaultDevice>’
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:406:14: required from ‘Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>& Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>::operator=(const Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>&) [with Scalar_ = float; int NumIndices_ = 3; int Options_ = 0; IndexType_ = long int]’
tensor_test.cpp:29:36: required from here
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h:42:71: warning: ignoring attributes on template argument ‘Eigen::PacketType<float, Eigen::DefaultDevice>::type {aka __vector(4) float}’ [-Wignored-attributes]
PacketAccess = (internal::unpacket_traits<PacketReturnType>::size > 1),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from /usr/local/include/eigen3/unsupported/Eigen/CXX11/Tensor:121:0,
from tensor_test.cpp:6:
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h: In instantiation of ‘static void Eigen::internal::TensorExecutor<Expression, Eigen::DefaultDevice, true>::run(const Expression&, const Eigen::DefaultDevice&) [with Expression = const Eigen::TensorAssignOp<Eigen::Tensor<float, 3>, const Eigen::Tensor<float, 3> >]’:
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:407:65: required from ‘Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>& Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>::operator=(const Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>&) [with Scalar_ = float; int NumIndices_ = 3; int Options_ = 0; IndexType_ = long int]’
tensor_test.cpp:29:36: required from here
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h:61:17: warning: ignoring attributes on template argument ‘Eigen::TensorEvaluator<const Eigen::TensorAssignOp<Eigen::Tensor<float, 3>, const Eigen::Tensor<float, 3> >, Eigen::DefaultDevice>::PacketReturnType {aka __vector(4) float}’ [-Wignored-attributes]
const int PacketSize = unpacket_traits<typename TensorEvaluator<Expression, DefaultDevice>::PacketReturnType>::size;
I can add a little code that populates the tensor, and then prints out the contents, and everything behaves as expected:
for (auto ii = 0; ii < 3; ii++) {
for (auto jj = 0; jj < 4; jj++) {
for (auto kk = 0; kk < 3; kk++) {
t_3d(kk, jj, ii) = val++;
}
}
}
for (auto ii = 0; ii < 3; ii++) {
for (auto jj = 0; jj < 4; jj++) {
for (auto kk = 0; kk < 3; kk++) {
std::cout << t_3d(kk, jj, ii) << std::endl;
}
}
}
I'm wondering if anyone is familiar with the warnings issued, and how to address them?
I was able to turn-off the warnings coming from unsupported/Eigen/CXX11/src/Tensor
using -isystem
option of g++.
I am using gcc version 7.4.0
and Eigen version 3.3.7 (323c052e1731)