ConstantTensorDescriptor.hip.hpp 18.1 KB
Newer Older
Chao Liu's avatar
Chao Liu committed
1
#pragma once
2
#include "common.hip.hpp"
Chao Liu's avatar
Chao Liu committed
3

4
5
template <class Lengths>
__host__ __device__ constexpr auto calculate_default_strides(Lengths)
6
{
Chao Liu's avatar
Chao Liu committed
7
8
    return reverse_inclusive_scan_sequence(Lengths{}.PopFront().PushBack(Number<1>{}),
                                           std::multiplies<index_t>{});
9
10
}

Chao Liu's avatar
Chao Liu committed
11
// this is ugly, only for 2d
Chao Liu's avatar
Chao Liu committed
12
template <index_t L0, index_t L1, index_t Align>
Chao Liu's avatar
Chao Liu committed
13
14
15
__host__ __device__ constexpr auto calculate_default_strides_aligned(Sequence<L0, L1>,
                                                                     Number<Align>)
{
Chao Liu's avatar
Chao Liu committed
16
    constexpr index_t L1_align = Align * ((L1 + Align - 1) / Align);
Chao Liu's avatar
Chao Liu committed
17
18
19
    return Sequence<L1_align, 1>{};
}

20
21
22
23
24
25
26
27
28
// this is ugly, only for 3d
template <index_t L0, index_t L1, index_t L2, index_t Align>
__host__ __device__ constexpr auto calculate_default_strides_aligned(Sequence<L0, L1, L2>,
                                                                     Number<Align>)
{
    constexpr index_t L2_align = Align * ((L2 + Align - 1) / Align);
    return Sequence<L1 * L2_align, L2_align, 1>{};
}

Chao Liu's avatar
Chao Liu committed
29
// this is ugly, only for 4d
Chao Liu's avatar
Chao Liu committed
30
template <index_t L0, index_t L1, index_t L2, index_t L3, index_t Align>
Chao Liu's avatar
Chao Liu committed
31
32
33
__host__ __device__ constexpr auto calculate_default_strides_aligned(Sequence<L0, L1, L2, L3>,
                                                                     Number<Align>)
{
Chao Liu's avatar
Chao Liu committed
34
    constexpr index_t L3_align = Align * ((L3 + Align - 1) / Align);
Chao Liu's avatar
Chao Liu committed
35
36
37
    return Sequence<L1 * L2 * L3_align, L2 * L3_align, L3_align, 1>{};
}

Chao Liu's avatar
Chao Liu committed
38
39
40
template <class Lengths, class Strides>
struct ConstantTensorDescriptor
{
Chao Liu's avatar
Chao Liu committed
41
42
    using Type = ConstantTensorDescriptor;

43
    static constexpr index_t nDim = Lengths::GetSize();
Chao Liu's avatar
Chao Liu committed
44
45
46

