ZigZag - Deep Learning Hardware Design Space Exploration
This repository presents the novel version of our tried-and-tested hardware Architecture-Mapping Design Space Exploration (DSE) Framework for Deep Learning (DL) accelerators. ZigZag bridges the gap between algorithmic DL decisions and their acceleration cost on specialized accelerators through a fast and accurate hardware cost estimation.
SpatialMapping Class Reference

Spatial unrollings defined for every operational array dimension. More...

Inheritance diagram for SpatialMapping:
Collaboration diagram for SpatialMapping:

Public Member Functions

def __init__ (self, dict[OADimension, MappingSingleOADim] data)
 
None initialize_oa_dims (self, dict[OADimension, int] oa_dim_sizes)
 Initialize the OA Dimensions's sizes in this instance. More...
 
def is_valid (self, dict[OADimension, dict[LayerDim, UnrollFactorInt]] max_unrollings, dict[LayerDim, UnrollFactor] layer_dim_sizes)
 Return True iff 1) the instance's OA Dimensions have been initialized to the size from the hardware architecture definition 2) the instance does not contain OA Dimensions that are not defined in the given list (no rogue OA Dim) 3) all OA Dimensions defined in the given list are contained within this instance 4) the instance does not contain LayerDims that are not bounded by max_unrollings (no rogue LayerDim) 5) each LayerDim unrolling does not exceed the unrolling prescribed in max_unrollings 6) the utilization at each OADimension does not exceed the size of the OADimension 7) the instance does not contain LayerDims that are not bounded by the given layer_dim_sizes 8) the total unrolling of each contained LayerDim does not exceed the LayerDim size. More...
 
def check_and_reduce (self, dict[OADimension, dict[LayerDim, UnrollFactorInt]] max_unrollings, dict[LayerDim, UnrollFactor] layer_dim_sizes)
 Verify. More...
 
UnrollFactor hw_utilization (self)
 Returns the hardware utilization, i.e. More...
 
