This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1274 - Tensor reduction operations can't be assigned to Tensors
Tensor reduction operations can't be assigned to Tensors
 Status: DECISIONNEEDED None Eigen Unclassified Tensor (show other bugs) 3.3 (current stable) All All Normal Unknown Nobody

 Reported: 2016-08-12 16:47 UTC by Arnaud TANGUY 2019-12-04 16:05 UTC (History) 5 users (show) benoit.steiner.goog chtz gael.guennebaud rmlarsen william.tambellini

Attachments

 Arnaud TANGUY 2016-08-12 16:47:51 UTC ```The Tensor module README proposes the following reduction example: Eigen::Tensor a(2, 3, 4); a.setValues({{{0.0f, 1.0f, 2.0f, 3.0f}, {7.0f, 6.0f, 5.0f, 4.0f}, {8.0f, 9.0f, 10.0f, 11.0f}}, {{12.0f, 13.0f, 14.0f, 15.0f}, {19.0f, 18.0f, 17.0f, 16.0f}, {20.0f, 21.0f, 22.0f, 23.0f}}}); // Reduce along all dimensions using the sum() operator. Eigen::Tensor b = a.sum(); cout << "b" << endl << b << endl << endl; Running this code, with latest Eigen (git), on both GCC 4.8.5 and Clang-3.9 results in the following assertion error: /usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h:122: bool Eigen::TensorEvaluator, const Eigen::TensorReductionOp, const Eigen::DimensionList, const Eigen::TensorCwiseUnaryOp, const Eigen::TensorCwiseBinaryOp, const Eigen::Tensor, const Eigen::Tensor > > > >, Eigen::DefaultDevice>::evalSubExprsIfNeeded(Scalar *) [Derived = const Eigen::TensorAssignOp, const Eigen::TensorReductionOp, const Eigen::DimensionList, const Eigen::TensorCwiseUnaryOp, const Eigen::TensorCwiseBinaryOp, const Eigen::Tensor, const Eigen::Tensor > > > >, Device = Eigen::DefaultDevice]: Assertion `dimensions_match(m_leftImpl.dimensions(), m_rightImpl.dimensions())' failed. unknown location(0): fatal error in "test_read_tensor": signal: SIGABRT (application abort requested) If it's of any help here is what gdb has to say about the dimensions: (gdb) print m_leftImpl.dimensions() \$3 = (const Eigen::TensorEvaluator, Eigen::DefaultDevice>::Dimensions &) @0x7fffffffc2e8: {> = {_M_elems = {0}}, static count = 1} (gdb) print m_rightImpl.dimensions() \$4 = (const Eigen::TensorEvaluator, Eigen::DimensionList const, Eigen::TensorCwiseUnaryOp, Eigen::TensorCwiseBinaryOp, Eigen::Tensor const, Eigen::Tensor const> const> const> const, Eigen::DefaultDevice>::Dimensions &) @0x7fffffffc2fb: {> = {static count = 0}, static total_size = 1} The same error occurs for all of the reduction operations (prod...). Not trying to assign the result to a tensor, and printing it out works fine: cout << a.sum() << endl; is perfectly fine and gives the expected result. Best regards, Arnaud``` Benoit Steiner 2016-08-12 16:58:13 UTC ```Since you're using a full reduction, the result is a scalar. Scalars are now represented using 0 rank tensors. The following statement should work for you: Eigen::Tensor b = a.sum();``` Gael Guennebaud 2016-08-22 11:43:41 UTC `I see the doc has been fixed in rev. 3782cd1de9c4, but what about allowing assignment of tensors with different ranks but compatible runtime sizes? For instance, in Eigen/Core, it is fine to assign a Vector from/to a Matrix.` william.tambellini 2018-12-18 02:13:36 UTC ```If that could allow to move forward on that one, I also vote to allow 'transfer' of data from tensor to tensor whatever the rankings as long as the size fits. (I am anyway globally not super fan of Ranking to be a template param).``` Nobody 2019-12-04 16:05:59 UTC ```-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1274.```

 Note You need to log in before you can comment on or make changes to this bug.