d0396f33203d0facb46b91e7f8232b245388be36,spynnaker/pyNN/models/neuron/synaptic_manager.py,SynapticManager,_write_synaptic_matrix_and_master_population_table,#SynapticManager#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#,559

Before Change


        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)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: SpiNNakerManchester/sPyNNaker
Commit Name: d0396f33203d0facb46b91e7f8232b245388be36
Time: 2019-07-09
Author: Andrew.Rowley@manchester.ac.uk
File Name: spynnaker/pyNN/models/neuron/synaptic_manager.py
Class Name: SynapticManager
Method Name: _write_synaptic_matrix_and_master_population_table


Project Name: pantsbuild/pants
Commit Name: bf9599809214cbc3082eb7f39c0ad3155822a2c5
Time: 2014-02-12
Author: benjy@foursquare.com
File Name: src/python/twitter/pants/tasks/jvm_compile/scala/zinc_analysis.py
Class Name: ZincAnalysis
Method Name: split


Project Name: allenai/allennlp
Commit Name: 686ba64038a8f552708f9c7bc6ec62453bb20ed6
Time: 2017-09-05
Author: mattg@allenai.org
File Name: allennlp/data/dataset.py
Class Name: Dataset
Method Name: as_array_dict