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.
|
Spatial unrollings defined for every operational array dimension. More...
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[LayerDim] | all_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[OADimension] | oa_dims (self) |
list[MappingSingleOADim] | mappings (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) |
![]() | |
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 | |
![]() | |
data | |
Spatial unrollings defined for every operational array dimension.
def __init__ | ( | self, | |
dict[OADimension, MappingSingleOADim] | data | ||
) |
bool __eq__ | ( | self, | |
Any | other | ||
) |
Return true if the contained dimensions are the same and all MappingSingleOADims are the same.
MappingSingleOADim __getitem__ | ( | self, | |
OADimension | key | ||
) |
def __hash__ | ( | self | ) |
def __setitem__ | ( | self, | |
OADimension | key, | ||
MappingSingleOADim | value | ||
) |
def __str__ | ( | self | ) |
set[LayerDim] all_contained_layer_dims | ( | self | ) |
Return a set containing all the LayerDims contained in the mapping at any OA Dim.
def check_and_reduce | ( | self, | |
dict[OADimension, dict[LayerDim, UnrollFactorInt]] | max_unrollings, | ||
dict[LayerDim, UnrollFactor] | layer_dim_sizes | ||
) |
Verify.
dict | of LayerDimSizes . LayerDimSizes instance cannot be used due to circular import. |
"SpatialMapping" copy | ( | self | ) |
None delete_layer_dim | ( | self, | |
LayerDim | layer_dim | ||
) |
|
static |
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)]
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.
The rational behind this function is that it costs less computation time to estimate the performance than actually computing the CMEs for each SpatialMapping
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.
UnrollFactor hw_utilization | ( | self | ) |
Returns the hardware utilization
, i.e.
the product of all unrolled dimensions
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.
oa_dim_sizes | Mapping of OA Dimensions and corresponding sizes from the hardware architecture definition. |
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.
max_unrollings | a SpatialMapping instance that contains the maximally allowed unrolling for each Layer Dimension in each OADimension individually |
dict | of LayerDimSizes . LayerDimSizes instance cannot be used due to circular import. |
oa_dim_sizes | List of OA Dimensions from hardware architecture definition to compare to |
def items | ( | self | ) |
def keys | ( | self | ) |
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.
set[OADimension] oa_dims | ( | self | ) |
def values | ( | self | ) |
data |
oa_dim_sizes |