lava.proc.monitor

lava.proc.monitor.models

digraph inheritance5e143b735a { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "AbstractProcessModel" [URL="../lava.magma.core.model.html#lava.magma.core.model.model.AbstractProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents a model that implements the behavior of a Process."]; "ABC" -> "AbstractProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AbstractPyProcessModel" [URL="../lava.magma.core.model.py.html#lava.magma.core.model.py.model.AbstractPyProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract interface for Python ProcessModels."]; "AbstractProcessModel" -> "AbstractPyProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "AbstractPyProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PyLoihiProcessModel" [URL="../lava.magma.core.model.py.html#lava.magma.core.model.py.model.PyLoihiProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="ProcessModel to simulate a Process on Loihi using CPU."]; "AbstractPyProcessModel" -> "PyLoihiProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PyMonitorModel" [URL="../lava/lava.proc.monitor.html#lava.proc.monitor.models.PyMonitorModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="This process model contains prototypical Ports and Vars to have"]; "PyLoihiProcessModel" -> "PyMonitorModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.proc.monitor.models.PyMonitorModel(proc_params=None)

Bases: PyLoihiProcessModel

This process model contains prototypical Ports and Vars to have one-to-one correspondes with Monitor process.

implements_process

alias of Monitor

implements_protocol

alias of LoihiProtocol

in_port_0: PyInPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyInPortVectorDense'>, d_type=<class 'int'>, precision=None)
out_read_0: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'float'>, precision=24)
post_guard()

Guard function that determines if post lrn mgmt phase will get executed or not for the current timestep.

ref_port_0: PyRefPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyRefPortVectorDense'>, d_type=<class 'int'>, precision=None)
required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
run_post_mgmt()

During this phase, RefPorts of Monitor process collects data from monitored Vars

run_spk()

During this phase, InPorts of Monitor process collects data from monitored OutPorts

var_read_0: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'float'>, precision=24)

lava.proc.monitor.process

digraph inheritanced750b23a28 { bgcolor=transparent; rankdir=TB; size=""; "AbstractProcess" [URL="../lava.magma.core.process.html#lava.magma.core.process.process.AbstractProcess",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The notion of a Process is inspired by the Communicating Sequential"]; "Monitor" [URL="../lava/lava.proc.monitor.html#lava.proc.monitor.process.Monitor",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Monitor process to probe/monitor a given variable of a target process."]; "AbstractProcess" -> "Monitor" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.proc.monitor.process.Monitor(*args, **kwargs)

Bases: AbstractProcess

Monitor process to probe/monitor a given variable of a target process.

Monitor process is initialized without any Ports and Vars. The InPorts, RefPorts and Vars are created dynamically, as the Monitor process is used to probe OutPorts and Vars of other processes. For this purpose, Monitor process has the probe() method, which as arguments takes the target Var or OutPorts and number of time steps we want to monitor given process.

Note: Monitor currently only supports to record from a singe Var or Port.

Parameters:
  • data (dict) – Dictionary that is populated by monitoring data once get_data(..) method is called, has the following structure: data __monitored_process_name __monitored_var_or_out_port_name

  • proc_params (dict) – Process parameters that will be transferred to the corresponding ProcessModel. It is populated with the names of dynamically created port and var names of Monitor process, to be carried to its ProcessModel. It is a dictionary of the following structure: “RefPorts”: names of RefPorts created to monitor target Vars “VarsData1”: names of Vars created to store data from target Vars “InPorts”: names of InPorts created to monitor target OutPorts “VarsData2”: names of Vars created to store data from target OutPorts “n_ref_ports”: number of created RefPorts, also monitored Vars “n_in_ports”: number of created InPorts, also monitored OutPorts

  • target_names (dict) – The names of the targeted Processes and Vars/OutPorts to be monitored. This is used in get_data(..) method to access the target names corresponding to data-storing Vars of Monitor process during readout phase. This dict has the follwoing sturcture: key: name of the data-storing Vars, i.e. VarsData1 and VarsData2 value: [monitored_process_name, monitored_var_or_out_port_name]

get_data()

Fetch and return the recorded data.

The recorded data is fetched, presented in a readable dict format and returned.

Returns:

data – Data dictionary collected by Monitor Process.

Return type:

dict

plot(ax, target, *args, **kwargs)

Plot the recorded data into subplots.

Can handle recordings of multiple processes and multiple variables per process. Each process will create a separate column in the subplots, each variable will be plotted in a separate row.

Parameters:
  • ax (matplotlib.Axes) – Axes to plot the data into

  • target (Var or OutPort) – The target which should be plotted

  • *args – Passed to the matplotlib.plot function to customize the plot.

  • **kwargs – Passed to the matplotlib.plot function to customize the plot.

post_init()

Run after __init__.

Creates one prototypical RefPort, InPort and two Vars. This ensures coherence and one-to-one correspondence between the Monitor Process and ProcessModel in terms og LavaPyTypes and Ports/Vars. These prototypical ports can later be updated inside the probe() method.

Note: This is separated from constructor, because once multi-variable monitoring is enabled, this method will be deprecated.

probe(target, num_steps)

Probe a Var or OutPort to record data from.

Record the target for num_step time steps, where target can be a Var or OutPort of a process.

Parameters:
  • target (Var or OutPort) – a Var or OutPort of some process to be monitored.

  • num_steps (int) – The number of steps the target Var/OutPort should be monitored.