set[LayerDimall_contained_layer_dims (self)
 Return a set containing all the LayerDims contained in the mapping at any OA Dim. More...
 
UnrollFactor get_total_unrolling_of_layer_dim (self, LayerDim layer_dim)
 Return the total unroll factor of a given Layer Dimension, over all Operational Array Dimensions. More...
 
float get_performance_indicator (self)
 Return a value that indicates how well this SpatialMapping is expected to perform when used in ZigZag, compared to other SpatialMappings. More...
 
list[tuple[LayerDim, UnrollFactor]] flatten_unrollings (self)
 Convert all unrollings (pair of LayerDim and UnrollFactor) at all OADimension to a single list of tuples. More...
 
None delete_layer_dim (self, LayerDim layer_dim)
 
set[OADimensionoa_dims (self)
 
list[MappingSingleOADimmappings (self)
 Return a list with all of the MappingSingleOADims contained in this instance. More...
 
def keys (self)
 
def items (self)
 
def values (self)
 
MappingSingleOADim __getitem__ (self, OADimension key)
 
def __setitem__ (self, OADimension key, MappingSingleOADim value)
 
"SpatialMapping" copy (self)
 
def __str__ (self)
 
bool __eq__ (self, Any other)
 Return true if the contained dimensions are the same and all MappingSingleOADims are the same. More...
 
def __hash__ (self)
 
- Public Member Functions inherited from LayerAttribute
def __init__ (self, Any data)
 
int __len__ (self)
 
Iterator[Any] __iter__ (self)
 
def __getitem__ (self, Any key)
 
bool __contains__ (self, Any key)
 
def __repr__ (self)
 
Any __jsonrepr__ (self)
 
def __eq__ (self, object other)
 

Static Public Member Functions

"SpatialMapping" empty ()
 

Public Attributes

 data
 
 oa_dim_sizes
 
- Public Attributes inherited from LayerAttribute
 data
 

Detailed Description

Spatial unrollings defined for every operational array dimension.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
dict[OADimension, MappingSingleOADim data 
)

Member Function Documentation

◆ __eq__()

bool __eq__ (   self,
Any  other 
)

Return true if the contained dimensions are the same and all MappingSingleOADims are the same.

Here is the call graph for this function:

◆ __getitem__()

MappingSingleOADim __getitem__ (   self,
OADimension  key 
)

◆ __hash__()

def __hash__ (   self)

Reimplemented from LayerAttribute.

Here is the call graph for this function:

◆ __setitem__()

def __setitem__ (   self,
OADimension  key,
MappingSingleOADim  value 
)

◆ __str__()

def __str__ (   self)

Reimplemented from LayerAttribute.

Here is the call graph for this function:

◆ all_contained_layer_dims()

set[LayerDim] all_contained_layer_dims (   self)

Return a set containing all the LayerDims contained in the mapping at any OA Dim.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_and_reduce()

def check_and_reduce (   self,
dict[OADimension, dict[LayerDim, UnrollFactorInt]]  max_unrollings,
dict[LayerDim, UnrollFactor]  layer_dim_sizes 
)

Verify.

  • that the utilization at each OADimension does not exceed the size of the OADimension
  • that each LayerDim unrolling does not exceed the unrolling prescribed in max_unrollings Reduce the unrollings otherwise.
    Parameters
    dictof LayerDimSizes. LayerDimSizes instance cannot be used due to circular import.
Here is the call graph for this function:

◆ copy()

"SpatialMapping" copy (   self)

◆ delete_layer_dim()

None delete_layer_dim (   self,
LayerDim  layer_dim 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

"SpatialMapping" empty ( )
static

◆ flatten_unrollings()

list[tuple[LayerDim, UnrollFactor]] flatten_unrollings (   self)

Convert all unrollings (pair of LayerDim and UnrollFactor) at all OADimension to a single list of tuples.

e.g. -> [('K', 4), ('C', 2), ('K', 8)]

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_performance_indicator()

float get_performance_indicator (   self)

Return a value that indicates how well this SpatialMapping is expected to perform when used in ZigZag, compared to other SpatialMappings.

The mapping with the highest value is expected to give the best results. Note: it is expected that the SpatialMapping is valid for the considered architecture and workload. The performance indicator consists of a term to represent the hardware representation and a term to indicate the diversity in LayerDims. Mappings with a higher hardware utilization should always have a higher performance indicator regardless of the diversity. Diversity is of importance because a mapping that unrolls the same LayerDim over all OA Dims will perform poorly due to the limited bandwidth of the memory that associated with that LayerDim.

TODO this is a rather naive metric and doesn't consider that multiple LayerDims may use the same memory

The rational behind this function is that it costs less computation time to estimate the performance than actually computing the CMEs for each SpatialMapping

Here is the call graph for this function:

◆ get_total_unrolling_of_layer_dim()

UnrollFactor get_total_unrolling_of_layer_dim (   self,
LayerDim  layer_dim 
)

Return the total unroll factor of a given Layer Dimension, over all Operational Array Dimensions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hw_utilization()

UnrollFactor hw_utilization (   self)

Returns the hardware utilization, i.e.

the product of all unrolled dimensions

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize_oa_dims()

None initialize_oa_dims (   self,
dict[OADimension, int]  oa_dim_sizes 
)

Initialize the OA Dimensions's sizes in this instance.

When the SpatialMapping is parsed from the workload definition, the OADimension sizes are unknown and given in the hardware architecture definition instead. To come to a valid SpatialMapping, the OADimension sizes must be updated.

Parameters
oa_dim_sizesMapping of OA Dimensions and corresponding sizes from the hardware architecture definition.

◆ is_valid()

def is_valid (   self,
dict[OADimension, dict[LayerDim, UnrollFactorInt]]  max_unrollings,
dict[LayerDim, UnrollFactor]  layer_dim_sizes 
)

Return True iff 1) the instance's OA Dimensions have been initialized to the size from the hardware architecture definition 2) the instance does not contain OA Dimensions that are not defined in the given list (no rogue OA Dim) 3) all OA Dimensions defined in the given list are contained within this instance 4) the instance does not contain LayerDims that are not bounded by max_unrollings (no rogue LayerDim) 5) each LayerDim unrolling does not exceed the unrolling prescribed in max_unrollings 6) the utilization at each OADimension does not exceed the size of the OADimension 7) the instance does not contain LayerDims that are not bounded by the given layer_dim_sizes 8) the total unrolling of each contained LayerDim does not exceed the LayerDim size.

Parameters
max_unrollingsa SpatialMapping instance that contains the maximally allowed unrolling for each Layer Dimension in each OADimension individually
dictof LayerDimSizes. LayerDimSizes instance cannot be used due to circular import.
oa_dim_sizesList of OA Dimensions from hardware architecture definition to compare to
Here is the call graph for this function:
Here is the caller graph for this function:

◆ items()

def items (   self)
Here is the caller graph for this function:

◆ keys()

def keys (   self)
Here is the caller graph for this function:

◆ mappings()

list[MappingSingleOADim] mappings (   self)

Return a list with all of the MappingSingleOADims contained in this instance.

Note: converting this to a set may cause problems since MappingSingleOADim objects with identical unrollings will be mapped on the same set element.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ oa_dims()

set[OADimension] oa_dims (   self)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ values()

def values (   self)
Here is the caller graph for this function:

Member Data Documentation

◆ data

data

◆ oa_dim_sizes

oa_dim_sizes

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