    __host__ __device__ constexpr ConstantTensorDescriptor()
    {
47
        static_assert(Lengths::GetSize() == Strides::GetSize(), "nDim not consistent");
Chao Liu's avatar
Chao Liu committed
48
49
    }

Chao Liu's avatar
Chao Liu committed
50
    __host__ __device__ static constexpr index_t GetNumOfDimension() { return nDim; }
Chao Liu's avatar
Chao Liu committed
51

52
    __host__ __device__ static constexpr Lengths GetLengths() { return Lengths{}; }
Chao Liu's avatar
Chao Liu committed
53

54
    __host__ __device__ static constexpr Strides GetStrides() { return Strides{}; }
Chao Liu's avatar
Chao Liu committed
55

Chao Liu's avatar
Chao Liu committed
56
    template <index_t I>
57
    __host__ __device__ static constexpr index_t GetLength(Number<I>)
Chao Liu's avatar
Chao Liu committed
58
    {
Chao Liu's avatar
Chao Liu committed
59
        return Lengths{}.Get(Number<I>{});
Chao Liu's avatar
Chao Liu committed
60
61
    }

Chao Liu's avatar
Chao Liu committed
62
    template <index_t I>
63
    __host__ __device__ static constexpr index_t GetStride(Number<I>)
Chao Liu's avatar
Chao Liu committed
64
    {
Chao Liu's avatar
Chao Liu committed
65
        return Strides{}.Get(Number<I>{});
Chao Liu's avatar
Chao Liu committed
66
67
    }

68
    __host__ __device__ static constexpr index_t GetElementSize()
Chao Liu's avatar
Chao Liu committed
69
    {
Chao Liu's avatar
Chao Liu committed
70
        return accumulate_on_sequence(Lengths{}, std::multiplies<index_t>{}, Number<1>{});
71
    }
72

Chao Liu's avatar
Chao Liu committed
73
    template <class Align = Number<1>>
74
    __host__ __device__ static constexpr index_t GetElementSpace(Align align = Align{})
Chao Liu's avatar
Chao Liu committed
75
    {
Chao Liu's avatar
Chao Liu committed
76
77
        constexpr index_t element_space_unaligned = accumulate_on_sequence(
            (GetLengths() - Number<1>{}) * GetStrides(), std::plus<index_t>{}, Number<1>{});
Chao Liu's avatar
Chao Liu committed
78
79

        return align.Get() * ((element_space_unaligned + align.Get() - 1) / align.Get());
Chao Liu's avatar
Chao Liu committed
80
    }
Chao Liu's avatar
Chao Liu committed
81

82
83
    template <index_t NSize>
    __host__ __device__ static index_t Get1dIndex(Array<index_t, NSize> multi_id)
Chao Liu's avatar
Chao Liu committed
84
    {
85
        static_assert(NSize == nDim, "wrong! Dimension not consistent");
Chao Liu's avatar
Chao Liu committed
86

Chao Liu's avatar
Chao Liu committed
87
        index_t id = 0;
Chao Liu's avatar
Chao Liu committed
88

89
        static_for<0, nDim, 1>{}([&](auto IDim) {
Chao Liu's avatar
Chao Liu committed
90
            constexpr index_t idim = IDim.Get();
91
92
            id += multi_id[idim] * GetStride(IDim);
        });
Chao Liu's avatar
Chao Liu committed
93

94
        return id;
95
96
    }

97
98
99
100
101
102
103
104
105
106
    template <class... Is>
    __host__ __device__ static index_t Get1dIndex(Is... is)
    {
        static_assert(sizeof...(Is) == nDim, "number of multi-index is wrong");

        const auto multi_id = Array<index_t, nDim>(is...);

        return Get1dIndex(multi_id);
    }

107
    template <index_t... Is>
Chao Liu's avatar
Chao Liu committed
108
    __host__ __device__ static constexpr index_t Get1dIndex(Sequence<Is...> /*multi_id*/)
109
110
111
    {
        static_assert(sizeof...(Is) == nDim, "wrong! Dimension not consistent");

Chao Liu's avatar
Chao Liu committed
112
113
        constexpr auto multi_id = Sequence<Is...>{};

Chao Liu's avatar
Chao Liu committed
114
        return accumulate_on_sequence(multi_id * GetStrides(), std::plus<index_t>{}, Number<0>{});
115
116
    }

117
    __host__ __device__ static Array<index_t, nDim> GetMultiIndex(index_t id)
Chao Liu's avatar
Chao Liu committed
118
    {
119
120
121
122
123
124
125
126
127
128
129
        Array<index_t, nDim> multi_id;

        static_for<0, nDim - 1, 1>{}([&](auto IDim) {
            constexpr index_t idim = IDim.Get();
            multi_id[idim]         = id / GetStride(IDim);
            id -= multi_id[idim] * GetStride(IDim);
        });

        multi_id[nDim - 1] = id / GetStride(Number<nDim - 1>{});

        return multi_id;
Chao Liu's avatar
Chao Liu committed
130
    }
131

Chao Liu's avatar
Chao Liu committed
132
    __host__ __device__ static constexpr auto Pack()
133
    {
134
135
        constexpr auto default_strides = calculate_default_strides(Lengths{});
        return ConstantTensorDescriptor<Lengths, decltype(default_strides)>{};
136
    }
Chao Liu's avatar
Chao Liu committed
137

Chao Liu's avatar
Chao Liu committed
138
    template <index_t... IDims>
Chao Liu's avatar
Chao Liu committed
139
    __host__ __device__ static constexpr auto Extract(Number<IDims>... extract_dims)
Chao Liu's avatar
Chao Liu committed
140
    {
Chao Liu's avatar
Chao Liu committed
141
142
        static_assert(sizeof...(IDims) <= GetNumOfDimension(),
                      "wrong! too many number of dimensions to be extracted");
Chao Liu's avatar
Chao Liu committed
143

Chao Liu's avatar
Chao Liu committed
144
145
        return make_ConstantTensorDescriptor(Lengths{}.Extract(extract_dims...),
                                             Strides{}.Extract(extract_dims...));
Chao Liu's avatar
Chao Liu committed
146
147
148
149
150
    }

