volta_tensor_op_policy.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/matrix_shape.h"
#include "cutlass/layout/matrix.h"
#include "cutlass/gemm/gemm.h"
namespace cutlass {
namespace epilogue {
namespace warp {
template <
typename WarpShape,
typename InterleavedTileShape,
typename ElementC,
typename Layout
>
struct VoltaTensorOpPolicy;
template <
typename WarpShape_
>
struct VoltaTensorOpPolicy<WarpShape_, gemm::GemmShape<32, 32, 4>, half_t, layout::RowMajor> {
using WarpShape = WarpShape_;
using InterleavedTileShape = gemm::GemmShape<32, 32, 4>;
using ElementC = half_t;
using Layout = layout::RowMajor;
using InstructionShape = gemm::GemmShape<16, 16, 4>;
using MmaIterations = MatrixShape<
InterleavedTileShape::kM / InstructionShape::kM,
InterleavedTileShape::kN / InstructionShape::kN
>;
using TileIterations = MatrixShape<
WarpShape::kM / InterleavedTileShape::kM,
WarpShape::kN / InterleavedTileShape::kN
>;
static int const kElementsPerMma = 8;
static int const kRowsPerIteration = 16;
//
// Hard-coded constants regarding Tensor Operations
//
static int const kElementsPerAccess = 4;
static int const kAccessesPerInterleavedTile = 4;
static int const kIterations = TileIterations::kRow * 2;
//
// Derived types
//
using AccessType = AlignedArray<ElementC, kElementsPerAccess>;
using Fragment = Array<
ElementC,
kElementsPerAccess * kAccessesPerInterleavedTile * TileIterations::kColumn>;
using AccumulatorTile = Array<
ElementC,
TileIterations::kCount * MmaIterations::kCount * kElementsPerMma>;
};
template <
typename WarpShape_
>
struct VoltaTensorOpPolicy<WarpShape_, gemm::GemmShape<32, 32, 4>, float, layout::RowMajor> {
using WarpShape = WarpShape_;
using InterleavedTileShape = gemm::GemmShape<32, 32, 4>;
using ElementC = float;
using Layout = layout::RowMajor;
using InstructionShape = gemm::GemmShape<16, 16, 4>;
using MmaIterations = MatrixShape<
InterleavedTileShape::kM / InstructionShape::kM,
InterleavedTileShape::kN / InstructionShape::kN
>;
using TileIterations = MatrixShape<
WarpShape::kM / InterleavedTileShape::kM,
WarpShape::kN / InterleavedTileShape::kN
>;
static int const kElementsPerMma = 8;
static int const kRowsPerIteration = 16;
//
// Hard-coded constants regarding Tensor Operations
//
static int const kElementsPerAccess = 2;
static int const kAccessesPerInterleavedTile = 8;
static int const kRowsPerMmaTile = 2;
static int const kIterations = TileIterations::kRow * MmaIterations::kRow;
//
// Derived types
//
using AccessType = AlignedArray<ElementC, kElementsPerAccess>;
using Fragment = Array<
ElementC,
kElementsPerAccess * kAccessesPerInterleavedTile * TileIterations::kColumn>;
using AccumulatorTile = Array<
ElementC,
TileIterations::kCount * MmaIterations::kCount * kElementsPerMma>;
};
} // namespace warp
} // namespace epilogue
} // namespace cutlass
cutlass::MatrixShape
Describes the size of a matrix tile.
Definition: matrix_shape.h:42
cutlass
Definition: aligned_buffer.h:35
cutlass::epilogue::warp::VoltaTensorOpPolicy< WarpShape_, gemm::GemmShape< 32, 32, 4 >, float, layout::RowMajor >::Fragment
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
cutlass::AlignedArray
Aligned array type.
Definition: array.h:511
cutlass::half_t
IEEE half-precision floating-point type.
Definition: half.h:126
gemm.h
Defines common types used for all GEMM-like operators.
matrix_shape.h
Defines a Shape template for matrix tiles.
cutlass::epilogue::warp::VoltaTensorOpPolicy< WarpShape_, gemm::GemmShape< 32, 32, 4 >, float, layout::RowMajor >::WarpShape
WarpShape_ WarpShape
Definition: volta_tensor_op_policy.h:125
cutlass::gemm::GemmShape
Shape of a matrix multiply-add operation.
Definition: include/cutlass/gemm/gemm.h:57
cutlass::layout::RowMajor
Mapping function for row-major matrices.
Definition: layout/matrix.h:50
cutlass::epilogue::warp::VoltaTensorOpPolicy< WarpShape_, gemm::GemmShape< 32, 32, 4 >, half_t, layout::RowMajor >::Fragment
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
matrix.h
Defines layout functions used by TensorRef and derived classes.
cutlass::epilogue::warp::VoltaTensorOpPolicy
Policy details related to the epilogue.
Definition: volta_tensor_op_policy.h:52
cutlass::epilogue::warp::VoltaTensorOpPolicy< WarpShape_, gemm::GemmShape< 32, 32, 4 >, float, layout::RowMajor >::AccumulatorTile
Array< ElementC, TileIterations::kCount *MmaIterations::kCount *kElementsPerMma > AccumulatorTile
This is the complete warp-level accumulator tile.
Definition: volta_tensor_op_policy.h:180
cutlass::epilogue::warp::VoltaTensorOpPolicy< WarpShape_, gemm::GemmShape< 32, 32, 4 >, half_t, layout::RowMajor >::AccumulatorTile
Array< ElementC, TileIterations::kCount *MmaIterations::kCount *kElementsPerMma > AccumulatorTile
This is the complete warp-level accumulator tile.
Definition: volta_tensor_op_policy.h:114
cutlass::epilogue::warp::VoltaTensorOpPolicy< WarpShape_, gemm::GemmShape< 32, 32, 4 >, half_t, layout::RowMajor >::WarpShape
WarpShape_ WarpShape
Definition: volta_tensor_op_policy.h:62