accelforge.frontend.mapping package#

Submodules#

accelforge.frontend.mapping.mapping module#

A module containing the visualization and types needed to run mapspace exploratioon in AccelForge.

class accelforge.frontend.mapping.mapping.Compute[source]#

Bases: MappingNode

A node that represents a compute operation. These nodes are the leaves of the LoopTree.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

component: str#

The name of the compute component performing the computation.

component_object: NoParse[Compute | None] = None#

The Compute object performing the computation.

einsum: str#

The Einsum being computed.

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Loop[source]#

Bases: MappingNode

A bounded loop over a rank variable with a given shape and/or pattern.

Do not instantiate directly; inherited by Temporal and Spatial.

__init__(*args, **kwargs)#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

property calculated_n_iterations: int#

The number of iterations performed by this loop.

compact_str()[source]#

Returns a compact string representation of this Loop.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

initial_tile_shape: EvalsTo[Symbol | Expr | int | str | None] = None#

The shape of the first tile shape. This attribute is optional. If not specified, all tiles have the same shape.

If specified, the initial tile shape may differ. For example, an initial tile shape of 3 and tile shape of 2 creates the following tiles in the iteration space: [0, 1, 2], [3, 4], [5, 6], …

Similarly to tile shape, this value should be an integer when writing a YAML input.

For those developing the mapper, this attribute can be a string. See tile_shape for details.

rank_variable: set[str] | str#

The rank variable(s) iterated over in this loop. This may be a single rank variable, or a set of rank variables if the loop is shared between multiple Einsums.

NOTE FOR DEVELOPERS: If the rank variable is a set DURING PMAPPIN GENERATION, then it means that the loop is a placeholder for multiple loops in the given Einsum. They will be split into multiple loops later. If the rank variable

property tile_pattern: TilePattern#
tile_shape: EvalsTo[Symbol | Expr | int | str] = 'symbol'#

The (common) tile shape of the iteration. For example, if the iteration space is range(6) and the tile shape is 3, then we create and iterate over two tiles [0, 1, 2] and [3, 4, 5].

This attribute specifies the common tile shape because initial_tile_shape may be specified.

For users writing YAML, the value should be an integer.

For those developing the mapper, the literal string “symbol” is often used to tell the model to create a sympy symbol to use as the tile shape. Any other string may be specified to explicitly request a variable name (later converted to a sympy variable).

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Mapping[source]#

Bases: Nested

A Mapping of a workload onto a hardware architecture.

clear_irrelevant_reservations(relevant_tensors)[source]#
clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property loops: list[Loop]#

Returns all Loop nodes in the Mapping.

remove_reservations()[source]#
render(with_reservations=True, with_tile_shape=True)[source]#
Return type:

_SVGJupyterRender

render_pydot(with_reservations=True, with_tile_shape=True)[source]#

Renders the mapping as a Pydot graph. Returns an SVG string.

Return type:

Dot

split_loop_with_multiple_rank_variables(einsum_name)[source]#
split_reservations()[source]#
split_tensor_holders_with_multiple_tensors()[source]#
to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.MappingNode[source]#

Bases: EvalableModel

Represents a Node in the Mapping, which can be a loop, a storage node, a compute node, etc.

__init__(*args, **kwargs)#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)[source]#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

accelforge.frontend.mapping.mapping.MappingNodeTypes#

The types of MappingNodes possible.

Type:

TypeAlias MappingNodeTypes

alias of Temporal | Spatial | Storage | Pipeline | Sequential | Compute | Reservation | TensorHolder

class accelforge.frontend.mapping.mapping.MappingNodeWithChildren[source]#

Bases: MappingNode

A MappingNode that also has child nodes.

clear_nodes(*nodes)[source]#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)[source]#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

nodes: EvalableList[Annotated[Annotated[Split, Tag(tag=Split)] | Annotated[Compute, Tag(tag=Compute)] | Annotated[Storage, Tag(tag=Storage)] | Annotated[Temporal, Tag(tag=Temporal)] | Annotated[Spatial, Tag(tag=Spatial)] | Annotated[Sequential, Tag(tag=Sequential)] | Annotated[Pipeline, Tag(tag=Pipeline)] | Annotated[Nested, Tag(tag=Nested)] | Annotated[Reservation, Tag(tag=Reservation)] | Annotated[Mapping, Tag(tag=Mapping)] | Annotated[Toll, Tag(tag=Toll)], Discriminator(discriminator=_get_tag, custom_error_type=None, custom_error_message=None, custom_error_context=None)]] = []#

