Outputs

This section explains interpretation of the resulting output files generated by ZigZag. There are currently two predefined SaveStages, which save the results to a .json file in different ways.

Saving a CostModelEvaluation object to a .json requires knowledge of what attributes of the object are relevant/irrelevant. This is handled by the complexHandler inside the SaveStage.

The complexHandler handles the json representation that should be invoked for each object passed to it. In for example the SimpleSaveStage, the __simplejsonrepr__ method of the CostModelEvaluation object specifies how this should be converted to a json format.

SimpleSaveStage

This stage only saves the energy and latency including data on- and off-loading. It relies on the __simplejsonrepr__ method, which is defined in the CostModelEvaluation object as:

def __simplejsonrepr__(self):
    """
    Simple JSON representation used for saving this object to a simple json file.
    """
    return {
        "energy": self.energy_total,
        "latency": self.latency_total2
    }

Note that saving these two numbers in combination with the standard filename_pattern loses all information with respect to: which layer, which spatial mapping, which temporal mapping, etc. this CostModelEvaluation is concerning.

CompleteSaveStage

This stage saves all relevant attributes of the CostModelEvaluation to a json file, using the following __jsonrepr__ definition inside the CostModelEvaluation:

def __jsonrepr__(self):
    """
    JSON representation used for saving this object to a json file.
    """
    return {
        "inputs": {
            "accelerator": self.accelerator,
            "node": self.node,
            "spatial_mapping": self.spatial_mapping,
            "temporal_mapping": self.temporal_mapping,
        },
        "outputs": {
            "memory": {
                "utilization": self.mem_utili_shared,
                "word_accesses": self.memory_word_access
            },
            "energy": {
                "energy_total": self.energy_total,
                "operational_energy": self.MAC_energy,
                "memory_energy": self.mem_energy,
                "energy_breakdown_per_level": self.energy_breakdown,
                "energy_breakdown_per_level_per_operand": self.energy_breakdown_further
            },
            "latency": {
                "latency_without_onloading_without_offloading": self.latency_total0,
                "latency_with_onloading_without_offloading": self.latency_total1,
                "latency_with_onloading_with_offloading": self.latency_total2
            }
        }
    }

The self.accelerator attribute is an Accelerator object, which also includes a __jsonrepr__ method to know how this should be converted to a json format.

Creating a custom SaveStage

The main goal of working with a hierarchy of stages is to make modification easy and straightforward. If you care only about a certain aspect of the results, you can create a custom SaveStage and modify its complexHandler.

Please see Input parser stages.