| CUTLASS CUDA Templates for Linear Algebra Subroutines and Solvers

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
37
38 namespace cutlass {
39 namespace epilogue {
40 namespace warp {
41
43
45 template <
46 typename WarpShape,
47 typename OperatorShape,
48 typename Layout
49 >
50 struct TensorOpPolicy;
51
53
55 template <
56 typename WarpShape,
57 typename OperatorShape
58 >
59 struct TensorOpPolicy<WarpShape, OperatorShape, layout::RowMajor> {
60
62 using OperatorCount = MatrixShape<
63 WarpShape::kM / OperatorShape::kM,
64 WarpShape::kN / OperatorShape::kN
65 >;
66
67 //
68 // Hard-coded constants regarding Tensor Operations
69 //
70
71 static int const kElementsPerAccess = 2;
72 static int const kRowsPerIteration = 8;
73
74 //
75 // Derived quantities
76 //
77
78 // Number of 'externally visible' iterations per actual instruction
79 static int const kIterationsPerInstruction = OperatorShape::kM / kRowsPerIteration;
80
81 // Number of externally visible iterations
82 static int const kIterations = OperatorCount::kRow * kIterationsPerInstruction;
83
84 static int const kAccumulatorRowStride = kElementsPerAccess;
85 static int const kAccumulatorColumnStride = kElementsPerAccess * OperatorCount::kRow * kIterationsPerInstruction;
86 };
87
89
91 template <
92 typename WarpShape,
93 typename OperatorShape,
94 int InterleavedK
95 >
96 struct TensorOpPolicy<WarpShape, OperatorShape,
97 layout::ColumnMajorInterleaved<InterleavedK> > {
99 using OperatorCount = MatrixShape<WarpShape::kM / OperatorShape::kM,
100 WarpShape::kN / OperatorShape::kN>;
101
102 //
103 // Hard-coded constants regarding Tensor Operations
104 //
105
106 static int const kElementsPerAccess = 2;
107 static int const kRowsPerIteration = 8;
108
109 //
110 // Derived quantities
111 //
112
113 // Number of 'externally visible' iterations per actual instruction
114 static int const kIterationsPerInstruction =
115 OperatorShape::kM / kRowsPerIteration;
116
117 // Number of externally visible iterations
118 static int const kIterations = WarpShape::kN / InterleavedK *
119 OperatorCount::kRow *
120 kIterationsPerInstruction;
121 };
122
124
125 } // namespace warp
126 } // namespace epilogue
127 } // namespace cutlass
128
cutlass::MatrixShape
Describes the size of a matrix tile.
Definition: matrix_shape.h:42
cutlass
Definition: aligned_buffer.h:35
matrix_shape.h
Defines a Shape template for matrix tiles.
cutlass::epilogue::warp::TensorOpPolicy
Policy details related to the epilogue.
Definition: tensor_op_policy.h:50
matrix.h
Defines layout functions used by TensorRef and derived classes.