    template <index_t IDim, index_t SliceLen>
    __host__ __device__ static constexpr auto Slice(Number<IDim>, Number<SliceLen>)
    {
Chao Liu's avatar
Chao Liu committed
151
152
        return make_ConstantTensorDescriptor(Lengths{}.Modify(Number<IDim>{}, Number<SliceLen>{}),
                                             Strides{});
Chao Liu's avatar
Chao Liu committed
153
154
    }

Chao Liu's avatar
Chao Liu committed
155
    template <index_t IDim, index_t... FoldIntervals>
Chao Liu's avatar
Chao Liu committed
156
    __host__ __device__ static constexpr auto Fold(Number<IDim>, Number<FoldIntervals>...)
Chao Liu's avatar
Chao Liu committed
157
    {
Chao Liu's avatar
Chao Liu committed
158
159
        constexpr auto fold_intervals = Sequence<FoldIntervals...>{};

Chao Liu's avatar
Chao Liu committed
160
        constexpr index_t fold_intervals_product =
Chao Liu's avatar
Chao Liu committed
161
162
163
164
165
166
167
            accumulate_on_sequence(fold_intervals, std::multiplies<index_t>{}, Number<1>{});

        constexpr auto unfold_length = GetLength(Number<IDim>{});
        constexpr auto unfold_stride = GetStride(Number<IDim>{});

        // length of the dimension to be folded needs to be dividable by fold_interval_product,
        // otherwise, folding is invalid
Chao Liu's avatar
Chao Liu committed
168
        static_assert(unfold_length % fold_intervals_product == 0,
Chao Liu's avatar
Chao Liu committed
169
170
171
172
                      "wrong! length on the dimension to be folded cannot be evenly divided!");

        // folded lengths
        constexpr auto fold_lengths =
Chao Liu's avatar
Chao Liu committed
173
            Sequence<unfold_length / fold_intervals_product>{}.Append(fold_intervals);
Chao Liu's avatar
Chao Liu committed
174
175

        // folded strides
Chao Liu's avatar
Chao Liu committed
176
177
        constexpr auto fold_strides =
            Number<unfold_stride>{} *
Chao Liu's avatar
Chao Liu committed
178
179
            reverse_inclusive_scan_sequence(fold_intervals.PushBack(Number<1>{}),
                                            std::multiplies<index_t>{});
Chao Liu's avatar
Chao Liu committed
180

Chao Liu's avatar
Chao Liu committed
181
182
183
184
        // left and right
        constexpr auto left  = make_increasing_sequence(Number<0>{}, Number<IDim>{}, Number<1>{});
        constexpr auto right = make_increasing_sequence(
            Number<IDim + 1>{}, Number<GetNumOfDimension()>{}, Number<1>{});
Chao Liu's avatar
Chao Liu committed
185

Chao Liu's avatar
Chao Liu committed
186
        return make_ConstantTensorDescriptor(
Chao Liu's avatar
Chao Liu committed
187
188
            GetLengths().Extract(left).Append(fold_lengths).Append(GetLengths().Extract(right)),
            GetStrides().Extract(left).Append(fold_strides).Append(GetStrides().Extract(right)));
Chao Liu's avatar
Chao Liu committed
189
190
191
192
193
    }

    template <index_t FirstUnfoldDim, index_t LastUnfoldDim>
    __host__ __device__ static constexpr auto Unfold(Number<FirstUnfoldDim>, Number<LastUnfoldDim>)
    {
Chao Liu's avatar
Chao Liu committed
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
        static_assert(FirstUnfoldDim >= 0 && LastUnfoldDim < nDim &&
                          FirstUnfoldDim <= LastUnfoldDim,
                      "wrong! should have FirstUnfoldDim <= LastUnfoldDim!");

        // dimensions to be unfold need to be in descending order (w.r.t. strides), and need to be
        // packed in memory, otherwise, unfolding is invalid
        static_for<FirstUnfoldDim, LastUnfoldDim, 1>{}([&](auto IDim) {
            static_assert(
                GetStride(IDim) >= GetStride(Number<IDim.Get() + 1>{}),
                "wrong! dimensions to be unfolded need to be in descending order w.r.t strides");

            static_assert(GetStride(IDim + 1) * GetLength(IDim + 1) == GetStride(IDim),
                          "wrong! dimensions to be unfolded need to be packed");
        });

Chao Liu's avatar
Chao Liu committed
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
        // left and right
        constexpr auto left =
            make_increasing_sequence(Number<0>{}, Number<FirstUnfoldDim>{}, Number<1>{});
        constexpr auto middle = make_increasing_sequence(
            Number<FirstUnfoldDim>{}, Number<LastUnfoldDim + 1>{}, Number<1>{});
        constexpr auto right = make_increasing_sequence(
            Number<LastUnfoldDim + 1>{}, Number<GetNumOfDimension()>{}, Number<1>{});

        // length and stride
        constexpr index_t unfold_length = accumulate_on_sequence(
            GetLengths().Extract(middle), std::multiplies<index_t>{}, Number<1>{});

        constexpr index_t unfold_stride = GetStride(Number<LastUnfoldDim>{});

        return make_ConstantTensorDescriptor(GetLengths()
                                                 .Extract(left)
                                                 .PushBack(Number<unfold_length>{})
                                                 .Append(GetLengths().Extract(right)),
                                             GetStrides()
                                                 .Extract(left)
                                                 .PushBack(Number<unfold_stride>{})
                                                 .Append(GetStrides().Extract(right)));
Chao Liu's avatar
Chao Liu committed
231
232
233
234
235
    }

