hxtorch.spiking.utils.from_nir

Translate a NIRGraph to an hxtorch SNN.

Classes

AELIF(size, experiment, leak, reset, …)

Layer of neurons with configurable dynamics up to adaptive exponential leaky integrate-and-fire complexity.

ConversionConfig(dt, calib_path, …)

Configuration for the conversion of NIRGraph to hxtorch SNN.

Experiment(mock, dt[, hw_routing_func])

Experiment class for describing experiments on hardware

InputNeuron(size, experiment, …)

Spike source generating spikes at the times [ms] given in the spike_times array.

LI(size, experiment, leak, tau_mem, tau_syn, …)

Layer of leaky integrator neurons

LIF(size, experiment, leak, reset, …)

Layer of leaky integrate-and-fire neurons.

LIFObservables

alias of types.Handle_current_membrane_cadc_membrane_madc_spikes

MixedHXModelParameter(model_value, float, …)

Synapse(in_features, out_features, …)

Synapse layer

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

Functions

hxtorch.spiking.utils.from_nir.dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)

Add dunder methods based on the fields defined in the class.

Examines PEP 526 __annotations__ to determine fields.

If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.

hxtorch.spiking.utils.from_nir.field(*, default=<dataclasses._MISSING_TYPE object>, default_factory=<dataclasses._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=<dataclasses._MISSING_TYPE object>)

Return an object to identify dataclass fields.

default is the default value of the field. default_factory is a 0-argument function called to initialize a field’s value. If init is true, the field will be a parameter to the class’s __init__() function. If repr is true, the field will be included in the object’s repr(). If hash is true, the field will be included in the object’s hash(). If compare is true, the field will be used in comparison functions. metadata, if specified, must be a mapping which is stored but not otherwise examined by dataclass. If kw_only is true, the field will become a keyword-only parameter to __init__().

It is an error to specify both default and default_factory.

hxtorch.spiking.utils.from_nir.from_nir(graph: nir.ir.graph.NIRGraph, cfg: hxtorch.spiking.utils.from_nir.ConversionConfig = None)torch.nn.modules.module.Module

Converts a NIRGraph to an hxtorch module.

Limitations

  • Only NIRGraphs with exactly one Input and one Output node

  • Only Linear, CubaLI, and CubaLIF nodes are supported

hxtorch.spiking.utils.from_nir.run(experiment: hxtorch.spiking.experiment.Experiment, runtime: Optional[int, None])Optional[hxtorch.spiking.execution_info.ExecutionInfo, None]

Execute the given experiment.

TODO: Why is this a standalone function?

Parameters
  • experiment – The experiment representing the computational graph to be executed on hardware and/or in software.

  • runtime – Only relevant for hardware experiments. Indicates the runtime resolved with experiment.dt.