hxtorch.spiking.backend.module_manager.ModuleManager

class hxtorch.spiking.backend.module_manager.ModuleManager

Bases: hxtorch.spiking.backend.module_manager.BaseModuleManager

Object representing all nodes in a graph-like data structure

__init__()

Initialize a Modules object. This object holds a list of nodes.

Methods

__init__()

Initialize a Modules object.

add_node(module, sources, target)

Adds a new module to the manager.

add_wrapper(wrapper)

Adds a new wrapper to the manager.

changed_since_last_run()

Check if any module is marked dirty.

clear()

Override clear to also clear open sources and open targets.

done()

Create a list of elements of form (module, sources, targets), which can be looped in the correct order. :param instance: The instance to work on. :return: Returns the ordered modules in the form (module, sources, targets).

find_edges(handle)

Find all edges with data associated with handle. :param handle: The edge data to match against. :return: Returns a list of all edges in the graph which hold the same data handle.

get_id_by_module(module)

Finds the ID of the node which corresponds to module module.

get_id_by_wrapper(wrapper)

Finds the ID of the wrapper which corresponds to wrapper wrapper.

get_module_by_id(node_id)

Finds the module of the node with ID node_id and returns it.

get_node_id()

Get the ID of the next node to add.

get_wrapper_by_id(wrapper_id)

Finds the wrapper of the node with ID wrapper_id and returns it.

get_wrapper_id()

Get the ID of the next wrapper to add.

has_module(module)

Checks whether the module module is already registered within the graph.

input_data()

Finds all edge data associated to edges with a source node in _open_sources, those nodes are roots.

pre_process(instance)

Handle all preprocessing needed prior to hardware execution.

reset_changed_since_last_run()

Restes all registered modules changed_since_last_run flags.

source_populations(module)

Find the source populations of module module, i.e. modules which are of type self._population_types.

target_populations(module)

Find the target populations of module module, i.e. modules which are of type self._population_types.

add_node(module: Union[hxtorch.spiking.modules.hx_module.HXBaseExperimentModule, Any], sources: Tuple[Any], target: Any)

Adds a new module to the manager. This method adds a node to the internal graph to represent the module. It assigned edges to this node holding the data in sources, resp. target. :param module: Module to represented in to the graph. :param sources: The sources to the node representing module. :param targets: The targets of the node representing module.

add_wrapper(wrapper: Union[hxtorch.spiking.modules.hx_module_wrapper.HXModuleWrapper, Any])

Adds a new wrapper to the manager. This must be called after all modules wrapped by this wrapper are represented in the graph. internal graph to represent the module. It assigned edges to this node holding the data in sources, resp. target. :param module: Module to represented in to the graph.

changed_since_last_run()bool

Check if any module is marked dirty. :return: Returns true if at least one module has been marked dirty.

clear()

Override clear to also clear open sources and open targets. This method resets the Manager without removing implicitly created input modules such that they can be reused.

done()

Create a list of elements of form (module, sources, targets), which can be looped in the correct order. :param instance: The instance to work on. :return: Returns the ordered modules in the form (module, sources,

targets).

find_edges(handle: Any)List[int]

Find all edges with data associated with handle. :param handle: The edge data to match against. :return: Returns a list of all edges in the graph which hold the same

data handle.

get_id_by_module(module: Union[hxtorch.spiking.modules.hx_module.HXBaseExperimentModule, Any])Optional[int]

Finds the ID of the node which corresponds to module module. If no ID is found, None is returned. :param module: The module to find the node ID for. :returns: Returns the node ID or None if no ID is found.

get_id_by_wrapper(wrapper: Union[hxtorch.spiking.modules.hx_module_wrapper.HXModuleWrapper, Any])Optional[int]

Finds the ID of the wrapper which corresponds to wrapper wrapper. If no ID is found, None is returned. :param wrapper: The wrapper module to find the node ID for. :returns: Returns the node ID or None if no ID is found.

get_module_by_id(node_id: int)

Finds the module of the node with ID node_id and returns it. If multiple modules assigned to this ID are found, only the first one is returned. However, this should never be the case and if so, it is a bug. :param node_id: The ID of the node to find the module for. :returns: Returns the corresponding module.

get_node_id()int

Get the ID of the next node to add. :returns: Returns the next usable ID of a node to add.

get_wrapper_by_id(wrapper_id: int)

Finds the wrapper of the node with ID wrapper_id and returns it. If multiple wrapper assigned to this ID are found, only the first one is returned. However, this should never be the case and if so, it is a bug. :param wrapper_id: The ID of the node to find the module for. :returns: Returns the corresponding wrapper.

get_wrapper_id()int

Get the ID of the next wrapper to add. :returns: Returns the next usable ID of a wrapper to add.

has_module(module: Union[hxtorch.spiking.modules.hx_module.HXBaseExperimentModule, Any])bool

Checks whether the module module is already registered within the graph. :param module: The module to check its existence for. :return: Returns a bool indicating whether the module exists or not.

input_data()List[Any]

Finds all edge data associated to edges with a source node in _open_sources, those nodes are roots. :return: Returns a list of all input data.

pre_process(instance)

Handle all preprocessing needed prior to hardware execution. This includes input module injection as well as setting the dropout masks.

reset_changed_since_last_run()

Restes all registered modules changed_since_last_run flags.

source_populations(module: Union[hxtorch.spiking.modules.hx_module.HXBaseExperimentModule, Any])

Find the source populations of module module, i.e. modules which are of type self._population_types. :param module: The module to find the source population. :return: Returns a list of source populations of module.

target_populations(module: Union[hxtorch.spiking.modules.hx_module.HXBaseExperimentModule, Any])

Find the target populations of module module, i.e. modules which are of type self._population_types. :param module: The module to find the target populations for. :return: Returns a list of target populations of module.