SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
smaug::TensorShape Class Reference

TensorShape describes the shape of a Tensor. More...

#include <tensor.h>

Detailed Description

TensorShape describes the shape of a Tensor.

A Tensor's shape is described by three parameters: its dimensions, alignment padding, and a DataLayout.

  1. Dimensions: an N dimensional vector. The outermost dimension is at index 0, and innermost dimemnsion is at index N -1.
  2. Alignment: used to zeropad the innermost dimension to be a multiple of a hardware backend's data alignment requirements (for example, if an accelerator expects 8-wide vectors, the innermost dimension must be a multiple of 8). This can be zero if no alignment is required.
  3. DataLayout: the meaning of each dimension, e.g. "NCHW" means dimensions[0] = N, dimensions[3] = W, etc.

Definition at line 35 of file tensor.h.

Public Member Functions

 TensorShape (std::vector< int > _dims, DataLayout _layout, int _alignment=0)
 
 TensorShape (std::initializer_list< int > _dims, DataLayout _layout, int _alignment=0)
 
 TensorShape (const TensorShape &shape)
 
 TensorShape (const TensorShapeProto &shapeProto)
 
const std::vector< int > & dims () const
 
const std::vector< int > & padding () const
 Returns a vector of padding along each dimension.
 
int operator[] (int index) const
 
int & operator[] (int index)
 
int getStorageDim (int index) const
 Returns the alignment-padded size of the specified dimension.
 
bool operator== (const TensorShape &other) const
 
DataLayout getLayout () const
 
int ndims () const
 
int size () const
 
int storageSize () const
 
int getAlignment () const
 
int getPadding (int index) const
 
TensorShapeProto * asTensorShapeProto ()
 Return a TensorShapeProto that serializes this TensorShape.
 

Protected Member Functions

int getIndex (int index) const
 
void computePadding ()
 

Protected Attributes

std::vector< int > dims_
 
std::vector< int > padding_
 Padding along each dimension. More...
 
DataLayout layout
 
int alignment
 

Member Data Documentation

◆ padding_

std::vector<int> smaug::TensorShape::padding_
protected

Padding along each dimension.

Only the last element be nonzero.

Definition at line 99 of file tensor.h.


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