CUTLASS
CUDA Templates for Linear Algebra Subroutines and Solvers
default_epilogue_tensor_op.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  **************************************************************************************************/
33 #pragma once
34 
35 #include "cutlass/cutlass.h"
36 #include "cutlass/numeric_types.h"
37 #include "cutlass/array.h"
38 
39 #include "cutlass/gemm/gemm.h"
40 
44 
46 
52 
55 
57 
58 namespace cutlass {
59 namespace epilogue {
60 namespace threadblock {
61 
63 
65 template <
66  typename Shape_,
67  typename WarpMmaTensorOp_,
68  int PartitionsK,
69  typename OutputOp_,
70  int ElementsPerAccess
71 >
73 
74  using Shape = Shape_;
75  using WarpMmaTensorOp = WarpMmaTensorOp_;
76  static int const kPartitionsK = PartitionsK;
77  using OutputOp = OutputOp_;
78  static int const kElementsPerAccess = ElementsPerAccess;
79 
80  using ElementOutput = typename OutputOp::ElementOutput;
81  using LayoutC = typename WarpMmaTensorOp::LayoutC;
82  using ElementAccumulator = typename WarpMmaTensorOp::ElementC;
83 
84  //
85  // Thread map
86  //
87 
89  Shape,
90  typename WarpMmaTensorOp::Shape,
93  kElementsPerAccess
94  >::Type;
95 
98  ElementOutput
99  >;
100 
102  typename WarpMmaTensorOp::Shape,
103  typename WarpMmaTensorOp::Policy::Operator::Shape,
104  typename WarpMmaTensorOp::Policy::Operator::ElementC,
105  typename WarpMmaTensorOp::Policy::Operator::FragmentC,
106  LayoutC
107  >;
108 
110  typename WarpMmaTensorOp::Shape,
111  typename WarpMmaTensorOp::Policy::Operator::Shape,
113  LayoutC
114  >;
115 
117  typename OutputTileThreadMap::CompactedThreadMap,
118  ElementAccumulator
119  >;
120 
123 
124  //
125  // Define the epilogue
126  //
128  Shape,
130  kPartitionsK,
135  OutputOp,
136  Padding
137  >;
138 };
139 
141 
144 template <typename Shape_, typename WarpMmaTensorOp_, int PartitionsK,
145  typename OutputOp_, int ElementsPerAccess, int InterleavedK,
146  bool IsBetaZero = false, bool isSplitK = false>
148  using Shape = Shape_;
149  using WarpMmaTensorOp = WarpMmaTensorOp_;
150  static int const kPartitionsK = PartitionsK;
151  using OutputOp = OutputOp_;
152  static int const kElementsPerAccess = ElementsPerAccess;
153 
154  using ElementOutput = typename OutputOp::ElementOutput;
155  using LayoutC = typename WarpMmaTensorOp::LayoutC;
156  using ElementAccumulator = typename WarpMmaTensorOp::ElementC;
157 
158  //
159  // Thread map
160  //
163  Shape, typename WarpMmaTensorOp::Shape, kPartitionsK, ElementOutput,
164  kElementsPerAccess, InterleavedK>::Type;
165 
166  using OutputTileIterator =
169 
172  typename WarpMmaTensorOp::Shape,
173  typename WarpMmaTensorOp::Policy::Operator::Shape,
174  typename WarpMmaTensorOp::Policy::Operator::ElementC,
175  typename WarpMmaTensorOp::Policy::Operator::FragmentC,
177 
178  //
179  // Define the epilogue
180  //
183  AccumulatorFragmentIterator, OutputOp, InterleavedK, IsBetaZero>;
184 };
185 
187 } // namespace threadblock
188 } // namespace epilogue
189 } // namespace cutlass
190 
Describes the size of a matrix tile.
Definition: matrix_shape.h:42
Templates implementing loading of tiles from pitch-linear rank=2 tensors.
Definition: aligned_buffer.h:35
typename WarpMmaTensorOp::LayoutC LayoutC
Definition: default_epilogue_tensor_op.h:81
typename OutputOp::ElementOutput ElementOutput
Definition: default_epilogue_tensor_op.h:80
Epilogue for threadblock scoped GEMMs using Tensor Ops.
Epilogue operator without splitk.
Definition: interleaved_epilogue.h:79
WarpMmaTensorOp_ WarpMmaTensorOp
Definition: default_epilogue_tensor_op.h:75
Defines common types used for all GEMM-like operators.
Functor performing conversion operations used by epilogues.
static int const kPartitionsK
Definition: default_epilogue_tensor_op.h:76
OutputOp_ OutputOp
Definition: default_epilogue_tensor_op.h:151
WarpMmaTensorOp_ WarpMmaTensorOp
Definition: default_epilogue_tensor_op.h:149
This defines a "fragment" iterator for visiting the fragments of an accumulator tile that participate...
cutlass::epilogue::threadblock::PredicatedTileIterator< OutputTileThreadMap, ElementOutput > OutputTileIterator
Definition: default_epilogue_tensor_op.h:99
typename WarpMmaTensorOp::ElementC ElementAccumulator
Definition: default_epilogue_tensor_op.h:82
Statically sized array of elements that accommodates all CUTLASS-supported numeric types and is safe ...
Defines the optimal thread map for TensorOp accumulator layouts.
Definition: default_thread_map_tensor_op.h:104
Shape_ Shape
Definition: default_epilogue_tensor_op.h:74
Functor performing linear combination operations used by epilogues.
Defines the size of an element in bits.
Definition: numeric_types.h:42
typename WarpMmaTensorOp::LayoutC LayoutC
Definition: default_epilogue_tensor_op.h:155
typename WarpMmaTensorOp::ElementC ElementAccumulator
Definition: default_epilogue_tensor_op.h:156
Defines the optimal thread map for TensorOp accumulator layouts.
Definition: default_thread_map_tensor_op.h:52
Top-level include for all CUTLASS numeric types.
Template for reading and writing tiles of accumulators to shared memory.
Definition: tile_iterator_tensor_op.h:52
cutlass::epilogue::threadblock::SharedLoadIterator< typename OutputTileThreadMap::CompactedThreadMap, ElementAccumulator > SharedLoadIterator
Definition: default_epilogue_tensor_op.h:119
Definition: epilogue/threadblock/predicated_tile_iterator.h:452
Epilogue for threadblock scoped GEMMs using Tensor Ops.
Definition: fragment_iterator_tensor_op.h:61
typename OutputOp::ElementOutput ElementOutput
Definition: default_epilogue_tensor_op.h:154
Epilogue operator without splitk.
Definition: epilogue.h:74
Epilogue for threadblock scoped GEMMs using Tensor Ops.
Definition: epilogue/threadblock/predicated_tile_iterator.h:65
cutlass::epilogue::warp::TileIteratorTensorOp< typename WarpMmaTensorOp::Shape, typename WarpMmaTensorOp::Policy::Operator::Shape, ElementAccumulator, LayoutC > WarpTileIterator
Definition: default_epilogue_tensor_op.h:114
Definition: default_epilogue_tensor_op.h:147
typename cutlass::epilogue::threadblock::DefaultInterleavedThreadMapTensorOp< Shape, typename WarpMmaTensorOp::Shape, kPartitionsK, ElementOutput, kElementsPerAccess, InterleavedK >::Type OutputTileThreadMap
Definition: default_epilogue_tensor_op.h:164
Definition: shared_load_iterator.h:61
typename cutlass::epilogue::threadblock::DefaultThreadMapTensorOp< Shape, typename WarpMmaTensorOp::Shape, kPartitionsK, ElementOutput, kElementsPerAccess >::Type OutputTileThreadMap
Definition: default_epilogue_tensor_op.h:94
Defines sensible defaults for epilogues for TensorOps.
Definition: default_epilogue_tensor_op.h:72
cutlass::epilogue::warp::FragmentIteratorTensorOp< typename WarpMmaTensorOp::Shape, typename WarpMmaTensorOp::Policy::Operator::Shape, typename WarpMmaTensorOp::Policy::Operator::ElementC, typename WarpMmaTensorOp::Policy::Operator::FragmentC, LayoutC > AccumulatorFragmentIterator
Definition: default_epilogue_tensor_op.h:107
Functor performing reduction operations used by epilogues.
Shape_ Shape
Definition: default_epilogue_tensor_op.h:148
Basic include for CUTLASS.
static int const kElementsPerAccess
Definition: default_epilogue_tensor_op.h:78
OutputOp_ OutputOp
Definition: default_epilogue_tensor_op.h:77
Epilogue for threadblock scoped GEMMs using Tensor Ops.