    template <index_t... IRs>
    __host__ __device__ static constexpr auto ReorderGivenNew2Old(Sequence<IRs...> /*new2old*/)
    {
Chao Liu's avatar
Chao Liu committed
236
        static_assert(sizeof...(IRs) == GetNumOfDimension(), "wrong! dimension is wrong");
Chao Liu's avatar
Chao Liu committed
237
238
239
240
        constexpr auto map_new2old = Sequence<IRs...>{};
        return make_ConstantTensorDescriptor(Lengths{}.ReorderGivenNew2Old(map_new2old),
                                             Strides{}.ReorderGivenNew2Old(map_new2old));
    }
Chao Liu's avatar
Chao Liu committed
241
};
Chao Liu's avatar
Chao Liu committed
242
243
244
245
246
247
248
249
250
251
252
253
254
255

template <class Lengths>
__host__ __device__ constexpr auto make_ConstantTensorDescriptor(Lengths)
{
    using Strides = decltype(calculate_default_strides(Lengths{}));
    return ConstantTensorDescriptor<Lengths, Strides>{};
}

template <class Lengths, class Strides>
__host__ __device__ constexpr auto make_ConstantTensorDescriptor(Lengths, Strides)
{
    return ConstantTensorDescriptor<Lengths, Strides>{};
}

Chao Liu's avatar
Chao Liu committed
256
template <class Lengths, index_t Align>
Chao Liu's avatar
Chao Liu committed
257
258
259
260
261
262
__host__ __device__ constexpr auto make_ConstantTensorDescriptor_aligned(Lengths, Number<Align>)
{
    using Strides = decltype(calculate_default_strides_aligned(Lengths{}, Number<Align>{}));
    return ConstantTensorDescriptor<Lengths, Strides>{};
}

Chao Liu's avatar
Chao Liu committed
263
template <class TDesc>
Chao Liu's avatar
Chao Liu committed
264
__host__ __device__ void print_ConstantTensorDescriptor(TDesc, const char* s)
Chao Liu's avatar
Chao Liu committed
265
{
Chao Liu's avatar
Chao Liu committed
266
    constexpr auto desc    = TDesc{};
Chao Liu's avatar
Chao Liu committed
267
    constexpr index_t ndim = desc.GetNumOfDimension();
Chao Liu's avatar
Chao Liu committed
268

Chao Liu's avatar
Chao Liu committed
269
    static_assert(ndim >= 2 && ndim <= 10, "wrong!");
Chao Liu's avatar
Chao Liu committed
270
271
272
273
274
275
276
277

    if(ndim == 2)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};

        printf("%s dim %u, lengths {%u %u}, strides {%u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
278
               desc.GetNumOfDimension(),
Chao Liu's avatar
Chao Liu committed
279
280
281
282
283
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetStride(I0),
               desc.GetStride(I1));
    }
284
285
286
287
288
289
290
291
    else if(ndim == 3)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};

        printf("%s dim %u, lengths {%u %u %u}, strides {%u %u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
292
               desc.GetNumOfDimension(),
293
294
295
296
297
298
299
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2));
    }
Chao Liu's avatar
Chao Liu committed
300
301
302
303
304
305
306
307
308
    else if(ndim == 4)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};

        printf("%s dim %u, lengths {%u %u %u %u}, strides {%u %u %u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
309
               desc.GetNumOfDimension(),
Chao Liu's avatar
Chao Liu committed
310
311
312
313
314
315
316
317
318
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3));
    }
