API Reference: hxtorch

struct hxtorch::core::CalibrationPath
#include <connection.h>

Path to a calibration.

Public Functions

inline explicit CalibrationPath(std::string value)

Public Members

std::string value
struct hxtorch::core::HWDBPath
#include <connection.h>

Path to a hardware database.

Public Functions

inline explicit HWDBPath(std::optional<std::string> path = std::nullopt, std::string version = "stable/latest")

Public Members

std::optional<std::string> path
std::string version
template<typename R, typename Trafo, typename T, size_t N, template<typename U> class PtrTraits, typename index_t>
struct hxtorch::perceptron::detail::ConvertToVector
#include <util.h>

Implementation for the at::TensorAccessor<T, N, PtrTraits, index_t> to std::vector<…<R>> (nesting-level N) conversion helper below.

Note

Other template parameaters come from at::TensorAccessor

Template Parameters
  • R – return value type

  • Trafo – transformation function

Public Types

typedef std::vector<typename unpacked_type::result_type> result_type
typedef at::TensorAccessor<T, N, PtrTraits, index_t> value_type

Public Static Functions

static inline result_type apply(value_type const &value, Trafo t)

Private Types

typedef ConvertToVector<R, Trafo, T, N - 1, PtrTraits, index_t> unpacked_type
template<typename R, typename Trafo, typename T, template<typename U> class PtrTraits, typename index_t>
struct hxtorch::perceptron::detail::ConvertToVector<R, Trafo, T, 1, PtrTraits, index_t>
#include <util.h>

Public Types

typedef std::vector<R> result_type
typedef at::TensorAccessor<T, 1, PtrTraits, index_t> value_type

Public Static Functions

static inline result_type apply(value_type const &value, Trafo t)
struct hxtorch::perceptron::detail::InferenceTracer
#include <inference_tracer.h>

Inference tracer implementation.

Currently only traces operation names.

Public Functions

void check_input(torch::Tensor const &value) const

Check input is equal to saved output.

Allows to ensure that between two traecd operations, the data is modified only by an identity function and thus all not-traced operations in between can be discarded.

Parameters

value – Value to check

void update_output(torch::Tensor const &value)

Update cached output value.

This is compared with the input of the next traced operation to ensure no modifications in-between.

Parameters

value – Value to update

Public Members

std::vector<std::string> operation_names
grenade::vx::compute::Sequence ops

Private Members

std::optional<torch::Tensor> m_last_output

Last output tensor to compare to next operations input tensor for sanity check.

struct hxtorch::perceptron::detail::MultidimIterator
#include <iterator.h>

Public Functions

inline MultidimIterator(std::vector<int64_t> const &range)
inline MultidimIterator end() const
inline bool operator!=(MultidimIterator const &other) const
inline std::vector<int64_t> operator*() const
inline MultidimIterator &operator++()
inline bool operator==(MultidimIterator const &other) const

Private Members

std::vector<int64_t> m_range
std::vector<int64_t> m_state
class hxtorch::perceptron::InferenceTracer
#include <inference_tracer.h>

Inference tracer for a linear sequence of operations.

The traced operations’ state is saved as a grenade::compute::Sequence, which can be executed as a single operation without transformation to and from PyTorch tensors. It is ensured, that no untraced modifications are made in-between traced operations by comparing the last traced operation’s output with the currently traced operation’s input value.

Note

Not final API or implementation, see Issue #3694

Public Functions

InferenceTracer(std::string const &filename)

Construct inference tracer with filename to store traced operations to.

void start()

Start tracing operations by registering tracer.

std::vector<std::string> stop()

Stop tracing operations by deregistering tracer and save traced operations to given file.

Returns

List of traced operation names

Private Members

std::string m_filename
std::shared_ptr<detail::InferenceTracer> m_impl
class hxtorch::perceptron::MAC : public torch::autograd::Function<MAC>
#include <mac.h>

Public Static Functions

static torch::autograd::variable_list backward(torch::autograd::AutogradContext *ctx, torch::autograd::variable_list grad_output)
static torch::autograd::variable_list forward(torch::autograd::AutogradContext *ctx, torch::autograd::Variable x, torch::autograd::Variable weights, int64_t num_sends, int64_t wait_between_events, bool mock, int64_t madc_recording_neuron_id, std::string madc_recording_path)
struct hxtorch::perceptron::MockParameter
#include <mock.h>

Parameter of hardware mock.

Public Functions

MockParameter() = default

Default constructor.

inline MockParameter(double noise_std, double gain)

Construct with noise standard deviation and gain.