The child nodes.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Nested[source]#

Bases: MappingNodeWithChildren

A MappingNodeWithChildren that represents a nested set of nodes. Each node is the parent of the next node.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

accelforge.frontend.mapping.mapping.NodeList#

EvalableList that can contain and discriminate between MappingNodes of different types.

Type:

TypeAlias NodeList

alias of EvalableList[Annotated[Annotated[Split, Tag(tag=Split)] | Annotated[Compute, Tag(tag=Compute)] | Annotated[Storage, Tag(tag=Storage)] | Annotated[Temporal, Tag(tag=Temporal)] | Annotated[Spatial, Tag(tag=Spatial)] | Annotated[Sequential, Tag(tag=Sequential)] | Annotated[Pipeline, Tag(tag=Pipeline)] | Annotated[Nested, Tag(tag=Nested)] | Annotated[Reservation, Tag(tag=Reservation)] | Annotated[Mapping, Tag(tag=Mapping)] | Annotated[Toll, Tag(tag=Toll)], Discriminator(discriminator=_get_tag, custom_error_type=None, custom_error_message=None, custom_error_context=None)]]

class accelforge.frontend.mapping.mapping.Pipeline[source]#

Bases: Split

A Split where each branch operates at the same time in different spatially-organized hardware.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Reservation[source]#

Bases: MappingNode

A node that reserves a hardware resource for a specific task.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

persistent: bool = False#

Whether this reservation is persistent. Persistent reservations can’t be tiled and must be kept in backing storage for the full duration of the workload’s execution.

property purpose: str#
purposes: EvalableList[str]#

The reasons for reserving the resource.

resource: str#

The resource being reserved.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Sequential[source]#

Bases: Split

A Split where branches are processed one-after-another.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Spatial[source]#

Bases: Loop

A spatial Loop.

property calculated_n_iterations: int#

The number of iterations performed by this loop.

compact_str()[source]#

Returns a compact string representation of this Loop.

Return type:

str

component: str#

The component name across which different spatial iterations occur.

component_object: NoParse[ArchNode] = None#

The component object across which different spatial iterations occur.

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

name: int | str#

The dimension over which the spatial is occuring.

property tile_pattern: TilePattern#
to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Split[source]#

Bases: MappingNodeWithChildren

A MappingNodeWithChildren that splits the tree into multiple branches, each applying to different Einsums.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.Storage[source]#

Bases: TensorHolder

A Storage TensorHolder that can hold tensors for reuse.

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property tensor: str#

If there is one tensor held in this tensor holder, returns its name. Otherwise, raises an error.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.T#

TypeVar T: Restricts the allowable types to types of MappingNodes.

alias of TypeVar(‘T’, bound=MappingNode)

class accelforge.frontend.mapping.mapping.Temporal[source]#

Bases: Loop

A Temporal Loop.

property calculated_n_iterations: int#

The number of iterations performed by this loop.

compact_str()[source]#

Returns a compact string representation of this Loop.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property tile_pattern: TilePattern#
to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.TensorHolder[source]#

Bases: MappingNode

A node that represents a hardware Component holding a set of tensors.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

component: str#

The name of the component holding the tensors.

component_object: NoParse[Component] = None#

The component object holding the tensors.

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

persistent: bool = False#

Whether this tensor holder is persistent. Persistent tensors can’t be tiled and must be kept in backing storage for the full duration of the workload’s execution.

property tensor: str#

If there is one tensor held in this tensor holder, returns its name. Otherwise, raises an error.

tensors: EvalableList[str]#

The names of the tensors being held in this node.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.mapping.TilePattern[source]#

Bases: object

TilePattern(tile_shape: accelforge.util._basetypes.EvalsTo[typing.Union[typing.Literal[‘symbol’], sympy.core.symbol.Symbol, int, str, NoneType, sympy.core.expr.Expr]] = ‘symbol’, initial_tile_shape: accelforge.util._basetypes.EvalsTo[typing.Union[typing.Literal[‘symbol’], sympy.core.symbol.Symbol, int, str, NoneType, sympy.core.expr.Expr]] = ‘symbol’, calculated_n_iterations: Union[Literal[‘symbol’], sympy.core.symbol.Symbol, int, str, NoneType, sympy.core.expr.Expr] = None)