319
320
321
322
323
324
325
326
327
328
    else if(ndim == 5)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};
        constexpr auto I4 = Number<4>{};

        printf("%s dim %u, lengths {%u %u %u %u %u}, strides {%u %u %u %u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
329
               desc.GetNumOfDimension(),
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetLength(I4),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3),
               desc.GetStride(I4));
    }
    else if(ndim == 6)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};
        constexpr auto I4 = Number<4>{};
        constexpr auto I5 = Number<5>{};

        printf("%s dim %u, lengths {%u %u %u %u %u %u}, strides {%u %u %u %u %u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
352
               desc.GetNumOfDimension(),
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetLength(I4),
               desc.GetLength(I5),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3),
               desc.GetStride(I4),
               desc.GetStride(I5));
    }
    else if(ndim == 7)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};
        constexpr auto I4 = Number<4>{};
        constexpr auto I5 = Number<5>{};
        constexpr auto I6 = Number<6>{};

        printf("%s dim %u, lengths {%u %u %u %u %u %u %u}, strides {%u %u %u %u %u %u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
378
               desc.GetNumOfDimension(),
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetLength(I4),
               desc.GetLength(I5),
               desc.GetLength(I6),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3),
               desc.GetStride(I4),
               desc.GetStride(I5),
               desc.GetStride(I6));
    }
    else if(ndim == 8)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};
        constexpr auto I4 = Number<4>{};
        constexpr auto I5 = Number<5>{};
        constexpr auto I6 = Number<6>{};
        constexpr auto I7 = Number<7>{};

        printf("%s dim %u, lengths {%u %u %u %u %u %u %u %u}, strides {%u %u %u %u %u %u %u %u}\n",
               s,
Chao Liu's avatar
Chao Liu committed
407
               desc.GetNumOfDimension(),
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetLength(I4),
               desc.GetLength(I5),
               desc.GetLength(I6),
               desc.GetLength(I7),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3),
               desc.GetStride(I4),
               desc.GetStride(I5),
               desc.GetStride(I6),
               desc.GetStride(I7));
    }
Chao Liu's avatar
Chao Liu committed
425
426
427
428
429
430
431
432
433
434
435
436
    else if(ndim == 9)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};
        constexpr auto I4 = Number<4>{};
        constexpr auto I5 = Number<5>{};
        constexpr auto I6 = Number<6>{};
        constexpr auto I7 = Number<7>{};
        constexpr auto I8 = Number<8>{};

Chao Liu's avatar
tidy yp  
Chao Liu committed
437
438
        printf("%s dim %u, lengths {%u %u %u %u %u %u %u %u %u}, strides {%u %u %u %u %u %u %u %u "
               "%u}\n",
Chao Liu's avatar
Chao Liu committed
439
               s,
Chao Liu's avatar
Chao Liu committed
440
               desc.GetNumOfDimension(),
Chao Liu's avatar
Chao Liu committed
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetLength(I4),
               desc.GetLength(I5),
               desc.GetLength(I6),
               desc.GetLength(I7),
               desc.GetLength(I8),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3),
               desc.GetStride(I4),
               desc.GetStride(I5),
               desc.GetStride(I6),
               desc.GetStride(I7),
               desc.GetStride(I8));
    }
    else if(ndim == 10)
    {
        constexpr auto I0 = Number<0>{};
        constexpr auto I1 = Number<1>{};
        constexpr auto I2 = Number<2>{};
        constexpr auto I3 = Number<3>{};
        constexpr auto I4 = Number<4>{};
        constexpr auto I5 = Number<5>{};
        constexpr auto I6 = Number<6>{};
        constexpr auto I7 = Number<7>{};
        constexpr auto I8 = Number<8>{};
        constexpr auto I9 = Number<9>{};

Chao Liu's avatar
tidy yp  
Chao Liu committed
473
474
        printf("%s dim %u, lengths {%u %u %u %u %u %u %u %u %u %u}, strides {%u %u %u %u %u %u %u "
               "%u %u %u}\n",
Chao Liu's avatar
Chao Liu committed
475
               s,
Chao Liu's avatar
Chao Liu committed
476
               desc.GetNumOfDimension(),
Chao Liu's avatar
Chao Liu committed
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
               desc.GetLength(I0),
               desc.GetLength(I1),
               desc.GetLength(I2),
               desc.GetLength(I3),
               desc.GetLength(I4),
               desc.GetLength(I5),
               desc.GetLength(I6),
               desc.GetLength(I7),
               desc.GetLength(I8),
               desc.GetLength(I9),
               desc.GetStride(I0),
               desc.GetStride(I1),
               desc.GetStride(I2),
               desc.GetStride(I3),
               desc.GetStride(I4),
               desc.GetStride(I5),
               desc.GetStride(I6),
               desc.GetStride(I7),
               desc.GetStride(I8),
               desc.GetStride(I9));
    }
Chao Liu's avatar
Chao Liu committed
498
}