This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Tensor Shuffle: one template argument could not be deduced

Tags: None
(comma "," separated)
hantschal
Registered Member
Posts
2
Karma
0
Hi,

I am trying to work with the tensor.shuffle(...) operation as described in the Tensor documentation (https://bitbucket.org/eigen/eigen/src/677c9f1577810e869f4f09881cabc3e503a810c1/unsupported/Eigen/CXX11/src/Tensor/README.md?at=default#markdown-header-api-reference).
However, even this minimal example is not compiling:

Code: Select all
#include <unsupported/Eigen/CXX11/Tensor>
using namespace Eigen;
int main(int argc, char** argv)
{
   Tensor<float, 3> input(20, 30, 50);
   Tensor<float, 3> output = input.shuffle({1, 2, 0});
}


I tried to compile with both icpc as well as g++. Both compilers are giving similar errors. Here is the log of icpc:

Code: Select all
error: no instance of overloaded function "Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType_>::shuffle [with Scalar_=float, NumIndices_=3, Options_=0, IndexType_=Eigen::DenseIndex={std::ptrdiff_t={long}}]" matches the argument list
            argument types are: ({...})
            object type is: Eigen::Tensor<float, 3, 0, Eigen::DenseIndex>
     Tensor<float, 3> output = input.shuffle({1, 2, 0});
                                     ^
./unsupported/Eigen/CXX11/src/Tensor/TensorBase.h(980): note: this candidate was rejected because at least one template argument could not be deduced
      shuffle(const Shuffle& shuffle) {


The compiler flags were: -O3 -std=c++14

Can someone please help me to solve this problem?

Thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
It seems you need to explicitly create an array:
Code: Select all
#include <unsupported/Eigen/CXX11/Tensor>
using namespace Eigen;
int main(int argc, char** argv)
{
   Tensor<float, 3> input(20, 30, 50);
   array<ptrdiff_t, 3> S = {{1,2,3}};
   Tensor<float, 3> output = input.shuffle(S);
}


Tip: to workaround the shortcoming of Tensor's doc use grep foo eigen/unsupported/test/*tensor*.cpp to find real working code making use of "foo".

The rest of Eigen's doc (http://eigen.tuxfamily.org/dox) does not exhibit such issues because all code snippets/examples are compiled during the doc generation.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]