__init__(tile_shape='symbol', initial_tile_shape='symbol', calculated_n_iterations=None)#
as_str(with_initial_tile_shape=True, with_tile_shape=True)[source]#
calculated_n_iterations: Literal['symbol'] | Symbol | int | str | None | Expr = None#

The number of iterations in the pattern. Do not set this! Used internally by the mapper.

initial_tile_shape: EvalsTo[Literal['symbol'] | Symbol | int | str | None | Expr] = 'symbol'#

The initial tile shape. This is the shape of the tile at the first iteration. Subsequent iterations may be smaller if they overlap previous iterations.

tile_shape: EvalsTo[Literal['symbol'] | Symbol | int | str | None | Expr] = 'symbol'#

The common tile shape of the pattern. This is the number of indices by which the tile moves each iteration.

update(**kwargs)[source]#

Update the TilePattern with the given keyword arguments.

Return type:

TilePattern

class accelforge.frontend.mapping.mapping.Toll[source]#

Bases: TensorHolder

A Toll TensorHolder that acts as a pass-through, where data is not reused but incurs accesses into this Toll.

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property tensor: str#

If there is one tensor held in this tensor holder, returns its name. Otherwise, raises an error.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

Module contents#

class accelforge.frontend.mapping.Compute[source]#

Bases: MappingNode

A node that represents a compute operation. These nodes are the leaves of the LoopTree.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

component: str#

The name of the compute component performing the computation.

component_object: NoParse[Compute | None] = None#

The Compute object performing the computation.

einsum: str#

The Einsum being computed.

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Loop[source]#

Bases: MappingNode

A bounded loop over a rank variable with a given shape and/or pattern.

Do not instantiate directly; inherited by Temporal and Spatial.

__init__(*args, **kwargs)#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

property calculated_n_iterations: int#

The number of iterations performed by this loop.

compact_str()[source]#

Returns a compact string representation of this Loop.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

initial_tile_shape: EvalsTo[Symbol | Expr | int | str | None] = None#

The shape of the first tile shape. This attribute is optional. If not specified, all tiles have the same shape.

If specified, the initial tile shape may differ. For example, an initial tile shape of 3 and tile shape of 2 creates the following tiles in the iteration space: [0, 1, 2], [3, 4], [5, 6], …

Similarly to tile shape, this value should be an integer when writing a YAML input.

For those developing the mapper, this attribute can be a string. See tile_shape for details.

rank_variable: set[str] | str#

The rank variable(s) iterated over in this loop. This may be a single rank variable, or a set of rank variables if the loop is shared between multiple Einsums.

NOTE FOR DEVELOPERS: If the rank variable is a set DURING PMAPPIN GENERATION, then it means that the loop is a placeholder for multiple loops in the given Einsum. They will be split into multiple loops later. If the rank variable

property tile_pattern: TilePattern#
tile_shape: EvalsTo[Symbol | Expr | int | str] = 'symbol'#

The (common) tile shape of the iteration. For example, if the iteration space is range(6) and the tile shape is 3, then we create and iterate over two tiles [0, 1, 2] and [3, 4, 5].

This attribute specifies the common tile shape because initial_tile_shape may be specified.

For users writing YAML, the value should be an integer.

For those developing the mapper, the literal string “symbol” is often used to tell the model to create a sympy symbol to use as the tile shape. Any other string may be specified to explicitly request a variable name (later converted to a sympy variable).

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Mapping[source]#

Bases: Nested

A Mapping of a workload onto a hardware architecture.

clear_irrelevant_reservations(relevant_tensors)[source]#
clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property loops: list[Loop]#

Returns all Loop nodes in the Mapping.

remove_reservations()[source]#
render(with_reservations=True, with_tile_shape=True)[source]#
Return type:

_SVGJupyterRender

render_pydot(with_reservations=True, with_tile_shape=True)[source]#

Renders the mapping as a Pydot graph. Returns an SVG string.

Return type:

Dot

split_loop_with_multiple_rank_variables(einsum_name)[source]#
split_reservations()[source]#
split_tensor_holders_with_multiple_tensors()[source]#
to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.MappingNode[source]#

