hxtorch.spiking.experiment.Experiment
-
class
hxtorch.spiking.experiment.
Experiment
(mock: bool = False, dt: float = 1e-06, hw_routing_func=<_pygrenade_vx_network_routing.PortfolioRouter object>) Bases:
hxtorch.spiking.experiment.BaseExperiment
Experiment class for describing experiments on hardware
-
__init__
(mock: bool = False, dt: float = 1e-06, hw_routing_func=<_pygrenade_vx_network_routing.PortfolioRouter object>) → None Instantiate a new experiment, representing an experiment on hardware and/or in software.
- Parameters
mock – Indicating whether module is executed on hardware (False) or simulated in software (True).
input_loopback – Record input spikes and use them for gradient calculation. Depending on link congestion, this may or may not be beneficial for the calculated gradient’s precision.
Methods
__init__
([mock, dt, hw_routing_func])Instantiate a new experiment, representing an experiment on hardware and/or in software.
clear
()Reset the experiments’s state.
connect
(module, input_handles, output_handle)Add an module to the experiment and connect it to other experiment modules via input and output handles.
connect_wrapper
(wrapper)Add a wrapper module to the experiment and assign it to the experiments modules.
get_hw_results
(runtime)Executes the experiment in mock or on hardware using the information added to the experiment for a time given by runtime and returns a dict of hardware data represented as PyTorch data types.
register_population
(module)Register a module as population.
register_projection
(module)Register a module as projection.
Attributes
Getter for the default
ExecutionInstance
object.-
clear
() → None Reset the experiments’s state. Corresponds to creating a new Experiment instance.
-
connect
(module: torch.nn.modules.module.Module, input_handles: Tuple[hxtorch.spiking.handle.TensorHandle], output_handle: hxtorch.spiking.handle.TensorHandle) Add an module to the experiment and connect it to other experiment modules via input and output handles.
- Parameters
module – The HXModule to add to the experiment.
input_handles – The TensorHandle serving as input to the module (its obsv_state).
output_handle – The TensorHandle outputted by the module, serving as input to subsequent HXModules.
-
connect_wrapper
(wrapper: hxtorch.spiking.modules.hx_module_wrapper.HXModuleWrapper) Add a wrapper module to the experiment and assign it to the experiments modules. In the PyTorch graph the individual module functions assigned to the wrapper are then bypassed and only the wrapper’s forward_func is considered when building the PyTorch graph. This functionality is of interest if several modules have cyclic dependencies and need to be represented by one PyTorch function.
- Parameters
wrapper – The HWModuleWrapper to add to the experiment.
-
property
default_execution_instance
Getter for the default
ExecutionInstance
object. All modules that have the sameExperiment
instance assigned and do not hold an explicitExecutionInstance
are assigned to this default execution instance.- Returns
The default execution instance
-
get_hw_results
(runtime: Optional[int]) → Dict[_pygrenade_vx_network.PopulationOnNetwork, Tuple[Optional[torch.Tensor], …]] Executes the experiment in mock or on hardware using the information added to the experiment for a time given by runtime and returns a dict of hardware data represented as PyTorch data types.
- Parameters
runtime – The runtime of the experiment on hardware in ms.
- Returns
Returns the data map as dict, where the keys are the population descriptors and values are tuples of values returned by the corresponding module’s post_process method.
-
property
last_run_chip_configs
-
register_population
(module: hxtorch.spiking.modules.hx_module.HXModule) → None Register a module as population.
- Parameters
module – The module to register as population.
-
register_projection
(module: hxtorch.spiking.modules.hx_module.HXModule) → None Register a module as projection.
- Parameters
module – The module to register as projection.
-