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

A multidimensional container of Tensors. More...

#include <tensor.h>

Inheritance diagram for smaug::TiledTensor:
smaug::TensorBase

Detailed Description

A multidimensional container of Tensors.

Each of the tensors in a TiledTensor represents one tile or rectangular section of a large tensor. TileTensor can be iterated over via a TensorIndexIterator just like ordinary Tensors, except each iteration produces a Tensor instead of scalar data.

Definition at line 552 of file tensor.h.

Classes

struct  CopyTilesArgs
 
struct  Tile
 A tile is a rectangular portion of a larger Tensor. More...
 

Public Member Functions

 TiledTensor (Tensor *_origTensor=nullptr, bool _useRawTensor=false)
 
 TiledTensor (const TensorShape &shape, Tensor *_origTensor=nullptr, bool _useRawTensor=false)
 Construct a TiledTensor. More...
 
virtual bool containsData () const
 
TensorIndexIterator startIndex () const
 
const Tensoroperator[] (int index) const
 Returns a const pointer to the Tensor at the given linear index.
 
Tensor *& operator[] (int index)
 Returns a mutable reference to the Tensor at the given linear index.
 
int size () const
 
bool isDimNHTiled () const
 Returns true if this TiledTensor is tiled along the N and H logical dimensions.
 
TensorgetTileWithData (int index)
 Returns a Tensor at the specified tile position, with data copied from the original tensor.
 
void setTile (int index, const std::vector< int > &origin, Tensor *tensor, bool copyData)
 Set the specified tile to the provided Tensor, and optionally copy data into it.
 
void copyDataToAllTiles ()
 Copies data (if needed) to all the tiles from the original Tensor.
 
void untile ()
 Copies data from the TiledTensor into the original Tensor. More...
 
- Public Member Functions inherited from smaug::TensorBase
 TensorBase (const std::string &_name, const TensorShape &_shape)
 
 TensorBase (const TensorProto &tensorProto)
 
std::string getName () const
 
const TensorShapegetShape () const
 
int ndims () const
 
int dim (int index) const
 
int getTotalDim (int index) const
 
int getDataStorageFormat () const
 
DataType getDataType () const
 
int getDataTypeSize () const
 
bool isDead () const
 
void setDead (bool _dead=true)
 

Static Public Member Functions

static void * tileCopyWorker (void *_args)
 

Protected Types

enum  TileDataOperation { Scatter, Gather }
 Specifies what to do with the data in the original Tensor and tiles. More...
 

Protected Member Functions

TilegetTile (int index)
 
void copyDataToTile (Tile *tile)
 Copy data (if needed) to this tile from the original Tensor.
 
void gatherDataFromTile (Tile *tile)
 Copy data from this tile to the original Tensor.
 
void parallelCopyTileData (TileDataOperation op)
 Split the work (data filling or gathering) across multiple threads.
 

Protected Attributes

bool useRawTensor
 True if we should use copyRawTensorData() for copying data.
 
TensororigTensor
 The original Tensor that was tiled into this TiledTensor.
 
bool dataFilled
 True if all the tiles have data filled.
 
std::vector< Tiletiles
 The list of Tiles, indexed using a TensorIndexIterator.
 
- Protected Attributes inherited from smaug::TensorBase
std::string name
 Name of of the Tensor. More...
 
TensorShape shape
 Shape of the Tensor.
 
DataStorageFormat dataFormat
 Indicates the compression format of the data. More...
 
DataType dataType
 
bool dead
 If true, the tensor is dead, which means it is on an untaken control flow path. More...
 

Member Enumeration Documentation

◆ TileDataOperation

Specifies what to do with the data in the original Tensor and tiles.

Enumerator
Scatter 

Copies data from a contiguous Tensor to the tiles.

Gather 

Copies data from the tiles to a contiguous Tensor.

Definition at line 651 of file tensor.h.

Constructor & Destructor Documentation

◆ TiledTensor()

smaug::TiledTensor::TiledTensor ( const TensorShape shape,
Tensor _origTensor = nullptr,
bool  _useRawTensor = false 
)
inline

Construct a TiledTensor.

Parameters
shapeThe shape of the TiledTensor - that is, the number of tiles in each dimension. Alignment padding is ignored here.
_origTensorThe Tensor that is being tiled.
_useRawTensorIf true, data from the original Tensor is memcpy'ed into the all the tiles, instead of being copied element-wise from/to a specific region. Only useful for broadcasting data into the tiles.

Definition at line 567 of file tensor.h.

Member Function Documentation

◆ untile()

void smaug::TiledTensor::untile ( )

Copies data from the TiledTensor into the original Tensor.

We name it "untile" because what it does reverses the tiling process.

Definition at line 153 of file tensor.cpp.


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