Bases: EvalableModel

Represents a Node in the Mapping, which can be a loop, a storage node, a compute node, etc.

__init__(*args, **kwargs)#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)[source]#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.MappingNodeWithChildren[source]#

Bases: MappingNode

A MappingNode that also has child nodes.

clear_nodes(*nodes)[source]#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)[source]#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

nodes: EvalableList[Annotated[Annotated[Split, Tag(tag=Split)] | Annotated[Compute, Tag(tag=Compute)] | Annotated[Storage, Tag(tag=Storage)] | Annotated[Temporal, Tag(tag=Temporal)] | Annotated[Spatial, Tag(tag=Spatial)] | Annotated[Sequential, Tag(tag=Sequential)] | Annotated[Pipeline, Tag(tag=Pipeline)] | Annotated[Nested, Tag(tag=Nested)] | Annotated[Reservation, Tag(tag=Reservation)] | Annotated[Mapping, Tag(tag=Mapping)] | Annotated[Toll, Tag(tag=Toll)], Discriminator(discriminator=_get_tag, custom_error_type=None, custom_error_message=None, custom_error_context=None)]] = []#

The child nodes.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Nested[source]#

Bases: MappingNodeWithChildren

A MappingNodeWithChildren that represents a nested set of nodes. Each node is the parent of the next node.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Pipeline[source]#

Bases: Split

A Split where each branch operates at the same time in different spatially-organized hardware.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

accelforge.frontend.mapping.RankVariable#

alias of str

class accelforge.frontend.mapping.Reservation[source]#

Bases: MappingNode

A node that reserves a hardware resource for a specific task.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

persistent: bool = False#

Whether this reservation is persistent. Persistent reservations can’t be tiled and must be kept in backing storage for the full duration of the workload’s execution.

property purpose: str#
purposes: EvalableList[str]#

The reasons for reserving the resource.

resource: str#

The resource being reserved.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Sequential[source]#

Bases: Split

A Split where branches are processed one-after-another.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Spatial[source]#

Bases: Loop

A spatial Loop.

property calculated_n_iterations: int#

The number of iterations performed by this loop.

compact_str()[source]#

Returns a compact string representation of this Loop.

Return type:

str

component: str#

The component name across which different spatial iterations occur.

component_object: NoParse[ArchNode] = None#

The component object across which different spatial iterations occur.

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

initial_tile_shape: EvalsTo[sympy.Symbol | sympy.Expr | int | str | None] = None#

The shape of the first tile shape. This attribute is optional. If not specified, all tiles have the same shape.

If specified, the initial tile shape may differ. For example, an initial tile shape of 3 and tile shape of 2 creates the following tiles in the iteration space: [0, 1, 2], [3, 4], [5, 6], …

Similarly to tile shape, this value should be an integer when writing a YAML input.

For those developing the mapper, this attribute can be a string. See tile_shape for details.

name: int | str#

The dimension over which the spatial is occuring.

rank_variable: set[RankVariable] | RankVariable#

The rank variable(s) iterated over in this loop. This may be a single rank variable, or a set of rank variables if the loop is shared between multiple Einsums.

NOTE FOR DEVELOPERS: If the rank variable is a set DURING PMAPPIN GENERATION, then it means that the loop is a placeholder for multiple loops in the given Einsum. They will be split into multiple loops later. If the rank variable

property tile_pattern: TilePattern#
tile_shape: EvalsTo[sympy.Symbol | sympy.Expr | int | str] = 'symbol'#

The (common) tile shape of the iteration. For example, if the iteration space is range(6) and the tile shape is 3, then we create and iterate over two tiles [0, 1, 2] and [3, 4, 5].

This attribute specifies the common tile shape because initial_tile_shape may be specified.

For users writing YAML, the value should be an integer.

For those developing the mapper, the literal string “symbol” is often used to tell the model to create a sympy symbol to use as the tile shape. Any other string may be specified to explicitly request a variable name (later converted to a sympy variable).

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Split[source]#

Bases: MappingNodeWithChildren

A MappingNodeWithChildren that splits the tree into multiple branches, each applying to different Einsums.

clear_nodes(*nodes)#

Removes nodes that equal any of the given nodes.

Return type:

None

