API Reference#
Subpackages#
- accelforge.frontend package
- Subpackages
- Submodules
- accelforge.frontend.arch module
ActionArchArchNodeArchNodesBranchComparisonComponentComponent.__init__()Component.actionsComponent.areaComponent.area_scaleComponent.calculate_action_energy()Component.calculate_action_latency()Component.calculate_area()Component.calculate_area_energy_latency_leak()Component.calculate_leak_power()Component.component_classComponent.component_modelComponent.component_modeling_logComponent.enabledComponent.energy_scaleComponent.extra_attributes_for_component_modelComponent.get_component_class()Component.latency_scaleComponent.leak_powerComponent.leak_power_scaleComponent.n_parallel_instancesComponent.nameComponent.populate_component_model()Component.total_areaComponent.total_latencyComponent.total_leak_power
ComputeFanoutForkHierarchicalLeafMemorySpatialTensorHolderTensorHolderActionTensorsToll
- accelforge.frontend.config module
- accelforge.frontend.model module
- accelforge.frontend.renames module
- accelforge.frontend.spec module
- accelforge.frontend.variables module
- accelforge.frontend.workload module
EinsumEinsum.__init__()Einsum.copy_source_tensor()Einsum.empty_renames()Einsum.indexing_expressionsEinsum.input_tensor_namesEinsum.is_copy_operationEinsum.iteration_space_shapeEinsum.n_instancesEinsum.nameEinsum.output_tensor_namesEinsum.rank_sizesEinsum.rank_variable2ranksEinsum.rank_variablesEinsum.ranksEinsum.renamesEinsum.tensor2directly_indexing_rank_variablesEinsum.tensor2expression_indexing_rank_variablesEinsum.tensor2irrelevant_rank_variablesEinsum.tensor2rank_variablesEinsum.tensor_accessesEinsum.tensor_names
ImpliedProjectionShapeTensorAccessTensorAccess.backing_storage_size_scaleTensorAccess.bits_per_valueTensorAccess.directly_indexing_rank_variablesTensorAccess.expression_indexing_rank_variablesTensorAccess.nameTensorAccess.outputTensorAccess.persistentTensorAccess.projectionTensorAccess.rank2rank_variablesTensorAccess.rank_variable2ranksTensorAccess.rank_variablesTensorAccess.ranks
WorkloadWorkload.accesses_for_tensor()Workload.bits_per_valueWorkload.einsum_namesWorkload.einsumsWorkload.einsums_with_tensor()Workload.einsums_with_tensor_as_input()Workload.einsums_with_tensor_as_output()Workload.empty_renames()Workload.get_iteration_space_shape_isl_string()Workload.get_tensor_copies()Workload.iteration_space_shapeWorkload.n_instancesWorkload.rank_sizesWorkload.rank_variablesWorkload.render()Workload.tensor_namesWorkload.tensor_names_used_in_multiple_einsums
isl_expression_has_variable()
- Module contents
- accelforge.mapper package
- accelforge.model package
- accelforge.plotting package
- accelforge.util package
Module contents#
- class accelforge.Arch[source]#
Bases:
HierarchicalTop-level architecture specification.
All attributes in the architecture can refrence variables in the spec-level variables field as well as symbols from the individual Einsum being processed.
- extra_attributes_for_all_component_models: EvalExtras#
Extra attributes to pass to all component models. This can be used to pass global attributes, such as technology node or clock period, to every component model.
- property per_component_total_area: dict[str, float]#
Returns the total area used by each component in the architecture in m^2.
- property per_component_total_leak_power: dict[str, float]#
Returns the total leak power of each component in the architecture in W.
- property total_area: float#
Returns the total area of the architecture in m^2.
- Returns:
The total area of the architecture in m^2.
- Return type:
- property total_leak_power: float#
Returns the total leak power of the architecture in W.
- Returns:
The total leak power of the architecture in W.
- Return type:
- variables: EvalExtras#
Like the spec-level variables field, this field is evaluated first and its contents can be referenced elsewhere in the architecture. Unlike the spec-level variables field, this, like ther rest of the architecture, is evaluated per-Einsum and can reference Einsum-specific symbols.
- class accelforge.Config[source]#
Bases:
EvalableModel- component_models: EvalableList[str | ComponentModel]#
A list of hwcomponents models to use for the energy and area calculations. These can either be paths to Python files that contain the models, or hwcomponents
ComponentModelobjects.
- expression_custom_functions: EvalableList[str | Callable]#
A list of functions to use while parsing expressions. These can either be functions or paths to Python files that contain the functions. If a path is provided, then all functions in the file will be added to the evaluator.
- classmethod from_yaml(f)[source]#
Loads a dictionary from one more more yaml files.
Each yaml file should contain a dictionary. Dictionaries are combined in the order they are given.
Keyword arguments are also added to the dictionary.
- Parameters:
files – A list of yaml files to load.
jinja_parse_data – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.
top_key – Optional[str] The top key to use when parsing the yaml files.
kwargs – Extra keyword arguments to be passed to the constructor.
- Return type:
- Returns:
A dict containing the combined dictionaries.
- exception accelforge.EvaluationError[source]#
Bases:
ExceptionException raised when parsing fails.
This exception is raised when there’s an error parsing specifications, architectures, workloads, or mappings.
- Parameters:
*args – Standard exception arguments.
source_field (Any, optional) – The field where the error occurred.
message (str, optional) – Error message describing what went wrong.
**kwargs – Additional keyword arguments.
- class accelforge.Mapping[source]#
Bases:
NestedA Mapping of a workload onto a hardware architecture.
- class accelforge.Metrics[source]#
Bases:
FlagMetrics used to optimize mappings.
- ACTIONS = 8#
Action counts.
- ENERGY = 2#
Energy. Minimize the amount of energy consumed by the workload.
- LATENCY = 1#
Latency. Minimize the amount of time taken to execute the workload.
- RESOURCE_USAGE = 4#
Resource usage. Minimize the amount of resources used by the workload. This objective is multivariate, and must consider every resource available to the hardware.
- __new__(value)#
- class accelforge.Renames[source]#
Bases:
EvalableModel- einsums: list[EinsumRename]#
Renames for a workload. The Einsum list is a list of EinsumRename objects, and renames will be applied to Einsums whose names match the EinsumRename.name. If an EinsumRename is named “default”, then its renames are applied to every Einsum unless overridden. Overriding is specific to a single name, so every rename in the default must be overridden independently.
- class accelforge.Spec[source]#
Bases:
EvalableModelThe top-level spec of all of the inputs to this package.
- calculate_component_area_energy_latency_leak(einsum_name=None, area=True, energy=True, latency=True, leak=True)[source]#
Populates per-component area, energy, latency, and/or leak power. For each component, populates the
area,total_area,leak_powerandtotal_leak_power. Additionally, for each action of each component, populates the<action>.energyand<action>.latencyfields. Extends thecomponent_modeling_logfield with log messages. Also populates thecomponent_modelattribute for each component if not already set.Some architectures’ attributes may depend on the workload. In that case, an Einsum name can be provided to populate those symbols with the Einsum’s symbols from the workload.
- Parameters:
einsum_name (EinsumName | None = None) – Optional Einsum name to populate symbols with the Einsum’s symbols from the workload. If None, and there are Einsums in the workload, the first Einsum is used. If None and there are no Einsums in the workload, then no symbols are populated from the workload.
area (bool, optional) – Whether to compute and populate area entries.
energy (bool, optional) – Whether to compute and populate energy entries.
latency (bool, optional) – Whether to compute and populate latency entries.
leak (bool, optional) – Whether to compute and populate leak power entries.
- Return type:
- map_workload_to_arch(einsum_names=None, print_number_of_pmappings=True, _pmapping_row_filter_function=None)[source]#
Maps the workload to the architecture using the AccelForge Fast and Fusiest Mapper (FFM).
- Parameters:
spec – The Spec to map.
einsum_names (
list[str] |None) – The einsum names to map. If None, all einsums will be mapped.can_combine_multiple_runs (Whether we would like to be able to combine multiple) – make_pmappings runs. Having this as True allows you to do things like pmappings = make_pmappings(*args_a) | make_pmappings(*args_b) but slows down execution.
cache_dir – The directory to cache pmappings in. If None, no caching will be done.
print_number_of_pmappings (
bool) – Whether to print the number of pmappings for each einsum._pmapping_row_filter_function (
Optional[Callable[[Series],bool]]) – A function that takes in a row of the pmapping dataframe and returns True if the row should be included in the final mappings, and False otherwise. If None, all rows will be included.
- Returns:
The mappings of the workload to the architecture.
- Return type:
- mapping: Mapping#
How the workload is programmed onto the architecture. Do not specify this if you’d like the mapper to generate a mapping for you.
- class accelforge.Variables[source]#
Bases:
EvalExtrasVariables that can be used in parsing. All variables defined here can be referenced elsewhere in any of the Spec’s evaluated expressions.
- class accelforge.Workload[source]#
Bases:
EvalableModelThe workload specification as a cascade of Einsums, with each Einsum being a computation step in the workload.
- accesses_for_tensor(tensor)[source]#
Returns all TensorAccess objects that access the given tensor across all Einsums.
- Parameters:
tensor (TensorName) – The tensor to check.
- Returns:
The TensorAccess objects that access the given tensor across all Einsums. Order is the same as the order in this workload’s Einsums list.
- Return type:
- bits_per_value: EvalableDict[str, int | str]#
Bits per value for each tensor. The workload-level bits_per_value is overridden if bits_per_action is specified for any given tensor access. This is a dictionary of set expressions to bits per value for the tensors given by those expressions. For example, we may write “Inputs: 8” to set the bits per value to 8 for all input tensors, unless overridden.
- einsums_with_tensor(tensor)[source]#
Returns the Einsums in the workload that access the given tensor.
- Parameters:
tensor (TensorName) – The tensor to check.
- Returns:
The Einsums in the workload that access the given tensor. Order is the same as the order in this workload’s Einsums list.
- Return type:
- einsums_with_tensor_as_input(tensor)[source]#
Returns the Einsums in the workload that use the given tensor as an input.
- Parameters:
tensor (TensorName) – The tensor to check.
- Returns:
The Einsums in the workload that use the given tensor as an input. Order is the same as the order in this workload’s Einsums list.
- Return type:
- einsums_with_tensor_as_output(tensor)[source]#
Returns the Einsums in the workload that have the given tensor as an output.
- Parameters:
tensor (TensorName) – The tensor to check.
- Returns:
The Einsums in the workload that have the given tensor as an output. Order is the same as the order in this workload’s Einsums list.
- Return type:
- get_iteration_space_shape_isl_string(einsum_name)[source]#
Returns the ISL string representing the iteration space of the given Einsum.
- get_tensor_copies()[source]#
Returns a dictionary specifying which tensors are copies of which other tensors. For example, if einsum A copies tensor X into tensors Y and Z, then we’d have in the return value X: {Y, Z}, Y: {X, Z}, and Z: {X, Y}. This is transitive.
- Returns:
A dictionary specifying which tensors are copies of which other tensors. The keys are the tensors that are copies, and the values are sets of tensors that are copies of the key.
- Return type:
- iteration_space_shape: EvalableDict[str, str]#
Bounds of valid rank variable values. This is a dictionary of rank variable names to bounds of valid rank variable values. The bounds are specified as a string in the ISL format. For example, “0 <= a < 10” means that the rank variable a must be between 0 and 10, including 0 but not 10. Bounds are included for all Einsums that include that rank variable.
- n_instances: int#
Number of times to repeat the workload. Multiplied by Einsum.n_instances to get the total number of Einsum instances. Energy, latency, and other summable metrics are multiplied by this value. Persistent reservations are also multiplied by this value, but non-persistent reservations are not, as they are assumed to be freed between each instance.