Parameters
  • noise_std – Noise standard deviation to use

  • gain – Gain to use

Public Members

double gain = hxtorch::perceptron::constants::defaults::gain
double noise_std = hxtorch::perceptron::constants::defaults::noise_std
class hxtorch::spiking::CADCHandle : public hxtorch::spiking::DataHandle<std::vector<std::tuple<int32_t, int64_t, int64_t, int64_t>>>
#include <types.h>

Public Functions

inline int batch_size()
inline DataHandle()
template<typename U>
inline DataHandle(U &&data, int batch_size, int population_size)
inline std::vector<std::tuple<int32_t, int64_t, int64_t, int64_t>> &get_data()
inline int population_size()
inline void set_data(U &&data, int batch_size, int population_size)
torch::Tensor to_dense(float runtime, float dt, std::string mode = "linear")
std::tuple<torch::Tensor, float> to_dense(float runtime, std::string mode = "linear")
std::tuple<torch::Tensor, torch::Tensor> to_raw()
template<typename T>
class hxtorch::spiking::DataHandle
#include <types.h>

Public Functions

inline DataHandle()
template<typename U>
inline DataHandle(U &&data, int batch_size, int population_size)
inline int batch_size()
inline T &get_data()
inline int population_size()
template<typename U>
inline void set_data(U &&data, int batch_size, int population_size)

Private Members

int m_batch_size
T m_data
int m_population_size
class hxtorch::spiking::MADCHandle : public hxtorch::spiking::DataHandle<std::vector<std::tuple<int16_t, int64_t, int64_t, int64_t>>>
#include <types.h>

Public Functions

inline int batch_size()
inline DataHandle()
template<typename U>
inline DataHandle(U &&data, int batch_size, int population_size)
inline std::vector<std::tuple<int16_t, int64_t, int64_t, int64_t>> &get_data()
inline int population_size()
inline void set_data(U &&data, int batch_size, int population_size)
torch::Tensor to_raw()
class hxtorch::spiking::SpikeHandle : public hxtorch::spiking::DataHandle<std::vector<std::tuple<int64_t, int64_t, int64_t>>>
#include <types.h>

Public Functions

inline int batch_size()
inline DataHandle()
template<typename U>
inline DataHandle(U &&data, int batch_size, int population_size)
inline std::vector<std::tuple<int64_t, int64_t, int64_t>> &get_data()
inline int population_size()
inline void set_data(U &&data, int batch_size, int population_size)
torch::Tensor to_dense(float runtime, float dt)
namespace grenade
namespace vx
namespace execution
namespace signal_flow
namespace hxtorch
namespace hxtorch::core

Functions

std::vector< std::vector< std::vector< float > > > dense_spikes_to_list (std::tuple< pybind11::array_t< int >, pybind11::array_t< float > > spikes, int input_size) SYMBOL_VISIBLE

Convert dense spike representation to grenade spike representation.

{ idx: [batch_idx, spike_idx], time: [batch_idx, spike_idx] } -> [batch, neuron_idx, spike_time]

Parameters
  • spikes – A tuple holding an array of neuron indices and an array of corresponding spike times

  • input_spikes – The size of the input population

Returns

Returns a vector of spike times of shape [batch, neuron_idx, spike_time]

std::map< grenade::vx::network::PopulationOnNetwork, std::tuple< pybind11::array_t< int >, pybind11::array_t< float > > > extract_n_spikes (grenade::vx::signal_flow::OutputData const &data, grenade::vx::network::NetworkGraph const &network_graph, int runtime, std::map< grenade::vx::network::PopulationOnNetwork, int > n_spikes) SYMBOL_VISIBLE

Convert recorded spikes in OutputData to population-specific tuples of NumPy arrays holding N spikes for each population in each batch entry.

If less spikes are encountered their entry will be np.inf

Parameters
  • data – The OutputData returned by grenade holding all recorded data.

  • network_graph – The logical grenade graph representation of the network.

  • n_spikes – The maximal numer of spikes per population.

  • runtime – The runtime of the experiment given in FPGA clock cycles.

Returns

Returns a tuple of indices and times, each as numpy array, where the first one holds the neuron index and the second one the spike time corresponding to the index

std::string get_unique_identifier(std::optional<HWDBPath> const &hwdb_path = std::nullopt)

Get unique identifier.

Parameters

hwdb_path – Optional path to the hwdb to use

void init_hardware(CalibrationPath const &calibration_path)

Initialize the hardware with calibration path.

Parameters

calibration_path – Calibration path to load from

void init_hardware(std::optional<HWDBPath> const &hwdb_path = std::nullopt, bool ann = false)

Initialize the hardware automatically from the environment.

Parameters
  • hwdb_path – Optional path to the hwdb to use. Only effective if param ann is true.

  • ann – Bool indicating whether additionally a default chip object is constructed for ANNs from a calibration loaded from hwdb_path, or if not given, from the latest nightly calibration.

void init_hardware_minimal()

Initialize automatically from the environment without ExperimentInit and without any calibration.

void release_hardware()

Release hardware resource.

grenade::vx::network::Projection::Connections weight_to_connection (pybind11::array_t< int > weight) SYMBOL_VISIBLE

Turns a weight matrix given as a rectangular NumPy array of type int into grenade connections.

Each entry in the weight matrix is translated to a single connection. The entries are expected to be positive integers.

Parameters

weight – NumPy tensor holding the weights as positive integers.

Returns

All grenade connections given as a vector of connections.

grenade::vx::network::Projection::Connections weight_to_connection (pybind11::array_t< int > weight, std::vector< std::vector< int > > connections) SYMBOL_VISIBLE

Turns a 1-D weight NumPay array together with a list of (pre, post) neuron connections into a list of grenade connections.

Each entry in the weight weight list corresponds to the weight of the connection int the connection list at the same index.

Parameters
  • weight – 1-D NumPy array holding the weights.

  • connections – Vector holding active connections

Returns

All grenade connections given as a vector of connections.

namespace hxtorch::core::detail

Functions

lola::vx::v3::Chip &getChip()

Get singleton chip configuration.

Returns

Reference to chip configuration

std::unique_ptr<grenade::vx::execution::JITGraphExecutor> &getExecutor()

Get singleton executor.

Returns

Reference to executor

namespace hxtorch::perceptron

Functions

torch::Tensor add(torch::Tensor const &input, torch::Tensor const &other, double alpha = 1., bool mock = false)

Elementwise addition operating on int8 value range.

Parameters
  • input – Input tensor

  • other – Other tensor, which must be broadcastable to input tensor dimension

  • alpha – The scalar multiplier for other

  • mock – Enable mock mode

torch::Tensor argmax(torch::Tensor const &input, c10::optional<int64_t> dim = c10::nullopt, bool keepdim = false, bool mock = false)

Arg max operation on int8 value range.

Parameters
  • input – The input tensor

  • dim – The dimension to reduce. If unspecified, the argmax of the flattened input is returned.

  • keepdim – Whether the output tensor has dim retained or not. Ignored if dim is unspecified.

  • mock – Enable mock mode

Returns

The indices of the maximum values of a tensor across a dimension

torch::Tensor conv1d(torch::Tensor const &input, torch::Tensor const &weight, c10::optional<torch::Tensor> const &bias, int64_t stride = 1, int64_t num_sends = 1, int64_t wait_between_events = constants::defaults::wait_between_events, bool mock = false)
torch::Tensor conv1d(torch::Tensor const &input, torch::Tensor const &weight, c10::optional<torch::Tensor> const &bias, std::array<int64_t, 1> stride, int64_t num_sends = 1, int64_t wait_between_events = constants::defaults::wait_between_events, bool mock = false)
torch::Tensor conv2d(torch::Tensor const &input, torch::Tensor const &weight, c10::optional<torch::Tensor> const &bias, int64_t stride = 1, int64_t num_sends = 1, int64_t wait_between_events = constants::defaults::wait_between_events, bool mock = false)
torch::Tensor conv2d(torch::Tensor const &input, torch::Tensor const &weight, c10::optional<torch::Tensor> const &bias, std::array<int64_t, 2> stride, int64_t num_sends = 1, int64_t wait_between_events = constants::defaults::wait_between_events, bool mock = false)
template<typename R, typename T, size_t N, template<typename U> class PtrTraits, typename index_t, typename Trafo = decltype(detail::default_transform<R, T>)>
detail::ConvertToVector<R, Trafo, T, N, PtrTraits, index_t>::result_type convert_to_vector(at::TensorAccessor<T, N, PtrTraits, index_t> const &tensor, Trafo func = detail::default_transform)

Conversion helper for converting at::TensorAccessor<T, N, PtrTraits, index_t> to std::vector<…<R>> (nesting-level N) types.

Note

The underlying value_type T is converted to R. All other template parameters come from at::TensorAccessor

Template Parameters
  • R – value_type to be returned

  • Trafo – Conversion type (defaults to R)

