gpt4 book ai didi

c++ - Eigen Tensor 示例的编译器警告

转载 作者:行者123 更新时间:2023-11-28 04:25:02 24 4
gpt4 key购买 nike

我正在对不受支持的 Eigen Tensor 库进行一些试验。在文档中,有一个小示例展示了如何调整张量对象的大小:

Tensor<float, 3> t_3d(2, 3, 4);
t_3d = Tensor<float, 3>(3, 4, 3);

当我编译一个基本上由这两行组成的 main() 时,我从编译器那里得到了一堆废话:

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;

我可以添加一些填充张量的代码,然后打印出内容,一切都按预期运行:

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;
}
}
}

我想知道是否有人熟悉发出的警告,以及如何解决它们?

最佳答案

我能够使用 g++ 的 -isystem 选项关闭来自 unsupported/Eigen/CXX11/src/Tensor 的警告。

我正在使用 gcc 版本 7.4.0Eigen 版本 3.3.7 (323c052e1731)

关于c++ - Eigen Tensor 示例的编译器警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54526502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com