mapping#

This module contains methods to map a given network to the chip.

class Edge(s: int, t: int, cap: int, flow: int = 0, rev: Union[ForwardRef('Edge'), NoneType] = None)[source]#
class LayerConstraints(kernel_memory: int, neuron_memory: int, bias_memory: int)[source]#
find_chip_layers(layer: sinabs.backend.dynapcnn.dynapcnn_layer.DynapcnnLayer, constraints: List[sinabs.backend.dynapcnn.mapping.LayerConstraints]) List[int][source]#

Find all layers where a given layer configuration fits.

Parameters
  • layer – DynapcnnLayer

  • constraints – A list of all the layer’s constraints

Returns

A list of indices of layers where the given layer fits.

get_valid_mapping(model: DynapcnnNetwork, constraints: List[sinabs.backend.dynapcnn.mapping.LayerConstraints]) List[Tuple[int, int]][source]#

Given a model, find a valid layer ordering for its placement within the constraints provided.

Parameters
  • model – DynapcnnNetwork

  • constraints – A list of all the layer’s constraints

make_flow_graph(layer_mapping: List[List[int]], num_layers: int = 9) List[List[sinabs.backend.dynapcnn.mapping.Edge]][source]#

Make a flow graph given all possible chip layers for each DynapcnnCompatibleLayer layer. Note that the flows are not computed yet. The flow for the graph generated here needs to be populated by calling the method edmonds

Parameters
  • layer_mapping – List of a list of all layer indices. Eg. [[1,3], [4, 6, 1]] for a two layer model

  • num_layers – Number of layers on the chip

Returns

graph (List[List[Edge]])