Parameters
  • tensor – The tensor accessor to be converted to a nested vector

  • func – The conversion function for the value_type inside (defaults to R())

Returns

A nested std::vector<std::vector<…<R>>> (N nested vectors).

torch::Tensor converting_relu(torch::Tensor const &input, int64_t shift = 2, bool mock = false)

Rectified linear unit operating on int8 value range converting to uint5 value range.

The result is bit-shifted by shift after applying the ReLU and clipped to the input range of BrainScaleS-2.

Parameters
  • input – Input tensor

  • shift – Amount of bits to shift before clipping

  • mock – Enable mock mode

torch::Tensor expanded_conv1d(torch::Tensor const &input, torch::Tensor const &weight, c10::optional<torch::Tensor> const &bias, int64_t stride = 1, int64_t num_expansions = 1, int64_t num_sends = 1, int64_t wait_between_events = constants::defaults::wait_between_events, bool mock = false)

1D convolution operation that unrolls the weight matrix for execution on hardware.

This maximizes the use of the synapses array.

Note

Fixed-pattern noise cannot be individually compensated for during training, because the same weights are used at different locations!

Parameters
  • input – Input tensor of shape (minibatch, in_channels, iW)

  • weight – Filters of shape (out_channels, in_channels / groups, kW)

  • bias – Optional bias of shape (out_channels)

  • stride – Stride of the convolving kernel

  • num_expansions – Number of enrolled kernels that will be placed side by side in a single operation

  • num_sends – How often to send the (same) input vector

  • wait_between_events – How long to wait (in FPGA cycles) between events

  • mock – Enable mock mode

torch::Tensor expanded_conv1d(torch::Tensor const &input, torch::Tensor const &weight, c10::optional<torch::Tensor> const &bias, std::array<int64_t, 1> stride, int64_t num_expansions = 1, int64_t num_sends = 1, int64_t wait_between_events = constants::defaults::wait_between_events, bool mock = false)
MockParameter get_mock_parameter()
torch::Tensor inference_trace(torch::Tensor const &input, std::string const &filename)

Execute inference of stored trace.

Parameters
  • input – Input data to use

  • filename – Filename to serialized operation trace

torch::Tensor mac(torch::Tensor const &x, torch::Tensor const &weights, int64_t num_sends = 1, int64_t wait_between_events = wait_between_events, bool mock = false, int64_t madc_recording_neuron_id = 0, std::string madc_recording_path = "")

The bare mutliply-accumulate operation of BrainScaleS-2.

A 1D input x is multiplied by the weight matrix weights. If x is two-dimensional, the weights are sent only once to the synapse array and the inputs are consecutively multiplied as a 1D vector.

Parameters
  • x – Input tensor

  • weights – The weights of the synapse array

  • num_sends – How often to send the (same) input vector

  • wait_between_events – How long to wait (in FPGA cycles) between events

  • mock – Enable mock mode

  • madc_recording_neuron_id – Neuron ID to record via MADC

  • madc_recording_path – Path to which to store MADC neuron membrane recordings in CSV format. If file exists new data is appended. By default recording is disabled.

Throws

std::runtime_error – When MADC recording is enabled but mock-mode is used.

Returns

Resulting tensor

torch::Tensor matmul(torch::Tensor const &input, torch::Tensor const &other, int64_t num_sends = 1, int64_t wait_between_events = wait_between_events, bool mock = false, int64_t madc_recording_neuron_id = 0, std::string madc_recording_path = "")

Drop-in replacement for the torch.matmul operation that uses BrainScaleS-2.

Note

The current implementation only supports other to be 1D or 2D.

Parameters
  • input – First input tensor

  • other – Second input tensor

  • num_sends – How often to send the (same) input vector

  • wait_between_events – How long to wait (in FPGA cycles) between events

  • mock – Enable mock mode

  • madc_recording_neuron_id – Neuron ID to record via MADC

  • madc_recording_path – Path to which to store MADC neuron membrane recordings in CSV format. If file exists new data is appended. By default recording is disabled.

Throws

std::runtime_error – When MADC recording is enabled but mock-mode is used.

Returns

Resulting tensor

MockParameter measure_mock_parameter()
torch::Tensor relu(torch::Tensor const &input, bool mock = false)

Rectified linear unit operating on int8 value range.

Parameters
  • input – Input tensor

  • mock – Enable mock mode

void set_mock_parameter(MockParameter const &parameter)
namespace hxtorch::perceptron::constants

Variables

static constexpr intmax_t hardware_matrix_height = halco::hicann_dls::vx::v3::SynapseRowOnSynram::size / 2
static constexpr intmax_t hardware_matrix_width = halco::hicann_dls::vx::v3::SynapseOnSynapseRow::size
static constexpr intmax_t input_activation_max = grenade::vx::signal_flow::UInt5::max
static constexpr intmax_t input_activation_min = grenade::vx::signal_flow::UInt5::min
static constexpr intmax_t output_activation_max = std::numeric_limits<grenade::vx::signal_flow::Int8::value_type>::max()
static constexpr intmax_t output_activation_min = std::numeric_limits<grenade::vx::signal_flow::Int8::value_type>::min()
static constexpr intmax_t synaptic_weight_max = grenade::vx::compute::MAC::Weight::max
static constexpr intmax_t synaptic_weight_min = grenade::vx::compute::MAC::Weight::min
namespace hxtorch::perceptron::constants::defaults

Variables

static constexpr double gain = 0.002
static constexpr double noise_std = 2.
static constexpr intmax_t wait_between_events = 5
namespace hxtorch::perceptron::detail

Functions

torch::autograd::variable_list add_backward(torch::Tensor const &grad_output, torch::Tensor const &input, torch::Tensor const &other)
torch::Tensor add_forward(torch::Tensor const &input, torch::Tensor const &other)
torch::Tensor add_mock_forward(torch::Tensor const &input, torch::Tensor const &other)
torch::Tensor argmax(torch::Tensor const &input, c10::optional<int64_t> dim = c10::nullopt, bool keepdim = false)
torch::Tensor argmax_mock(torch::Tensor const &input, c10::optional<int64_t> dim = c10::nullopt, bool keepdim = false)
torch::Tensor conv(torch::Tensor const &input, torch::Tensor const &weights, c10::optional<torch::Tensor> const &bias, std::vector<int64_t> const &stride, std::vector<int64_t> const &dilation, int64_t num_sends, int64_t wait_between_events, bool mock)
int64_t conv1d_output_size(int64_t input_size, int64_t kernel_size, int64_t stride = 1, int64_t dilation = 1)

Returns the output size of a convolution with given input size, kernel size, stride and dilation.

std::vector<int64_t> conv_output_size(std::vector<int64_t> input_size, std::vector<int64_t> kernel_size, std::vector<int64_t> stride, std::vector<int64_t> dilation)

Returns the output size of a convolution with given input size, kernel size, stride and dilation.

grenade::vx::signal_flow::UInt5 convert_activation(float value)
float convert_membrane(int8_t value)
grenade::vx::compute::MAC::Weight convert_weight(float value)
torch::autograd::variable_list converting_relu_backward(torch::Tensor const &grad_output, torch::Tensor const &input, int64_t shift)
torch::Tensor converting_relu_forward(torch::Tensor const &input, int64_t shift)
torch::Tensor converting_relu_mock_forward(torch::Tensor const &input, int64_t shift)
template<typename R, typename T>
R default_transform(T const &t)

Default transformation function from T to R.

torch::Tensor expanded_conv1d(torch::Tensor const &input, torch::Tensor const &weights, c10::optional<torch::Tensor> const &bias, int64_t stride, int64_t dilation, int64_t num_expansions, int64_t num_sends, int64_t wait_between_events, bool mock)
std::unordered_set<std::shared_ptr<InferenceTracer>> &getInferenceTracer()

Get singleton set of registered inference tracers.

MockParameter &getMockParameter()
bool has_tracer()

Check whether inference tracers are registered.

Returns

Boolean value

torch::autograd::variable_list mac_backward(torch::Tensor grad_output, torch::Tensor x, torch::Tensor weights)
torch::Tensor mac_forward(torch::Tensor x, torch::Tensor weights, int64_t num_sends, int64_t wait_between_events, int64_t madc_recording_neuron_id, std::string madc_recording_path)

Calculate forward-pass of multiply accumulate operation.

Input dimensions supported are 1D or 2D, where in the latter the input plane is the highest dimension and the first dimension describes which input vector to choose. The multiply accumulate therefore multiplies the last input dimension with the first weights dimension like y = x^T W.

Parameters
  • x – Input (1D or 2D)

  • weights – 2D weight matrix

  • num_sends – How often to send the (same) input vector

  • wait_between_events – Wait time between two successive vector inputs, in FPGA clock cycles. Shorter wait time can lead to saturation of the synaptic input.

  • madc_recording_neuron_id – Neuron ID to record via MADC

  • madc_recording_path – Path to which to store MADC neuron membrane recordings. If file exists new data is appended. By default recording is disabled.

Returns

Resulting tensor

torch::Tensor mac_mock_forward(torch::Tensor const &x, torch::Tensor const &weights, int64_t num_sends)

Mocks the forward-pass of the multiply accumulate operation.

Input dimensions supported are 1D or 2D, where in the latter the input plane is the highest dimension and the first dimension describes which input vector to choose. The multiply accumulate therefore multiplies the last input dimension with the first weights dimension like y = x^T W.

Parameters
  • x – Input (1D or 2D)

  • weights – 2D weight matrix

  • num_sends – How often to send the (same) input vector

Returns

Resulting tensor

template<typename T>
auto multi_narrow(T &t, std::vector<int64_t> dim, std::vector<int64_t> start, std::vector<int64_t> length)
torch::autograd::variable_list relu_backward(torch::Tensor const &grad_output, torch::Tensor const &input)
torch::Tensor relu_forward(torch::Tensor const &input)
torch::Tensor relu_mock_forward(torch::Tensor const &input)
void tracer_add(std::string const &name, grenade::vx::compute::Sequence::Entry &&op)

Add operation to trace.

Parameters
  • name – Name to use

  • op – Operation to add

void tracer_check_input(torch::Tensor const &value)

Check all tracers for equality of the output of the last traced operation with the given value.

Throws

std::runtime_error – On this operations input being unequal to last operations output

Parameters

value – Value to check

void tracer_update_output(torch::Tensor const &value)

Update all tracers’ output of the last traced operation with the given value.

Parameters

value – Value to update

namespace hxtorch::spiking

Functions

std::map<grenade::vx::network::PopulationOnNetwork, CADCHandle> extract_cadc(grenade::vx::signal_flow::OutputData const &data, grenade::vx::network::NetworkGraph const &network_graph)

Convert recorded CADC samples in OutputData to population-specific CADCHandles holding the samples in a sparse tensor representation.

Parameters
  • data – The OutputData returned by grenade holding all recorded data.

  • network_graph – The logical grenade graph representation of the network.

Returns

Returns a mapping between population descriptors and CADC handles.

std::map<grenade::vx::network::PopulationOnNetwork, MADCHandle> extract_madc(grenade::vx::signal_flow::OutputData const &data, grenade::vx::network::NetworkGraph const &network_graph)

Convert recorded MADC samples in OutputData to population-specific MADCHandles holding the samples in a sparse tensor representation.

Parameters
  • data – The OutputData returned by grenade holding all recorded data.

  • network_graph – The logical grenade graph representation of the network.

Returns

Returns a mapping between population descriptors and MADC handles.

std::map<grenade::vx::network::PopulationOnNetwork, SpikeHandle> extract_spikes(grenade::vx::signal_flow::OutputData const &data, grenade::vx::network::NetworkGraph const &network_graph)

Convert recorded spikes in OutputData to population-specific SpikeHandles holding the spikes in a sparse tensor representation.

Parameters
  • data – The OutputData returned by grenade holding all recorded data.

  • network_graph – The logical grenade graph representation of the network.

Returns

Returns a mapping between population descriptors and spike handles.

grenade::vx::signal_flow::OutputData run(grenade::vx::execution::JITGraphExecutor::ChipConfigs const &config, grenade::vx::network::NetworkGraph const &network_graph, grenade::vx::signal_flow::InputData const &inputs, grenade::vx::execution::JITGraphExecutor::Hooks &hooks)

Strips connection from grenade::vx::network::run for python exposure.

std::vector<std::vector<std::vector<float>>> tensor_to_spike_times(torch::Tensor times, float dt)

Convert a torch tensor of spikes with a dense (but discrete) time representation into spike times.

Parameters
  • times – A tensor of shape (batch_size, time_length, population_size) holding spike represemted as ones. Absent spikes are represented by zeros.

  • dt – The temporal resolution of the spike tensor.

Returns

A vector with the first dimension being the batch dimension and the second dimension the neuron index, holding a list of spike times of the corresonding neuron, i.e. shape (batch, neuron index, spike times).

namespace hxtorch::spiking::detail

Functions

