SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
Static Public Member Functions | Static Protected Member Functions | List of all members
smaug::smv::conv::TilingOptimizer Class Reference

Tiling optimizer for SMV convolution kernel. More...

#include <smv_convolution_tiling.h>

Inheritance diagram for smaug::smv::conv::TilingOptimizer:
smaug::smv::TilingOptimizerBase

Detailed Description

Tiling optimizer for SMV convolution kernel.

Definition at line 19 of file smv_convolution_tiling.h.

Static Public Member Functions

static std::array< TiledTensor, 3 > doTiling (SmvConvolutionOp *op)
 
static TilingConfig computeBasicTileShapes (SmvConvolutionOp *op)
 Determine the best basic tiling shape for this convolution layer. More...
 
static TiledTensor generateRowwiseOutputTiledTensor (SmvConvolutionOp *op, const TiledTensor &inputTiledTensor, const TiledTensor &weightsTiledTensor, const TensorShape &maxOutputTileSize, Tensor *outputTensor, bool copyData=false)
 A specialized output tiling function when the output is tiled rowwise. More...
 

Static Protected Member Functions

static std::array< TilingDims, 3 > determineBestTilingDims (Tensor *inputs, Tensor *weights, Tensor *outputs, int maxTileSize)
 Determine the best tiling dimensions for running convolution on SMV. More...
 
- Static Protected Member Functions inherited from smaug::smv::TilingOptimizerBase
static TilingDims findBestTilingDims (const TensorShape &shape, int maxTileSize, const std::vector< int > &minShape)
 Find the best set of dimensions to tile a given tensor shape. More...
 
static void enum2DTensorTilingConfigs (TensorShape shape, int maxTileSize, const std::vector< int > &minShape, const std::vector< int > &strides, std::vector< TensorShape > &configs)
 Enumerates all tiling configs for a two dimensional Tensor. More...
 
static void enum4DTensorTilingConfigs (TensorShape shape, int maxTileSize, const std::vector< int > &minShape, const std::vector< int > &strides, std::vector< TensorShape > &configs)
 Enumerates all tiling configs for a four dimensional Tensor. More...
 

Member Function Documentation

◆ computeBasicTileShapes()

TilingConfig smaug::smv::conv::TilingOptimizer::computeBasicTileShapes ( SmvConvolutionOp op)
static

Determine the best basic tiling shape for this convolution layer.

The algorithm first determines the dimensions along which the inputs, weights, and outputs will be tiled. Then based on those dimensions, we enumerate all possible basic tile shapes for inputs, weights, and outputs. A basic shape is the shape that all but potentially the last tile along a set of dimensions will use. This triplet of tile shapes defines a TilingConfig. The TilingConfig that maximizes the total combined size of input, weights, and output tiles is chosen as the best.

To limit the number of possibilities, we only enumerate each dimension in certain increments. For example, input channels are only enumerated in multiples of kNumMaccsPerPE, and output channels are only enumerated in multiples in kNumPEs.

This algorithm assumes that the maximum tile size for weights, inputs, and outputs are all the same and that they will reside in separate scratchpads (no sharing).

Parameters
opThe SMV convolution operator. All tensors must have been created with createAllTensors() prior to calling this function.
Returns
The TilingConfig that describes the best tiling shapes.

Definition at line 57 of file smv_convolution_tiling.cpp.

◆ determineBestTilingDims()

std::array< TilingDims, 3 > smaug::smv::conv::TilingOptimizer::determineBestTilingDims ( Tensor inputs,
Tensor weights,
Tensor outputs,
int  maxTileSize 
)
staticprotected

Determine the best tiling dimensions for running convolution on SMV.

This function imposes some additional constraints on the tiling dimensions, in that certain combinations of input/weight/output tiling dimensions are not allowed in the interest of tiling code complexity.

Returns
A 3-element array of TilingDims enums (inputs, weights, outputs).

Definition at line 13 of file smv_convolution_tiling.cpp.

◆ generateRowwiseOutputTiledTensor()

TiledTensor smaug::smv::conv::TilingOptimizer::generateRowwiseOutputTiledTensor ( SmvConvolutionOp op,
const TiledTensor inputTiledTensor,
const TiledTensor weightsTiledTensor,
const TensorShape maxOutputTileSize,
Tensor outputTensor,
bool  copyData = false 
)
static

A specialized output tiling function when the output is tiled rowwise.

This accounts for additional corner cases in filter field size and zero-padding that arise with specific inputs/weights tile sizes.

Definition at line 249 of file smv_convolution_tiling.cpp.


The documentation for this class was generated from the following files: