Skip to content

Transposition into sub-tensor #20

@Blixodus

Description

@Blixodus

Hello,
I tried to do a tensor transpose from a 3x3x3 tensor into a 3x3x3 sub-tensor of a 5x5x5 tensor, but the result is unexpected. The following code snippet is what I tried to do

std::vector<double> A(125), B(27, 1);
std::iota(A.begin(), A.end(), 0);
double* aliasA = &A[0];
std::vector<int> perm = {0,1,2};
std::vector<int> size = {3,3,3};
std::vector<int> outerSize = {5,5,5};
auto plan = hptt::create_plan(&perm[0], 3,
                              1, &B[0],   &size[0], NULL,
                              10, aliasA,           &outerSize[0],
                              hptt::ESTIMATE, 1);
plan->execute();
for(int i = 0; i < 125; i++) std::cout << A[i] << std::endl;

I would expect as result the following tensor

  1,  11,  21,   3,   4,
 51,  61,  71,   8,   9,
101, 111, 121,  13,  14,
 15,  16,  17,  18,  19,
 20,  21,  22,  23,  24,

251, 261, 271,  28,  29,
301, 311, 321,  33,  34,
351, 361, 371,  38,  39,
 40,  41,  42,  43,  44,
 45,  46,  47,  48,  49,

501, 511, 521,  53,  54,
551, 561, 571,  58,  59,
601, 611, 621,  63,  64,
 65,  66,  67,  68,  69,
 70,  71,  72,  73,  74,

 75,  76,  77,  78,  79,
 80,  81,  82,  83,  84,
 85,  86,  87,  88,  89,
 90,  91,  92,  93,  94,
 95,  96,  97,  98,  99,

100, 101, 102, 103, 104,
105, 106, 107, 108, 109,
110, 111, 112, 113, 114,
115, 116, 117, 118, 119,
120, 121, 122, 123, 124

However, the result ends up as the tensor

  1, 111,2111, 311,  41,
 51, 611,7111, 811,  91,
101,1111,12111,1311, 141,
 15,  16,  17,  18,  19,
 20,  21,  22,  23,  24,

 25,  26,  27,  28,  29,
 30,  31,  32,  33,  34,
 35,  36,  37,  38,  39,
 40,  41,  42,  43,  44,
 45,  46,  47,  48,  49,

 50,  51,  52,  53,  54,
 55,  56,  57,  58,  59,
 60,  61,  62,  63,  64,
 65,  66,  67,  68,  69,
 70,  71,  72,  73,  74,

 75,  76,  77,  78,  79,
 80,  81,  82,  83,  84,
 85,  86,  87,  88,  89,
 90,  91,  92,  93,  94,
 95,  96,  97,  98,  99,

100, 101, 102, 103, 104,
105, 106, 107, 108, 109,
110, 111, 112, 113, 114,
115, 116, 117, 118, 119,
120, 121, 122, 123, 124

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions