Beispiel #1
0
def _get_allowed_row_length(n_words, dynamics, in_edge, n_synapses):
    """ Get the allowed row length in words in the population table for a
        desired row length in words

    :param int n_words: The number of words in the row
    :param AbstractSynapseDynamics dynamics: The synapse dynamics used
    :param ProjectionApplicationEdge in_edge: The incoming edge
    :param int n_synapses: The number of synapses for the number of words
    :raises SynapseRowTooBigException:
        If the given row is too big; the exception will detail the maximum
        number of synapses that are supported.
    """
    if n_words == 0:
        return 0
    try:
        return MasterPopTableAsBinarySearch.get_allowed_row_length(n_words)
    except SynapseRowTooBigException as e:
        # Find the number of synapses available for the maximum population
        # table size, as extracted from the exception
        max_synapses = dynamics.get_max_synapses(e.max_size)
        raise SynapseRowTooBigException(
            max_synapses,
            "The connection between {} and {} has more synapses ({}) than"
            " can currently be supported on this implementation of PyNN"
            " ({} for this connection type)."
            " Please reduce the size of the target population, or reduce"
            " the number of neurons per core.".format(in_edge.pre_vertex,
                                                      in_edge.post_vertex,
                                                      n_synapses,
                                                      max_synapses)) from e
Beispiel #2
0
 def _get_max_row_length(size, dynamics, population_table, in_edge,
                         row_length):
     """
     :param int size:
     :param AbstractSynapseDynamics dynamics:
     :param MasterPopTableAsBinarySearch population_table:
     :param in_edge:
     :type in_edge: ProjectionApplicationEdge or ProjectionMachineEdge
     :param int row_length:
     :raises SynapseRowTooBigException:
     """
     try:
         return population_table.get_allowed_row_length(size)
     except SynapseRowTooBigException as e:
         max_synapses = dynamics.get_max_synapses(e.max_size)
         raise_from(
             SynapseRowTooBigException(
                 max_synapses,
                 "The connection between {} and {} has more synapses ({}) than"
                 " can currently be supported on this implementation of PyNN"
                 " ({} for this connection type)."
                 " Please reduce the size of the target population, or reduce"
                 " the number of neurons per core.".format(
                     in_edge.pre_vertex, in_edge.post_vertex, row_length,
                     max_synapses)), e)
Beispiel #3
0
 def get_allowed_row_length(self, row_length):
     """
     :param row_length: the row length being considered
     :return: the row length available
     """
     if row_length > 255:
         raise SynapseRowTooBigException(
             255, "Only rows of up to 255 entries are allowed")
     return row_length
Beispiel #4
0
 def get_allowed_row_length(self, row_length):
     """
     :param int row_length: the row length being considered
     :return: the row length available
     :rtype: int
     :raises SynapseRowTooBigException: If the row won't fit
     """
     if row_length > self.MAX_ROW_LENGTH:
         raise SynapseRowTooBigException(
             self.MAX_ROW_LENGTH,
             "Only rows of up to 255 entries are allowed")
     return row_length
    def get_allowed_row_length(self, row_length):
        # Can even the largest valid entry accommodate the given synaptic row?
        if row_length > ROW_LEN_TABLE_ENTRIES[-1]:
            raise SynapseRowTooBigException(
                ROW_LEN_TABLE_ENTRIES[-1],
                "Max row length too long; wanted length {}, but max length "
                "permitted is {}.".format(
                    row_length, ROW_LEN_TABLE_ENTRIES[-1]))

        # Search up the list until we find one entry big enough:
        for length in ROW_LEN_TABLE_ENTRIES:
            if row_length <= length:
                # This row length is big enough. Choose it and exit:
                return length
        raise Exception("Should not get here!")
Beispiel #6
0
    def get_allowed_row_length(row_length):
        """ Get the next allowed row length

        :param int row_length: the row length being considered
        :return: the row length available
        :rtype: int
        :raises SynapseRowTooBigException: If the row won't fit
        """

        if row_length > POP_TABLE_MAX_ROW_LENGTH:
            raise SynapseRowTooBigException(
                POP_TABLE_MAX_ROW_LENGTH,
                "Only rows of up to {} entries are allowed".format(
                    POP_TABLE_MAX_ROW_LENGTH))
        return row_length
Beispiel #7
0
 def _get_max_row_bytes(
         self, size, dynamics, population_table, in_edge, row_length):
     # pylint: disable=too-many-arguments
     try:
         return population_table.get_allowed_row_length(size) * 4
     except SynapseRowTooBigException as e:
         max_synapses = dynamics.get_max_synapses(e.max_size)
         raise_from(SynapseRowTooBigException(
             max_synapses,
             "The connection between {} and {} has more synapses ({}) than"
             " can currently be supported on this implementation of PyNN"
             " ({} for this connection type)."
             " Please reduce the size of the target population, or reduce"
             " the number of neurons per core.".format(
                 in_edge.pre_vertex, in_edge.post_vertex, row_length,
                 max_synapses)), e)