pacman.model.graphs package

Subpackages

Module contents

class pacman.model.graphs.AbstractEdge

Bases: Generic[V]

A directed edge in a graph between two vertices.

abstract property label: str | None

The label of the edge.

abstract property post_vertex: V

The vertex at the end of the edge.

abstract property pre_vertex: V

The vertex at the start of the edge.

class pacman.model.graphs.AbstractEdgePartition(identifier: str, allowed_edge_types: Type[E] | Tuple[Type[E], ...])

Bases: Generic[E]

A collection of edges which start at a single vertex which have the same semantics and so can share a single key or block of SDRAM (depending on edge type).

Parameters:
  • identifier – The identifier of the partition

  • allowed_edge_types – The types of edges allowed

add_edge(edge: E) None[source]

Add an edge to the edge partition.

Parameters:

edge – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

property edges: Collection[E]

The edges in this edge partition.

Note

The order in which the edges are added is preserved for when they are requested later. If not, please talk to the software team.

property identifier: str

The identifier of this edge partition.

property n_edges: int

The number of edges in the edge partition.

abstract property pre_vertices: Collection[AbstractVertex]

The vertices associated with this partition.

Note

Most edge partitions will be AbstractSingleSourcePartition and therefore provide the pre_vertex method.

class pacman.model.graphs.AbstractMultiplePartition(pre_vertices: Collection[V], identifier: str, allowed_edge_types: Type[E] | Tuple[Type[E], ...])

Bases: AbstractEdgePartition[E], Generic[V, E]

An edge partition that has multiple source vertices.

Parameters:
  • pre_vertices – The vertices which send through this partition

  • identifier – The identifier of the partition

  • allowed_edge_types – The types of edges allowed

add_edge(edge: E) None[source]

Add an edge to the edge partition.

Parameters:

edge – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

property pre_vertices: Collection[V]

The vertices associated with this partition.

Note

Most edge partitions will be AbstractSingleSourcePartition and therefore provide the pre_vertex method.

class pacman.model.graphs.AbstractSingleSourcePartition(pre_vertex: V, identifier: str, allowed_edge_types: Type[E] | Tuple[Type[E], ...])

Bases: AbstractEdgePartition, Generic[V, E]

An edge partition that has a single source vertex.

Parameters:
  • pre_vertex – The vertex at the start of all the edges

  • identifier – The identifier of the partition

  • allowed_edge_types – The types of edges allowed

add_edge(edge: E) None[source]

Add an edge to the edge partition.

Parameters:

edge – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

property pre_vertex: V

The vertex at which all edges in this outgoing edge partition start.

property pre_vertices: Sequence[V]

The vertices associated with this partition.

Note

Most edge partitions will be AbstractSingleSourcePartition and therefore provide the pre_vertex method.

class pacman.model.graphs.AbstractSupportsSDRAMEdges

Bases: object

Marks a machine vertex that can have SDRAM edges attached to it.

abstractmethod sdram_requirement(sdram_machine_edge: SDRAMMachineEdge) int[source]

Asks a machine vertex for the SDRAM requirement it needs.

Parameters:

sdram_machine_edge – The SDRAM edge in question ~pacman.model.graphs.machine.SDRAMMachineEdge

Returns:

The size in bytes this vertex needs for the SDRAM edge.

class pacman.model.graphs.AbstractVertex(label: str | None = None)

Bases: object

A vertex in a graph.

Parameters:

label – The optional name of the vertex

get_fixed_location() ChipAndCore | None[source]

The x, y and possibly p the vertex must be placed on.

Typically None! Does not have the value of a normal placements.

Used instead of ChipAndCoreConstraint.

Returns:

None or the location constraint,

has_been_added_to_graph() bool[source]
Returns:

True if the vertex has been added to the graph

property label: str | None

The current label to the vertex.

This label could change when the vertex is added to the graph.

set_added_to_graph() None[source]

Records that the vertex has been added to a graph.

Raises:

PacmanConfigurationException – If there is an attempt to add the same vertex more than once

set_fixed_location(x: int, y: int, p: int | None = None) None[source]

Set the location where the vertex must be placed.

Note

If called, must be called prior to the placement algorithms.

Parameters:
  • x – X coordinate of fixed location

  • y – Y coordinate of fixed location

  • p – Processor ID of fixed location

Raises:

PacmanConfigurationException – If a fixed location has already been set to a different location.

set_label(label: str) None[source]

Changes the label for a vertex not yet added to a graph.

Parameters:

label – new value for the label

Raises:

PacmanConfigurationException – If there is an attempt to change the label once the vertex has been added to a graph

class pacman.model.graphs.AbstractVirtual

Bases: object

A vertex which exists outside of the machine, allowing a graph to formally participate in I/O.

Note

Everything that is an instance of AbstractVirtual is also an instance of AbstractVertex.

abstract property board_address: str | None

The IP address of the board to which the device is connected, or None for the boot board, or when using linked chip coordinates.

Get link data from the machine.

Parameters:

machine – The machine to get the data from

Returns:

The link of the type used by the specific vertex.

abstract property incoming: bool

Whether this device sends traffic into SpiNNaker.

abstract property linked_chip_coordinates: XY | None

The coordinates of the chip to which the device is connected, or None for the boot board, or when using a board address.

abstract property outgoing: bool

Whether this device receives traffic from SpiNNaker.

abstractmethod outgoing_keys_and_masks() List[BaseKeyAndMask] | None[source]

Get the keys sent by the device or None if there aren’t any explicitly defined.

Returns:

The keys and masks used by the vertex if any