torch::Tensor sparse_cadc_to_dense_linear(std::vector<std::tuple<int32_t, int64_t, int64_t, int64_t>> const &data, int batch_size, int population_size, float runtime, float dt)
torch::Tensor sparse_cadc_to_dense_nn(std::vector<std::tuple<int32_t, int64_t, int64_t, int64_t>> const &data, int batch_size, int population_size, float runtime, float dt)
std::tuple<torch::Tensor, torch::Tensor> sparse_cadc_to_dense_raw(std::vector<std::tuple<int32_t, int64_t, int64_t, int64_t>> const &data, int batch_size, int population_size)
torch::Tensor sparse_madc_to_dense_raw(std::vector<std::tuple<int16_t, int64_t, int64_t, int64_t>> const &data, int batch_size)
torch::Tensor sparse_spike_to_dense(std::vector<std::tuple<int64_t, int64_t, int64_t>> const &data, int batch_size, int population_size, float runtime, float dt)
namespace lola
namespace vx
namespace v3
namespace std

STL namespace.

namespace torch
namespace autograd
file dense_spikes_to_list.h
#include “”
#include <>
#include <>
#include <>
file connection.h
#include <>
#include <>
file connection.h
#include <>
file extract_data.h
#include “”
#include “”
#include <>
#include <>
#include <>
file weight_to_connection.h
#include “”
#include <>
file constants.h
#include “”
#include “”
#include “”
#include <>
file conv.h
#include <>
#include <>
file conv.h
#include <>
#include <>
file add.h
#include <>
file add.h
#include <>
file argmax.h
#include <>
file argmax.h
#include <>
file conv1d.h
#include <>
file conversion.h
#include “”
#include “”
file iterator.h
#include <>
#include <>
file mac.h
#include <>
file mac.h
#include <>
#include <>
file narrow.h
#include <>
#include <>
file relu.h
#include <>
file relu.h
#include <>
file util.h
#include <>
#include <>
#include <>
file docstrings.h

Variables

static const char * __doc_hxtorch_CalibrationPath   = R"doc(Path to a calibration.)doc"
static const char * __doc_hxtorch_CalibrationPath_CalibrationPath   = R"doc()doc"
static const char * __doc_hxtorch_get_unique_identifier  =R"doc(Return the unique identifier of the chip with the initialized connection.@param hwdb_path Optional path to the hwdb to use@return The identifier as string)doc"
static const char * __doc_hxtorch_HWDBPath   = R"doc(Path to a hardware database.)doc"
static const char * __doc_hxtorch_HWDBPath_HWDBPath   = R"doc()doc"
static const char * __doc_hxtorch_init_hardware  =R"doc(Initialize the hardware automatically from the environment.@param hwdb_path Optional path to the hwdb to use@param spiking Boolean flag indicating whether spiking or non-spiking calibration is loaded)doc"
static const char * __doc_hxtorch_init_hardware_2  =R"doc(Initialize the hardware with calibration path.@param calibration_path Calibration path to load from)doc"
static const char * __doc_hxtorch_init_hardware_minimal  =R"doc(Initialize automatically from the environmentwithout ExperimentInit and without any calibration.)doc"
static const char * __doc_hxtorch_release_hardware   = R"doc(Release hardware resource.)doc"
file docstrings.h

Variables

