def get_seeds(self, app_vertex=None): if app_vertex: if app_vertex not in self.__seeds.keys(): self.__seeds[app_vertex] = (create_mars_kiss_seeds(self.__rng)) return self.__seeds[app_vertex] else: return create_mars_kiss_seeds(self.__rng)
def _get_connector_seed(self, pre_vertex_slice, post_vertex_slice, rng): """ Get the seed of the connector for a given pre-post pairing :param ~pacman.model.graphs.common.Slice pre_vertex_slice: :param ~pacman.model.graphs.common.Slice post_vertex_slice: :param ~pyNN.random.NumpyRNG rng: """ key = (id(pre_vertex_slice), id(post_vertex_slice)) if key not in self.__connector_seed: self.__connector_seed[key] = utility_calls.create_mars_kiss_seeds( rng) return self.__connector_seed[key]
def _generate_param_seed( pre_vertex_slice, post_vertex_slice, values, seeds): """ Get the seed of a parameter generator for a given pre-post pairing :param ~pacman.model.graphs.common.Slice pre_vertex_slice: :param ~pacman.model.graphs.common.Slice post_vertex_slice: :param values: :type values: int or ~pyNN.random.NumpyRNG :param dict(list(int)) seeds: :rtype: list(int) """ if not isinstance(values, RandomDistribution): return None key = (id(pre_vertex_slice), id(post_vertex_slice), id(values)) if key not in seeds: seeds[key] = utility_calls.create_mars_kiss_seeds(values.rng) return seeds[key]
def gen_connector_params( self, pre_slices, post_slices, pre_vertex_slice, post_vertex_slice, synapse_type, synapse_info): params = self._basic_connector_params(synapse_info) # The same seed needs to be sent to each of the slices key = (id(pre_vertex_slice), id(post_slices)) if key not in self.__post_connector_seed: self.__post_connector_seed[ key] = utility_calls.create_mars_kiss_seeds(self._rng) # Only deal with self-connections if the two populations are the same self_connections = True if ((not self.__allow_self_connections) and ( synapse_info.pre_population is synapse_info.post_population)): self_connections = False params.extend([ self_connections, self.__with_replacement, self.__n_post, synapse_info.n_post_neurons]) params.extend(self.__post_connector_seed[key]) return numpy.array(params, dtype="uint32")
def _write_poisson_parameters(self, spec, graph, placement, routing_info, vertex_slice, machine_time_step): """ Generate Parameter data for Poisson spike sources :param ~data_specification.DataSpecification spec: the data specification writer :param ~pacman.model.graphs.machine.MachineGraph graph: :param ~pacman.model.placements.Placement placement: :param ~pacman.model.routing_info.RoutingInfo routing_info: :param ~pacman.model.graphs.common.Slice vertex_slice: the slice of atoms a machine vertex holds from its application vertex :param int machine_time_step: the time between timer tick updates. """ # pylint: disable=too-many-arguments, too-many-locals spec.comment("\nWriting Parameters for {} poisson sources:\n".format( vertex_slice.n_atoms)) # Set the focus to the memory region 2 (neuron parameters): spec.switch_write_focus(_REGIONS.POISSON_PARAMS_REGION.value) # Write Key info for this core: key = routing_info.get_first_key_from_pre_vertex( placement.vertex, constants.SPIKE_PARTITION_ID) spec.write_value(data=1 if key is not None else 0) spec.write_value(data=key if key is not None else 0) # Write the incoming mask if there is one in_edges = graph.get_edges_ending_at_vertex_with_partition_name( placement.vertex, constants.LIVE_POISSON_CONTROL_PARTITION_ID) if len(in_edges) > 1: raise ConfigurationException( "Only one control edge can end at a Poisson vertex") incoming_mask = 0 if len(in_edges) == 1: in_edge = in_edges[0] # Get the mask of the incoming keys incoming_mask = \ routing_info.get_routing_info_for_edge(in_edge).first_mask incoming_mask = ~incoming_mask & 0xFFFFFFFF spec.write_value(incoming_mask) # Write the number of seconds per timestep (unsigned long fract) spec.write_value(data=float(machine_time_step) / MICRO_TO_SECOND_CONVERSION, data_type=DataType.U032) # Write the number of timesteps per second (integer) spec.write_value(data=int(MICRO_TO_SECOND_CONVERSION / float(machine_time_step))) # Write the slow-rate-per-tick-cutoff (accum) spec.write_value(data=SLOW_RATE_PER_TICK_CUTOFF, data_type=DataType.S1615) # Write the fast-rate-per-tick-cutoff (accum) spec.write_value(data=FAST_RATE_PER_TICK_CUTOFF, data_type=DataType.S1615) # Write the lo_atom ID spec.write_value(data=vertex_slice.lo_atom) # Write the number of sources spec.write_value(data=vertex_slice.n_atoms) # Write the random seed (4 words), generated randomly! if vertex_slice not in self.__kiss_seed: self.__kiss_seed[vertex_slice] = create_mars_kiss_seeds( self.__rng, self.__seed) for value in self.__kiss_seed[vertex_slice]: spec.write_value(data=value)
def kiss_seed(self, vertex_slice): if vertex_slice not in self.__kiss_seed: self.__kiss_seed[vertex_slice] = create_mars_kiss_seeds(self.__rng) return self.__kiss_seed[vertex_slice]