CUTLASS
CUDA Templates for Linear Algebra Subroutines and Solvers
layout/matrix.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  **************************************************************************************************/
34 #pragma once
35 
36 #include "cutlass/cutlass.h"
37 #include "cutlass/matrix_coord.h"
38 #include "cutlass/matrix_traits.h"
39 
40 namespace cutlass {
41 namespace layout {
42 
44 //
45 // Defines data layouts of various matrix formats usable by TensorRef and other classes.
46 //
48 
50 class RowMajor {
51 public:
53  static int const kRank = 2;
54 
56  static int const kStrideRank = 1;
57 
59  using Index = int32_t;
60 
62  using LongIndex = int64_t;
63 
66 
69 
70 private:
71  //
72  // Data members
73  //
74 
76  Stride stride_;
77 
78 public:
79  //
80  // Methods
81  //
82 
85  RowMajor(Index ldm = 0): stride_(ldm) { }
86 
89  RowMajor(Stride stride): stride_(stride) { }
90 
93  static RowMajor packed(MatrixCoord const &extent) {
94  return RowMajor(extent.column());
95  }
96 
100  LongIndex operator()(MatrixCoord const &coord) const {
101  return coord.row() * stride_[0] + coord.column();
102  }
103 
106  MatrixCoord inverse(LongIndex offset) const {
107  return MatrixCoord(Index(offset / stride_[0]), Index(offset % stride_[0]));
108  }
109 
112  Stride stride() const {
113  return stride_;
114  }
115 
119  return stride_;
120  }
121 
124  Index stride(int idx) const {
125  return stride_[idx];
126  }
127 
130  Index & stride(int idx) {
131  return stride_[idx];
132  }
133 
136  LongIndex capacity(MatrixCoord const &extent) const {
137  return extent.row() * stride_[0];
138  }
139 };
140 
142 class ColumnMajor {
143 public:
145  static int const kRank = 2;
146 
148  static int const kStrideRank = 1;
149 
151  using Index = int32_t;
152 
154  using LongIndex = int64_t;
155 
158 
161 
162 private:
163  //
164  // Data members
165  //
166 
168  Stride stride_;
169 
170 public:
171  //
172  // Methods
173  //
174 
177  ColumnMajor(Index ldm = 0): stride_(ldm) { }
178 
181  ColumnMajor(Stride stride): stride_(stride) { }
182 
183 
186  static ColumnMajor packed(MatrixCoord const &extent) {
187  return ColumnMajor(extent.row());
188  }
189 
193  LongIndex operator()(MatrixCoord const &coord) const {
194  return coord.row() + coord.column() * stride_[0];
195  }
196 
199  MatrixCoord inverse(LongIndex offset) const {
200  return MatrixCoord(Index(offset % stride_[0]), Index(offset / stride_[0]));
201  }
202 
205  Stride stride() const {
206  return stride_;
207  }
208 
212  return stride_;
213  }
214 
217  Index stride(int idx) const {
218  return stride_[idx];
219  }
220 
223  Index & stride(int idx) {
224  return stride_[idx];
225  }
226 
229  LongIndex capacity(MatrixCoord const &extent) const {
230  return extent.column() * stride_[0];
231  }
232 };
233 
236 template <int Interleave>
238 
240  static int const kRank = 2;
241 
243  static int const kStrideRank = 1;
244 
246  using Index = int32_t;
247 
249  using LongIndex = int64_t;
250 
253 
256 
258  static int const kInterleave = Interleave;
259 
260 private:
261  //
262  // Data members
263  //
264 
266  Stride stride_;
267 
268 public:
269  //
270  // Methods
271  //
272 
275  RowMajorInterleaved(Index ldm = 0): stride_(ldm) { }
276 
279  RowMajorInterleaved(Stride stride): stride_(stride) { }
280 
283  static RowMajorInterleaved packed(MatrixCoord const &extent) {
284  return RowMajorInterleaved(extent.column() * kInterleave);
285  }
286 
290  LongIndex operator()(MatrixCoord const &coord) const {
291  Index row_major = coord.row() / kInterleave;
292  Index row_minor = coord.row() % kInterleave;
293  return row_major * stride_[0] + coord.column() * kInterleave + row_minor;
294  }
295 
298  MatrixCoord inverse(LongIndex offset) const {
299 
300  Index row_major = Index(offset / stride_[0]);
301  Index residual = Index(offset % stride_[0]);
302 
303  Index column = residual / kInterleave;
304  Index row_minor = residual % kInterleave;
305 
306  return MatrixCoord(row_major * kInterleave + row_minor, column);
307  }
308 
311  Stride stride() const {
312  return stride_;
313  }
314 
318  return stride_;
319  }
320 
323  Index stride(int idx) const {
324  return stride_[idx];
325  }
326 
329  Index & stride(int idx) {
330  return stride_[idx];
331  }
332 
335  LongIndex capacity(MatrixCoord const &extent) const {
336  return (extent.row() + kInterleave - 1) / kInterleave * stride_[0];
337  }
338 };
339 
342 template <int Interleave>
344 
346  static int const kRank = 2;
347 
349  static int const kStrideRank = 1;
350 
352  using Index = int32_t;
353 
355  using LongIndex = int64_t;
356 
359 
362 
364  static int const kInterleave = Interleave;
365 
366 private:
367  //
368  // Data members
369  //
370 
372  Stride stride_;
373 
374 public:
375  //
376  // Methods
377  //
378 
381  ColumnMajorInterleaved(Index ldm = 0): stride_(ldm) { }
382 
385  ColumnMajorInterleaved(Stride stride): stride_(stride) { }
386 
387 
390  static ColumnMajorInterleaved packed(MatrixCoord const &extent) {
391  return ColumnMajorInterleaved(extent.row() * kInterleave);
392  }
393 
397  LongIndex operator()(MatrixCoord const &coord) const {
398  Index column_major = coord.column() / kInterleave;
399  Index column_minor = coord.column() % kInterleave;
400  return column_major * stride_[0] + coord.row() * kInterleave + column_minor;
401  }
402 
405  MatrixCoord inverse(LongIndex offset) const {
406 
407  Index column_major = Index(offset / stride_[0]);
408  Index residual = Index(offset % stride_[0]);
409 
410  Index row = residual / kInterleave;
411  Index column_minor = residual % kInterleave;
412 
413  return MatrixCoord(row, column_major * kInterleave + column_minor);
414  }
415 
418  Stride stride() const {
419  return stride_;
420  }
421 
425  return stride_;
426  }
427 
430  Index stride(int idx) const {
431  return stride_[idx];
432  }
433 
436  Index & stride(int idx) {
437  return stride_[idx];
438  }
439 
442  LongIndex capacity(MatrixCoord const &extent) const {
443  return (extent.column() + kInterleave - 1) / kInterleave * stride_[0];
444  }
445 };
446 
448 enum class Matrix {
449  kColumnMajor,
450  kRowMajor
451 };
452 
456 
458  static int const kRank = 2;
459 
461  static int const kStrideRank = 1;
462 
464  using Index = int32_t;
465 
467  using LongIndex = int64_t;
468 
471 
474 
475 private:
476  //
477  // Data members
478  //
479 
481  Stride stride_;
482 
484  Matrix layout_;
485 
486 public:
487  //
488  // Methods
489  //
490 
494  Index ldm = 0,
496  ):
497  stride_(ldm), layout_(layout) { }
498 
502  MatrixCoord const &extent,
503  Matrix layout = Matrix::kColumnMajor) {
504 
505  Index ldm = 0;
506  if (layout == Matrix::kColumnMajor) {
507  ldm = extent.row();
508  }
509  else if (layout == Matrix::kRowMajor) {
510  ldm = extent.column();
511  }
512  return ContiguousMatrix(ldm, layout);
513  }
514 
518  LongIndex operator()(MatrixCoord const &coord) const {
519  if (layout_ == Matrix::kColumnMajor) {
520  return coord.row() + coord.column() * stride_[0];
521  }
522  else if (layout_ == Matrix::kRowMajor) {
523  return coord.row() * stride_[0] + coord.column();
524  }
525  else {
526  // degenerate case
527  return 0;
528  }
529  }
530 
533  MatrixCoord inverse(LongIndex offset) const {
534  // TODO
535  return MatrixCoord(0, 0);
536  }
537 
540  Stride stride() const {
541  return stride_;
542  }
543 
547  return stride_;
548  }
549 
552  Index stride(int idx) const {
553  return stride_[idx];
554  }
555 
558  Index & stride(int idx) {
559  return stride_[idx];
560  }
561 
564  LongIndex capacity(MatrixCoord const &extent) const {
565  if (layout_ == Matrix::kColumnMajor) {
566  return stride_[0] * extent.column();
567  }
568  else if (layout_ == Matrix::kRowMajor) {
569  return stride_[0] * extent.row();
570  }
571  else {
572  // degenerate case
573  return 0;
574  }
575  }
576 };
577 
580 template <int BlockRows, int BlockColumns>
583  static int const kRank = 2;
584 
586  static int const kStrideRank = 1;
587 
589  using Index = int32_t;
590 
592  using LongIndex = int64_t;
593 
596 
599 
601  static int const kBlockRows = BlockRows;
602 
604  static int const kBlockColumns = BlockColumns;
605 
606 private:
607  //
608  // Data members
609  //
610 
612  Stride stride_;
613 
614 public:
615  //
616  // Methods
617  //
618 
621  ColumnMajorBlockLinear(Index ldm = 0): stride_(ldm) { }
622 
625  static ColumnMajorBlockLinear packed(MatrixCoord const &extent) {
626  return ColumnMajorBlockLinear(extent.row() * kBlockRows * kBlockColumns);
627  }
628 
632  LongIndex operator()(MatrixCoord const &coord) const {
633  return
634  (coord.row() % kBlockRows) +
635  (coord.column() % kBlockColumns) * kBlockRows +
636  (coord.row() / kBlockRows) * kBlockRows * kBlockColumns +
637  (coord.column() / kBlockColumns) * stride_[0];
638  }
639 
642  MatrixCoord inverse(LongIndex offset) const {
643 
644  // TODO
645  return MatrixCoord(0, 0);
646  }
647 
650  Stride stride() const {
651  return stride_;
652  }
653 
657  return stride_;
658  }
659 
662  Index stride(int idx) const {
663  return stride_[idx];
664  }
665 
668  Index & stride(int idx) {
669  return stride_[idx];
670  }
671 
674  LongIndex capacity(MatrixCoord const &extent) const {
675  return (extent.column() + kBlockColumns - 1) / kBlockColumns * stride_[0];
676  }
677 };
678 
681 template <int BlockRows, int BlockColumns>
684  static int const kRank = 2;
685 
687  static int const kStrideRank = 1;
688 
690  using Index = int32_t;
691 
693  using LongIndex = int64_t;
694 
697 
700 
702  static int const kBlockRows = BlockRows;
703 
705  static int const kBlockColumns = BlockColumns;
706 
707 private:
708  //
709  // Data members
710  //
711 
713  Stride stride_;
714 
715 public:
716  //
717  // Methods
718  //
719 
722  RowMajorBlockLinear(Index ldm = 0): stride_(ldm) { }
723 
726  static RowMajorBlockLinear packed(MatrixCoord const &extent) {
727  return RowMajorBlockLinear(extent.column() * kBlockRows * kBlockColumns);
728  }
729 
733  LongIndex operator()(MatrixCoord const &coord) const {
734  return
735  (coord.column() % kBlockColumns) +
736  (coord.row() % kBlockRows) * kBlockColumns +
737  (coord.column() / kBlockColumns) * kBlockRows * kBlockColumns +
738  (coord.row() / kBlockRows) * stride_[0];
739  }
740 
743  MatrixCoord inverse(LongIndex offset) const {
744  // TODO
745  return MatrixCoord(0, 0);
746  }
747 
750  Stride stride() const {
751  return stride_;
752  }
753 
757  return stride_;
758  }
759 
762  Index stride(int idx) const {
763  return stride_[idx];
764  }
765 
768  Index & stride(int idx) {
769  return stride_[idx];
770  }
771 
774  LongIndex capacity(MatrixCoord const &extent) const {
775  return (extent.row() + kBlockRows - 1) / kBlockRows * stride_[0];
776  }
777 };
778 
780 
782 
784  static int const kRank = 2;
785 
787  static int const kStrideRank = 2;
788 
790  using Index = int32_t;
791 
793  using LongIndex = int64_t;
794 
797 
800 
801 private:
802  //
803  // Data members
804  //
805 
806  MatrixLayout layout_id_;
807 
809  Stride stride_;
810 
811 public:
812  //
813  // Methods
814  //
815 
818  GeneralMatrix(): layout_id_(MatrixLayout::kColumnMajor), stride_(make_Coord(0, 1)) { }
819 
823  MatrixLayout layout_id,
824  Index ldm,
825  Index interleave): layout_id_(layout_id), stride_(make_Coord(ldm, interleave)) { }
826 
830  MatrixCoord const &extent,
832  Index interleave = 1) {
833 
834  Index c;
835  if (layout_id == MatrixLayout::kRowMajor) {
836  c = extent.column();
837  }
838  else {
839  c = extent.row();
840  }
841 
842  Index ldm = c * interleave;
843 
844  return GeneralMatrix(layout_id, ldm, interleave);
845  }
846 
850  LongIndex operator()(MatrixCoord const &coord) const {
851  Index c, s;
852  if (layout_id_ == MatrixLayout::kRowMajor) {
853  c = coord.column();
854  s = coord.row();
855  }
856  else {
857  s = coord.column();
858  c = coord.row();
859  }
860 
861  Index v = s / stride_[1];
862  Index residual = (s % stride_[1]);
863 
864  return LongIndex(c) * LongIndex(stride_[1]) + LongIndex(v) * LongIndex(stride_[0]) + residual;
865  }
866 
869  Stride stride() const {
870  return stride_;
871  }
872 
875  return layout_id_;
876  }
877 
881  return stride_;
882  }
883 
886  return layout_id_;
887  }
888 
891  Index stride(int idx) const {
892  return stride_[idx];
893  }
894 
897  Index & stride(int idx) {
898  return stride_[idx];
899  }
900 
903  LongIndex capacity(MatrixCoord const &extent) const {
904  Index s;
905  if (layout_id_ == MatrixLayout::kRowMajor) {
906  s = extent.row();
907  }
908  else {
909  s = extent.column();
910  }
911 
912  Index v = Index((s + stride_[1] - 1) / stride_[1]);
913  return LongIndex(v) * LongIndex(stride_[0]);
914  }
915 };
916 
918 
920 template <typename Layout>
922 
924 template <>
925 struct LayoutTranspose<layout::RowMajor> {
927 };
928 
930 template <>
931 struct LayoutTranspose<layout::ColumnMajor> {
933 };
934 
936 
937 } // namespace layout
938 } // namespace cutlass
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:464
static CUTLASS_HOST_DEVICE RowMajorInterleaved packed(MatrixCoord const &extent)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:283
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:323
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:62
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:668
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:355
CUTLASS_HOST_DEVICE Index const & column() const
Returns the column of the coordinate.
Definition: matrix_coord.h:85
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:540
static CUTLASS_HOST_DEVICE RowMajorBlockLinear packed(MatrixCoord const &extent)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:726
Definition: aligned_buffer.h:35
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:750
leading dimension refers to stride between columns; stride along rows is 1
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:311
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:768
CUTLASS_HOST_DEVICE ColumnMajorInterleaved(Index ldm=0)
Ctor.
Definition: layout/matrix.h:381
CUTLASS_HOST_DEVICE GeneralMatrix(MatrixLayout layout_id, Index ldm, Index interleave)
Ctor.
Definition: layout/matrix.h:822
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:592
Definition: layout/matrix.h:455
Definition: layout/matrix.h:781
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:662
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:442
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:130
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:124
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:467
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:249
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:397
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:793
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:693
static int const kRank
Logical rank of tensor.
Definition: layout/matrix.h:53
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:211
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:329
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:352
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:558
CUTLASS_HOST_DEVICE Coord< 1 > make_Coord(int _0)
Helper to make a 2-element coordinate.
Definition: coord.h:387
int64_t LongIndex
Long index type used for offsets.
Definition: layout/matrix.h:154
CUTLASS_HOST_DEVICE ColumnMajor(Index ldm=0)
Ctor.
Definition: layout/matrix.h:177
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:298
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:733
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:246
CUTLASS_HOST_DEVICE Index const & row() const
Returns the row of the coordinate.
Definition: matrix_coord.h:77
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:136
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:418
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:112
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:335
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:106
Definition: layout/matrix.h:581
Mapping function for column-major matrices.
Definition: layout/matrix.h:142
CUTLASS_HOST_DEVICE MatrixLayout & layout_id()
Definition: layout/matrix.h:885
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:762
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:891
CUTLASS_HOST_DEVICE GeneralMatrix()
Ctor.
Definition: layout/matrix.h:818
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:59
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:650
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:642
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:897
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:100
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:790
Defines transposes of matrix layouts.
Definition: layout/matrix.h:921
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:632
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:564
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:589
Matrix
Enumerated type for canonical pitch-linear matrix layouts.
Definition: layout/matrix.h:448
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:518
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:199
Definition: layout/matrix.h:682
MatrixLayout
Definition: matrix_traits.h:36
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:436
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:690
CUTLASS_HOST_DEVICE RowMajorInterleaved(Stride stride)
Ctor.
Definition: layout/matrix.h:279
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:89
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:533
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:743
static CUTLASS_HOST_DEVICE ColumnMajor packed(MatrixCoord const &extent)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:186
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:756
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:774
static CUTLASS_HOST_DEVICE GeneralMatrix packed(MatrixCoord const &extent, MatrixLayout layout_id=MatrixLayout::kColumnMajor, Index interleave=1)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:829
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:229
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:118
static CUTLASS_HOST_DEVICE ContiguousMatrix packed(MatrixCoord const &extent, Matrix layout=Matrix::kColumnMajor)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:501
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:205
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:424
leading dimension refers to stride between rows; stride along columns is 1
Mapping function for row-major matrices.
Definition: layout/matrix.h:50
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:193
Defines a canonical coordinate for rank=2 matrices offering named indices.
CUTLASS_HOST_DEVICE RowMajor(Stride stride)
Ctor.
Definition: layout/matrix.h:89
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:880
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:290
CUTLASS_HOST_DEVICE ContiguousMatrix(Index ldm=0, Matrix layout=Matrix::kColumnMajor)
Ctor.
Definition: layout/matrix.h:493
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:430
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:317
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:552
CUTLASS_HOST_DEVICE Index stride(int idx) const
Returns the stride of the layout.
Definition: layout/matrix.h:217
static CUTLASS_HOST_DEVICE ColumnMajorBlockLinear packed(MatrixCoord const &extent)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:625
CUTLASS_HOST_DEVICE ColumnMajorInterleaved(Stride stride)
Ctor.
Definition: layout/matrix.h:385
CUTLASS_HOST_DEVICE LongIndex operator()(MatrixCoord const &coord) const
Definition: layout/matrix.h:850
Definition: layout/matrix.h:343
int32_t Index
Index type used for coordinates.
Definition: layout/matrix.h:151
CUTLASS_HOST_DEVICE Stride stride() const
Returns the stride of the layout.
Definition: layout/matrix.h:869
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:656
static CUTLASS_HOST_DEVICE RowMajor packed(MatrixCoord const &extent)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:93
CUTLASS_HOST_DEVICE RowMajorInterleaved(Index ldm=0)
Ctor.
Definition: layout/matrix.h:275
CUTLASS_HOST_DEVICE RowMajorBlockLinear(Index ldm=0)
Ctor.
Definition: layout/matrix.h:722
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:903
CUTLASS_HOST_DEVICE MatrixCoord inverse(LongIndex offset) const
Inverse of layout function, mapping linear offset to logical coordinate.
Definition: layout/matrix.h:405
Defines properties of matrices used to denote layout and operands to GEMM kernels.
static CUTLASS_HOST_DEVICE ColumnMajorInterleaved packed(MatrixCoord const &extent)
Helper returns a layout to a tightly packed tensor.
Definition: layout/matrix.h:390
CUTLASS_HOST_DEVICE Index & stride(int idx)
Returns the stride of the layout.
Definition: layout/matrix.h:223
CUTLASS_HOST_DEVICE Stride & stride()
Returns the stride of the layout.
Definition: layout/matrix.h:546
Basic include for CUTLASS.
Definition: matrix_coord.h:39
CUTLASS_HOST_DEVICE LongIndex capacity(MatrixCoord const &extent) const
Compute the number of contiguous elements needed to store a tensor with the given size...
Definition: layout/matrix.h:674
CUTLASS_HOST_DEVICE ColumnMajor(Stride stride)
Ctor.
Definition: layout/matrix.h:181
static int const kStrideRank
Rank of stride vector.
Definition: layout/matrix.h:56
CUTLASS_HOST_DEVICE ColumnMajorBlockLinear(Index ldm=0)
Ctor.
Definition: layout/matrix.h:621
CUTLASS_HOST_DEVICE RowMajor(Index ldm=0)
Constructor.
Definition: layout/matrix.h:85
CUTLASS_HOST_DEVICE MatrixLayout layout_id() const
Definition: layout/matrix.h:874
Definition: layout/matrix.h:237