CUTLASS
CUDA Templates for Linear Algebra Subroutines and Solvers
volta_tensor_op_policy.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  **************************************************************************************************/
31 #pragma once
32 
33 #include "cutlass/matrix_shape.h"
34 #include "cutlass/layout/matrix.h"
35 #include "cutlass/gemm/gemm.h"
36 
38 
39 namespace cutlass {
40 namespace epilogue {
41 namespace warp {
42 
44 
46 template <
47  typename WarpShape,
48  typename InterleavedTileShape,
49  typename ElementC,
50  typename Layout
51 >
53 
55 
57 template <
58  typename WarpShape_
59 >
60 struct VoltaTensorOpPolicy<WarpShape_, gemm::GemmShape<32, 32, 4>, half_t, layout::RowMajor> {
61 
62  using WarpShape = WarpShape_;
63  using InterleavedTileShape = gemm::GemmShape<32, 32, 4>;
64  using ElementC = half_t;
66 
69 
71  using MmaIterations = MatrixShape<
72  InterleavedTileShape::kM / InstructionShape::kM,
73  InterleavedTileShape::kN / InstructionShape::kN
74  >;
75 
78  WarpShape::kM / InterleavedTileShape::kM,
79  WarpShape::kN / InterleavedTileShape::kN
80  >;
81 
83  static int const kElementsPerMma = 8;
84  static int const kRowsPerIteration = 16;
85 
86  //
87  // Hard-coded constants regarding Tensor Operations
88  //
89 
91  static int const kElementsPerAccess = 4;
92 
94  static int const kAccessesPerInterleavedTile = 4;
95 
97  static int const kIterations = TileIterations::kRow * 2;
98 
99  //
100  // Derived types
101  //
102 
105 
107  using Fragment = Array<
108  ElementC,
109  kElementsPerAccess * kAccessesPerInterleavedTile * TileIterations::kColumn>;
110 
112  using AccumulatorTile = Array<
113  ElementC,
114  TileIterations::kCount * MmaIterations::kCount * kElementsPerMma>;
115 };
116 
118 
120 template <
121  typename WarpShape_
122 >
123 struct VoltaTensorOpPolicy<WarpShape_, gemm::GemmShape<32, 32, 4>, float, layout::RowMajor> {
124 
125  using WarpShape = WarpShape_;
126  using InterleavedTileShape = gemm::GemmShape<32, 32, 4>;
127  using ElementC = float;
129 
132 
134  using MmaIterations = MatrixShape<
135  InterleavedTileShape::kM / InstructionShape::kM,
136  InterleavedTileShape::kN / InstructionShape::kN
137  >;
138 
140  using TileIterations = MatrixShape<
141  WarpShape::kM / InterleavedTileShape::kM,
142  WarpShape::kN / InterleavedTileShape::kN
143  >;
144 
146  static int const kElementsPerMma = 8;
147  static int const kRowsPerIteration = 16;
148 
149  //
150  // Hard-coded constants regarding Tensor Operations
151  //
152 
154  static int const kElementsPerAccess = 2;
155 
157  static int const kAccessesPerInterleavedTile = 8;
158 
160  static int const kRowsPerMmaTile = 2;
161 
163  static int const kIterations = TileIterations::kRow * MmaIterations::kRow;
164 
165  //
166  // Derived types
167  //
168 
171 
173  using Fragment = Array<
174  ElementC,
175  kElementsPerAccess * kAccessesPerInterleavedTile * TileIterations::kColumn>;
176 
178  using AccumulatorTile = Array<
179  ElementC,
180  TileIterations::kCount * MmaIterations::kCount * kElementsPerMma>;
181 };
182 
184 
185 } // namespace warp
186 } // namespace epilogue
187 } // namespace cutlass
188 
Describes the size of a matrix tile.
Definition: matrix_shape.h:42
Definition: aligned_buffer.h:35
Array< ElementC, kElementsPerAccess *kAccessesPerInterleavedTile *TileIterations::kColumn > Fragment
This is the fragment size produced by one access of the iterator.
Definition: volta_tensor_op_policy.h:175
Aligned array type.
Definition: array.h:511
IEEE half-precision floating-point type.
Definition: half.h:126
Defines common types used for all GEMM-like operators.
Defines a Shape template for matrix tiles.
Shape of a matrix multiply-add operation.
Definition: include/cutlass/gemm/gemm.h:57
Mapping function for row-major matrices.
Definition: layout/matrix.h:50
Array< ElementC, kElementsPerAccess *kAccessesPerInterleavedTile *TileIterations::kColumn > Fragment
This is the fragment size produced by one access of the iterator.
Definition: volta_tensor_op_policy.h:109
Defines layout functions used by TensorRef and derived classes.
Policy details related to the epilogue.
Definition: volta_tensor_op_policy.h:52
Array< ElementC, TileIterations::kCount *MmaIterations::kCount *kElementsPerMma > AccumulatorTile
This is the complete warp-level accumulator tile.
Definition: volta_tensor_op_policy.h:180
Array< ElementC, TileIterations::kCount *MmaIterations::kCount *kElementsPerMma > AccumulatorTile
This is the complete warp-level accumulator tile.
Definition: volta_tensor_op_policy.h:114