hxtorch.spiking.modules.HXTorchBaseModule

class hxtorch.spiking.modules.HXTorchBaseModule

Bases: hxtorch.spiking.modules.hx_module.HXTorchFunctionMixin, torch.nn.modules.module.Module

__init__()None

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Methods

__init__()

Initialize internal Module state, shared by both nn.Module and ScriptModule.

exec_forward(input, output)

Inject hardware observables into TensorHandles or execute forward in mock-mode.

forward(*input)

Forward method registering layer operation in given experiment. Input and output references will hold corresponding data as soon as ‘hxtorch.run’ in executed. :param input: Reference to TensorHandle holding data tensors as soon as required. :returns: Returns a Reference to TensorHandle holding result data associated with this layer after ‘hxtorch.run’ is executed.

post_process(hw_data, runtime)

This methods needs to be overridden for every derived module that demands hardware observables and is intended to translated hardware- affine datatypes returned by grenade into PyTorch tensors.

post_simulation_processing(output)

Attributes

exec_forward(input: Union[Tuple[types.Handle_tensor], types.Handle_tensor], output: types.Handle_tensor)None

Inject hardware observables into TensorHandles or execute forward in mock-mode.

forward(*input: Union[Tuple[types.Handle_tensor], types.Handle_tensor])types.Handle_tensor

Forward method registering layer operation in given experiment. Input and output references will hold corresponding data as soon as ‘hxtorch.run’ in executed. :param input: Reference to TensorHandle holding data tensors as soon

as required.

Returns

Returns a Reference to TensorHandle holding result data associated with this layer after ‘hxtorch.run’ is executed.

post_process(hw_data: hxtorch.spiking.observables.HXTorchObservables, runtime: int)Optional[Tuple[Optional[torch.Tensor, None], ], None]

This methods needs to be overridden for every derived module that demands hardware observables and is intended to translated hardware- affine datatypes returned by grenade into PyTorch tensors.

Parameters
  • hw_data – A HardwareObservables instance holding the hardware data assigned to this module.

  • runtime – The requested runtime of the experiment on hardware in us.

  • dt – The expected temporal resolution in hxtorch.

Returns

Hardware data represented as torch.Tensors. Note that torch.Tensors are required here to enable gradient flow.

post_simulation_processing(output)None