# CUTLASS: default_epilogue_volta_tensor_op.h Source File

default_epilogue_volta_tensor_op.h
Go to the documentation of this file.
/***************************************************************************************************
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************************************/
#pragma once
#include "cutlass/cutlass.h"
#include "cutlass/numeric_types.h"
#include "cutlass/array.h"
#include "cutlass/gemm/gemm.h"
#include "cutlass/epilogue/thread/linear_combination.h"
#include "cutlass/epilogue/thread/conversion_op.h"
#include "cutlass/epilogue/thread/reduction_op.h"
#include "cutlass/transform/threadblock/regular_tile_iterator_pitch_linear.h"
#include "cutlass/epilogue/threadblock/predicated_tile_iterator.h"
#include "cutlass/epilogue/threadblock/shared_load_iterator.h"
#include "cutlass/epilogue/warp/fragment_iterator_volta_tensor_op.h"
#include "cutlass/epilogue/warp/tile_iterator_volta_tensor_op.h"
#include "cutlass/epilogue/threadblock/default_thread_map_volta_tensor_op.h"
#include "cutlass/epilogue/threadblock/epilogue.h"
namespace cutlass {
namespace epilogue {
namespace threadblock {
template <
typename Shape_,
typename WarpMmaTensorOp_,
int PartitionsK,
typename OutputOp_,
int ElementsPerAccess
>
struct DefaultEpilogueVoltaTensorOp {
using Shape = Shape_;
using WarpMmaTensorOp = WarpMmaTensorOp_;
static int const kPartitionsK = PartitionsK;
using OutputOp = OutputOp_;
static int const kElementsPerAccess = ElementsPerAccess;
using ElementOutput = typename OutputOp::ElementOutput;
using LayoutC = typename WarpMmaTensorOp::LayoutC;
using ElementAccumulator = typename WarpMmaTensorOp::ElementC;
//
// Thread map
//
using OutputTileThreadMap = typename cutlass::epilogue::threadblock::DefaultThreadMapVoltaTensorOp<
Shape,
typename WarpMmaTensorOp::Shape,
kPartitionsK,
ElementOutput,
kElementsPerAccess,
ElementAccumulator
>::Type;
using OutputTileIterator = cutlass::epilogue::threadblock::PredicatedTileIterator<
OutputTileThreadMap,
ElementOutput
>;
using AccumulatorFragmentIterator = cutlass::epilogue::warp::FragmentIteratorVoltaTensorOp<
typename WarpMmaTensorOp::Shape,
gemm::GemmShape<32, 32, 4>,
ElementAccumulator,
LayoutC
>;
using WarpTileIterator = cutlass::epilogue::warp::TileIteratorVoltaTensorOp<
typename WarpMmaTensorOp::Shape,
gemm::GemmShape<32, 32, 4>,
ElementAccumulator,
LayoutC
>;
static int const kSharedMemAlignment = sizeof_bits<ElementAccumulator>::value * WarpTileIterator::kElementsPerAccess / 8;
static_assert(kSharedMemAlignment == 8, "Shared memory alignment must be 8B");
using SharedLoadIterator = cutlass::epilogue::threadblock::SharedLoadIterator<
typename OutputTileThreadMap::CompactedThreadMap,
ElementAccumulator,
kSharedMemAlignment
>;
using Padding = typename WarpTileIterator::Padding;
//
// Define the epilogue
//
using Epilogue = cutlass::epilogue::threadblock::Epilogue<
Shape,
WarpMmaTensorOp,
kPartitionsK,
OutputTileIterator,
AccumulatorFragmentIterator,
WarpTileIterator,
SharedLoadIterator,
OutputOp,
Padding
>;
};
} // namespace threadblock
} // namespace epilogue
} // namespace cutlass
regular_tile_iterator_pitch_linear.h
Templates implementing loading of tiles from pitch-linear rank=2 tensors.
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::WarpMmaTensorOp
WarpMmaTensorOp_ WarpMmaTensorOp
Definition: default_epilogue_volta_tensor_op.h:74
cutlass
Definition: aligned_buffer.h:35
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::kPartitionsK
static int const kPartitionsK
Definition: default_epilogue_volta_tensor_op.h:75
predicated_tile_iterator.h
Epilogue for threadblock scoped GEMMs using Tensor Ops.
fragment_iterator_volta_tensor_op.h
This defines a "fragment" iterator for visiting the fragments of an accumulator tile that participate...
gemm.h
Defines common types used for all GEMM-like operators.
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::kElementsPerAccess
static int const kElementsPerAccess
Definition: default_epilogue_volta_tensor_op.h:77
conversion_op.h
Functor performing conversion operations used by epilogues.
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::LayoutC
typename WarpMmaTensorOp::LayoutC LayoutC
Definition: default_epilogue_volta_tensor_op.h:80
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::Shape
Shape_ Shape
Definition: default_epilogue_volta_tensor_op.h:73
array.h
Statically sized array of elements that accommodates all CUTLASS-supported numeric types and is safe ...
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::SharedLoadIterator
cutlass::epilogue::threadblock::SharedLoadIterator< typename OutputTileThreadMap::CompactedThreadMap, ElementAccumulator, kSharedMemAlignment > SharedLoadIterator
Definition: default_epilogue_volta_tensor_op.h:123
tile_iterator_volta_tensor_op.h
linear_combination.h
Functor performing linear combination operations used by epilogues.
cutlass::sizeof_bits
Defines the size of an element in bits.
Definition: numeric_types.h:42
cutlass::epilogue::warp::TileIteratorVoltaTensorOp
Template for reading and writing tiles of accumulators to shared memory.
Definition: tile_iterator_volta_tensor_op.h:52
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::AccumulatorFragmentIterator
cutlass::epilogue::warp::FragmentIteratorVoltaTensorOp< typename WarpMmaTensorOp::Shape, gemm::GemmShape< 32, 32, 4 >, ElementAccumulator, LayoutC > AccumulatorFragmentIterator
Definition: default_epilogue_volta_tensor_op.h:106
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::kSharedMemAlignment
static int const kSharedMemAlignment
Definition: default_epilogue_volta_tensor_op.h:115
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::WarpTileIterator
cutlass::epilogue::warp::TileIteratorVoltaTensorOp< typename WarpMmaTensorOp::Shape, gemm::GemmShape< 32, 32, 4 >, ElementAccumulator, LayoutC > WarpTileIterator
Definition: default_epilogue_volta_tensor_op.h:113
default_thread_map_volta_tensor_op.h
numeric_types.h
Top-level include for all CUTLASS numeric types.
cutlass::epilogue::warp::FragmentIteratorVoltaTensorOp
Definition: fragment_iterator_volta_tensor_op.h:61
cutlass::gemm::GemmShape
Shape of a matrix multiply-add operation.
Definition: include/cutlass/gemm/gemm.h:57
static_assert
#define static_assert(__e, __m)
Definition: platform.h:153
shared_load_iterator.h
Epilogue for threadblock scoped GEMMs using Tensor Ops.
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp
Defines sensible defaults for epilogues for TensorOps.
Definition: default_epilogue_volta_tensor_op.h:71
cutlass::epilogue::threadblock::Epilogue
Epilogue operator without splitk.
Definition: epilogue.h:74
epilogue.h
Epilogue for threadblock scoped GEMMs using Tensor Ops.
cutlass::epilogue::threadblock::PredicatedTileIterator
Definition: epilogue/threadblock/predicated_tile_iterator.h:65
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::OutputTileIterator
cutlass::epilogue::threadblock::PredicatedTileIterator< OutputTileThreadMap, ElementOutput > OutputTileIterator
Definition: default_epilogue_volta_tensor_op.h:99
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::ElementAccumulator
typename WarpMmaTensorOp::ElementC ElementAccumulator
Definition: default_epilogue_volta_tensor_op.h:81
cutlass::epilogue::threadblock::DefaultThreadMapVoltaTensorOp
Defines the optimal thread map for TensorOp accumulator layouts.
Definition: default_thread_map_volta_tensor_op.h:52
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::Padding
typename WarpTileIterator::Padding Padding
Hard-coded padding elements added.
Definition: default_epilogue_volta_tensor_op.h:126
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::OutputTileThreadMap
typename cutlass::epilogue::threadblock::DefaultThreadMapVoltaTensorOp< Shape, typename WarpMmaTensorOp::Shape, kPartitionsK, ElementOutput, kElementsPerAccess, ElementAccumulator >::Type OutputTileThreadMap
Definition: default_epilogue_volta_tensor_op.h:94
cutlass::epilogue::threadblock::SharedLoadIterator
Definition: shared_load_iterator.h:61
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::ElementOutput
typename OutputOp::ElementOutput ElementOutput
Definition: default_epilogue_volta_tensor_op.h:79
reduction_op.h
Functor performing reduction operations used by epilogues.
cutlass.h
Basic include for CUTLASS.
cutlass::epilogue::threadblock::DefaultEpilogueVoltaTensorOp::OutputOp
OutputOp_ OutputOp
Definition: default_epilogue_volta_tensor_op.h:76