generate_on_machine = list()
// Store synapse information by projection edge to get indices
synapse_infos = defaultdict(list)
// For each machine edge in the vertex, create a synaptic list
for machine_edge in in_edges:
app_edge = graph_mapper.get_application_edge(machine_edge)
if isinstance(app_edge, ProjectionApplicationEdge):
spec.comment("\nWriting matrix for m_edge:{}\n".format(
machine_edge.label))
pre_vertex_slice = graph_mapper.get_slice(
machine_edge.pre_vertex)
pre_slices = graph_mapper.get_slices(app_edge.pre_vertex)
pre_slice_idx = graph_mapper.get_machine_vertex_index(
machine_edge.pre_vertex)
for synapse_info in app_edge.synapse_information:
rinfo = routing_info.get_routing_info_for_edge(
machine_edge)
// If connector is being built on SpiNNaker,
// compute matrix sizes only
connector = synapse_info.connector
dynamics = synapse_info.synapse_dynamics
if (isinstance(
connector, AbstractGenerateConnectorOnMachine) and
connector.generate_on_machine(
synapse_info.weight, synapse_info.delay) and
isinstance(dynamics, AbstractGenerateOnMachine) and
dynamics.generate_on_machine and
not self.__is_direct(
single_addr, connector, pre_vertex_slice,
post_vertex_slice, app_edge)):
generate_on_machine.append((
synapse_info, pre_slices, pre_vertex_slice,
pre_slice_idx, app_edge, rinfo))
else:
block_addr, single_addr = self.__write_block(
spec, synaptic_matrix_region, synapse_info,
pre_slices, pre_slice_idx, post_slices,
post_slice_index, pre_vertex_slice,
post_vertex_slice, app_edge,
self.__n_synapse_types,
single_synapses, master_pop_table_region,
weight_scales, machine_time_step, rinfo,
all_syn_block_sz, block_addr, single_addr,
machine_edge=machine_edge)
synapse_infos[app_edge].append(synapse_info)
// Skip blocks that will be written on the machine, but add them
// to the master population table
generator_data = list()
for gen_data in generate_on_machine:
(synapse_info, pre_slices, pre_vertex_slice, pre_slice_idx,
app_edge, rinfo) = gen_data
block_addr = self.__generate_on_chip_data(
spec, synapse_info,
pre_slices, pre_slice_idx, post_slices,
post_slice_index, pre_vertex_slice,
post_vertex_slice, master_pop_table_region, rinfo,
all_syn_block_sz, block_addr, machine_time_step, app_edge,
generator_data)
synapse_infos[app_edge].append(synapse_info)
// Loop over synapse infos as collected above and assign index in order
for app_edge, infos in iteritems(synapse_infos):
for i, info in enumerate(infos):
info.index = i
self.__poptable_type.finish_master_pop_table(
spec, master_pop_table_region)
// Write the size and data of single synapses to the direct region
After Change
generate_on_machine = list()
// Store synapse information by projection edge to get indices
index = 0
// For each machine edge in the vertex, create a synaptic list
for machine_edge in in_edges:
app_edge = graph_mapper.get_application_edge(machine_edge)
if isinstance(app_edge, ProjectionApplicationEdge):
spec.comment("\nWriting matrix for m_edge:{}\n".format(
machine_edge.label))
pre_vertex_slice = graph_mapper.get_slice(
machine_edge.pre_vertex)
pre_slices = graph_mapper.get_slices(app_edge.pre_vertex)
pre_slice_idx = graph_mapper.get_machine_vertex_index(
machine_edge.pre_vertex)
for synapse_info in app_edge.synapse_information:
rinfo = routing_info.get_routing_info_for_edge(
machine_edge)
// If connector is being built on SpiNNaker,
// compute matrix sizes only
connector = synapse_info.connector
dynamics = synapse_info.synapse_dynamics
if (isinstance(
connector, AbstractGenerateConnectorOnMachine) and
connector.generate_on_machine(
synapse_info.weight, synapse_info.delay) and
isinstance(dynamics, AbstractGenerateOnMachine) and
dynamics.generate_on_machine and
not self.__is_direct(
single_addr, connector, pre_vertex_slice,
post_vertex_slice, app_edge)):
generate_on_machine.append((
synapse_info, pre_slices, pre_vertex_slice,
pre_slice_idx, app_edge, rinfo))
else:
block_addr, single_addr = self.__write_block(
spec, synaptic_matrix_region, synapse_info,
pre_slices, pre_slice_idx, post_slices,
post_slice_index, pre_vertex_slice,
post_vertex_slice, app_edge,
self.__n_synapse_types,
single_synapses, master_pop_table_region,
weight_scales, machine_time_step, rinfo,
all_syn_block_sz, block_addr, single_addr,
machine_edge=machine_edge)
key = (synapse_info, pre_vertex_slice.lo_atom,
post_vertex_slice.lo_atom)
self.__synapse_indices[key] = index
index += 1
// Skip blocks that will be written on the machine, but add them
// to the master population table
generator_data = list()
for gen_data in generate_on_machine:
(synapse_info, pre_slices, pre_vertex_slice, pre_slice_idx,
app_edge, rinfo) = gen_data
block_addr = self.__generate_on_chip_data(
spec, synapse_info,
pre_slices, pre_slice_idx, post_slices,
post_slice_index, pre_vertex_slice,
post_vertex_slice, master_pop_table_region, rinfo,
all_syn_block_sz, block_addr, machine_time_step, app_edge,
generator_data)
key = (synapse_info, pre_vertex_slice.lo_atom,
post_vertex_slice.lo_atom)
self.__synapse_indices[key] = index
self.__poptable_type.finish_master_pop_table(
spec, master_pop_table_region)