clear_nodes_of_type(types)#

Clears all child nodes that match the given type(s).

Return type:

None

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Storage[source]#

Bases: TensorHolder

A Storage TensorHolder that can hold tensors for reuse.

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property tensor: str#

If there is one tensor held in this tensor holder, returns its name. Otherwise, raises an error.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.Temporal[source]#

Bases: Loop

A Temporal Loop.

property calculated_n_iterations: int#

The number of iterations performed by this loop.

compact_str()[source]#

Returns a compact string representation of this Loop.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property tile_pattern: TilePattern#
to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

class accelforge.frontend.mapping.TensorHolder[source]#

Bases: MappingNode

A node that represents a hardware Component holding a set of tensors.

compact_str()[source]#

Returns a compact string representation of this node.

Return type:

str

component: str#

The name of the component holding the tensors.

component_object: NoParse[Component] = None#

The component object holding the tensors.

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

persistent: bool = False#

Whether this tensor holder is persistent. Persistent tensors can’t be tiled and must be kept in backing storage for the full duration of the workload’s execution.

property tensor: str#

If there is one tensor held in this tensor holder, returns its name. Otherwise, raises an error.

tensors: EvalableList[str]#

The names of the tensors being held in this node.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str

accelforge.frontend.mapping.TensorName#

alias of str

class accelforge.frontend.mapping.TilePattern[source]#

Bases: object

TilePattern(tile_shape: accelforge.util._basetypes.EvalsTo[typing.Union[typing.Literal[‘symbol’], sympy.core.symbol.Symbol, int, str, NoneType, sympy.core.expr.Expr]] = ‘symbol’, initial_tile_shape: accelforge.util._basetypes.EvalsTo[typing.Union[typing.Literal[‘symbol’], sympy.core.symbol.Symbol, int, str, NoneType, sympy.core.expr.Expr]] = ‘symbol’, calculated_n_iterations: Union[Literal[‘symbol’], sympy.core.symbol.Symbol, int, str, NoneType, sympy.core.expr.Expr] = None)

__init__(tile_shape='symbol', initial_tile_shape='symbol', calculated_n_iterations=None)#
as_str(with_initial_tile_shape=True, with_tile_shape=True)[source]#
calculated_n_iterations: Literal['symbol'] | Symbol | int | str | None | Expr = None#

The number of iterations in the pattern. Do not set this! Used internally by the mapper.

initial_tile_shape: EvalsTo[Literal['symbol'] | Symbol | int | str | None | Expr] = 'symbol'#

The initial tile shape. This is the shape of the tile at the first iteration. Subsequent iterations may be smaller if they overlap previous iterations.

tile_shape: EvalsTo[Literal['symbol'] | Symbol | int | str | None | Expr] = 'symbol'#

The common tile shape of the pattern. This is the number of indices by which the tile moves each iteration.

update(**kwargs)[source]#

Update the TilePattern with the given keyword arguments.

Return type:

TilePattern

class accelforge.frontend.mapping.Toll[source]#

Bases: TensorHolder

A Toll TensorHolder that acts as a pass-through, where data is not reused but incurs accesses into this Toll.

compact_str()#

Returns a compact string representation of this node.

Return type:

str

classmethod from_yaml(*files, jinja_parse_data=None, top_key=None, **kwargs)#

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 (str | list[str] | Path | list[Path]) – A list of yaml files to load.

  • jinja_parse_data (dict[str, Any] | None) – Optional[Dict[str, Any]] A dictionary of Jinja2 data to use when parsing the yaml files.

  • top_key (str | None) – Optional[str] The top key to use when parsing the yaml files.

  • kwargs – Extra keyword arguments to be passed to the Jinja2 parser.

Return type:

TypeVar(T)

Returns:

A dict containing the combined dictionaries.

get_nodes_of_type(types)#

Returns all sub-nodes, including this one, that match the given types.

Return type:

List[TypeVar(T, bound= MappingNode)]

property tensor: str#

If there is one tensor held in this tensor holder, returns its name. Otherwise, raises an error.

to_yaml(f=None)#

Dump the model to a YAML string.

Parameters:
  • f (str | None) – The file to write the YAML to. If not given, then returns as a string.

  • exclude (IncEx | None) – The fields to exclude from the YAML.

Returns:

The YAML string.

Return type:

str