static const char * __doc_hxtorch_add  =R"doc(Elementwise addition operating on int8 value range.@param input Input tensor@param other Other tensor, which must be broadcastable to input tensor dimension@param alpha The scalar multiplier for other@param mock Enable mock mode)doc"
static const char * __doc_hxtorch_argmax  =R"doc(Arg max operation on int8 value range.@param input The input tensor@param dim The dimension to reduce. If unspecified, the argmax of the flattenedinput is returned.@param keepdim Whether the output tensor has @p dim retained or not. Ignoredif @p dim is unspecified.@param mock Enable mock mode@return The indices of the maximum values of a tensor across a dimension)doc"
static const char * __doc_hxtorch_conv1d   = R"doc()doc"
static const char * __doc_hxtorch_conv1d_2   = R"doc()doc"
static const char * __doc_hxtorch_conv2d   = R"doc()doc"
static const char * __doc_hxtorch_conv2d_2   = R"doc()doc"
static const char * __doc_hxtorch_converting_relu  =R"doc(Rectified linear unit operating on int8 value range converting to uint5value range.The result is bit-shifted by @p shift after applying the ReLU and clippedto the input range of BrainScaleS-2.@param input Input tensor@param shift Amount of bits to shift before clipping@param mock Enable mock mode)doc"
static const char * __doc_hxtorch_expanded_conv1d  =R"doc(1D convolution operation that unrolls the weight matrix for executionon hardware. This maximizes the use of the synapses array.@noteFixed-pattern noise cannot be individually compensated for duringtraining, because the same weights are used at different locations!@param input Input tensor of shape (minibatch, in_channels, *iW*)@param weight Filters of shape (out_channels, in_channels / groups, *kW*)@param bias Optional bias of shape (out_channels)@param stride Stride of the convolving kernel@param num_expansions Number of enrolled kernels that will be placed sideby side in a single operation@param num_sends How often to send the (same) input vector@param wait_between_events How long to wait (in FPGA cycles) between events@param mock Enable mock mode)doc"
static const char * __doc_hxtorch_expanded_conv1d_2   = R"doc()doc"
static const char * __doc_hxtorch_get_mock_parameter  =R"doc(Returns the current mock parameters.)doc"
static const char * __doc_hxtorch_inference_trace  =R"doc(Execute inference of stored trace.@param input Input data to use@param filename Filename to serialized operation trace)doc"
static const char * __doc_hxtorch_InferenceTracer  =R"doc(Inference tracer for a linear sequence of operations.The traced operations' state is saved as a grenade::compute::Sequence,which can be executed as a single operation without transformation to andfrom PyTorch tensors.It is ensured, that no untraced modifications are made in-between tracedoperations by comparing the last traced operation's output with thecurrently traced operation's input value.@noteNot final API or implementation, see Issue #3694)doc"
static const char * __doc_hxtorch_InferenceTracer_InferenceTracer  =R"doc(Construct inference tracer with filename to store traced operations to.)doc"
static const char * __doc_hxtorch_InferenceTracer_start  =R"doc(Start tracing operations by registering tracer.)doc"
static const char * __doc_hxtorch_InferenceTracer_stop  =R"doc(Stop tracing operations by deregistering tracer and save tracedoperations to given file.@return List of traced operation names)doc"
static const char * __doc_hxtorch_mac  =R"doc(The bare mutliply-accumulate operation of BrainScaleS-2. A 1D input @p xis multiplied by the weight matrix @p weights. If @p x is two-dimensional,the weights are sent only once to the synapse array and the inputs areconsecutively multiplied as a 1D vector.@param x Input tensor@param weights The weights of the synapse array@param num_sends How often to send the (same) input vector@param wait_between_events How long to wait (in FPGA cycles) between events@param mock Enable mock mode@return Resulting tensor)doc"
static const char * __doc_hxtorch_matmul  =R"doc(Drop-in replacement for the torch.matmul operation that uses BrainScaleS-2.@noteThe current implementation only supports @p other to be 1D or 2D.@param input First input tensor@param other Second input tensor@param num_sends How often to send the (same) input vector@param wait_between_events How long to wait (in FPGA cycles) between events@param mock: Enable mock mode@return Resulting tensor)doc"
static const char * __doc_hxtorch_measure_mock_parameter  =R"doc(Measures the mock parameters, i.e. gain and noise_std, by multiplying afull weight with an artificial test input on the BSS-2 chip.For this purpose a random pattern is used, whose mean value is successivelyreduced to also work with higher gain factors.The output for the actual calibration is chosen such that it is close tothe middle of the available range.)doc"
static const char * __doc_hxtorch_MockParameter   = R"doc(Parameter of hardware mock.)doc"
static const char * __doc_hxtorch_MockParameter_MockParameter  =R"doc(Construct with noise standard deviation and gain.@param noise_std Noise standard deviation to use@param gain Gain to use)doc"
static const char * __doc_hxtorch_relu  =R"doc(Rectified linear unit operating on int8 value range.@param input Input tensor@param mock Enable mock mode)doc"
static const char * __doc_hxtorch_set_mock_parameter   = R"doc(Sets the mock parameters.)doc"
file docstrings.h
file inference_tracer.h
#include <>
#include <>
#include <>
#include <>
#include <>
#include <>
#include “”
file inference_tracer.h
#include <>
#include <>
file matmul.h
#include <>
file mock.h
file mock.h
file to_dense.h
#include <>
file extract_tensors.h
#include “”
#include “”
#include “hxtorch/spiking/types.h
#include <>
file run.h
#include “”
#include “”
#include “”
#include “”
#include “”
file tensor_to_spike_times.h
#include <>
#include <>
file types.h
#include <>
#include <>
#include <>
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch/core
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch/core/detail
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch/perceptron/detail
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch/spiking/detail
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch/perceptron
dir /jenkins/jenlib_workspaces_f9/doc_gerrit_documentation-brainscales2-dependencies.ZG9jX2dlcnJpdF9kb2N1bWVudGF0aW9uLWJyYWluc2NhbGVzMi1kZXBlbmRlbmNpZXMjMTI5NjI.x/hxtorch/include/hxtorch/spiking