• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / sPyNNaker / 7285532539

21 Dec 2023 08:04AM UTC coverage: 62.866% (+0.09%) from 62.778%
7285532539

Pull #1425

github

Christian-B
flake8
Pull Request #1425: Overrides check

1909 of 4475 branches covered (0.0%)

Branch coverage included in aggregate %.

317 of 328 new or added lines in 66 files covered. (96.65%)

26 existing lines in 17 files now uncovered.

12789 of 18905 relevant lines covered (67.65%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.94
/spynnaker/pyNN/extra_algorithms/splitter_components/splitter_delay_vertex_slice.py
1
# Copyright (c) 2020 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
from typing import Dict, Iterable, Sequence, Tuple
1✔
16
from spinn_utilities.overrides import overrides
1✔
17
from pacman.exceptions import (
1✔
18
    PacmanConfigurationException, PacmanInvalidParameterException)
19
from pacman.model.graphs.application import ApplicationVertex
1✔
20
from pacman.model.graphs.machine import MachineVertex
1✔
21
from pacman.model.graphs.common import Slice
1✔
22
from pacman.model.partitioner_splitters import AbstractSplitterCommon
1✔
23
from pacman.model.resources import ConstantSDRAM
1✔
24
from spinn_front_end_common.utilities.constants import (
1✔
25
    SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD)
26
from spynnaker.pyNN.models.utility_models.delays import (
1✔
27
    DelayExtensionVertex, DelayExtensionMachineVertex)
28
from pacman.utilities.utility_objs.chip_counter import ChipCounter
1✔
29
from pacman.model.resources.abstract_sdram import AbstractSDRAM
1✔
30

31

32
class SplitterDelayVertexSlice(AbstractSplitterCommon[DelayExtensionVertex]):
1✔
33
    """
34
    Handles the splitting of the :py:class:`DelayExtensionVertex`
35
    via slice logic.
36
    """
37

38
    __slots__ = ("_machine_vertex_by_slice", )
1✔
39

40
    _EXPANDER_BASE_PARAMS_SIZE = 3 * BYTES_PER_WORD
1✔
41

42
    NEED_EXACT_ERROR_MESSAGE = (
1✔
43
        "DelayExtensionsSplitters need exact incoming slices. Please fix "
44
        "and try again")
45

46
    DELAY_RECORDING_ERROR = (
1✔
47
        "The delay extensions does not record any variables. Therefore "
48
        "asking for them is deemed an error.")
49

50
    def __init__(self) -> None:
1✔
51
        super().__init__()
1✔
52
        self._machine_vertex_by_slice: Dict[
1✔
53
            Slice, DelayExtensionMachineVertex] = dict()
54

55
    @overrides(AbstractSplitterCommon.get_out_going_vertices)
1✔
56
    def get_out_going_vertices(
1✔
57
            self, partition_id: str) -> Sequence[MachineVertex]:
58
        return list(self.governed_app_vertex.machine_vertices)
1✔
59

60
    @overrides(AbstractSplitterCommon.get_in_coming_vertices)
1✔
61
    def get_in_coming_vertices(
1✔
62
            self, partition_id: str) -> Sequence[MachineVertex]:
63
        return list(self.governed_app_vertex.machine_vertices)
×
64

65
    @overrides(AbstractSplitterCommon.get_source_specific_in_coming_vertices)
1✔
66
    def get_source_specific_in_coming_vertices(
1✔
67
            self, source_vertex: ApplicationVertex,
68
            partition_id: str) -> Sequence[Tuple[
69
                DelayExtensionMachineVertex, Sequence[MachineVertex]]]:
70
        # Only connect to the source that matches the slice
71
        return [
×
72
            (self._machine_vertex_by_slice[m_vertex.vertex_slice], [m_vertex])
73
            for m_vertex in source_vertex.splitter.get_out_going_vertices(
74
                partition_id)]
75

76
    @overrides(AbstractSplitterCommon.create_machine_vertices)
1✔
77
    def create_machine_vertices(self, chip_counter: ChipCounter):
1✔
78
        source_app_vertex = self.governed_app_vertex.source_vertex
1✔
79
        slices = source_app_vertex.splitter.get_out_going_slices()
1✔
80

81
        # create vertices correctly
82
        for vertex_slice in slices:
1✔
83
            vertex = self.create_machine_vertex(
1✔
84
                source_app_vertex, vertex_slice)
85
            self.governed_app_vertex.remember_machine_vertex(vertex)
1✔
86
            chip_counter.add_core(vertex.sdram_required)
1✔
87

88
    @overrides(AbstractSplitterCommon.get_in_coming_slices)
1✔
89
    def get_in_coming_slices(self) -> Sequence[Slice]:
1✔
90
        other_splitter = self.governed_app_vertex.source_vertex.splitter
×
91
        return other_splitter.get_in_coming_slices()
×
92

93
    @overrides(AbstractSplitterCommon.get_out_going_slices)
1✔
94
    def get_out_going_slices(self) -> Sequence[Slice]:
1✔
95
        other_splitter = self.governed_app_vertex.source_vertex.splitter
×
96
        return other_splitter.get_out_going_slices()
×
97

98
    @overrides(AbstractSplitterCommon.set_governed_app_vertex)
1✔
99
    def set_governed_app_vertex(self, app_vertex: DelayExtensionVertex):
1✔
100
        super().set_governed_app_vertex(app_vertex)
1✔
101
        if not isinstance(app_vertex, DelayExtensionVertex):
1!
102
            raise PacmanConfigurationException(
×
103
                f"The vertex {app_vertex} cannot be supported by the "
104
                "SplitterDelayVertexSlice as the only vertex supported by "
105
                "this splitter is a DelayExtensionVertex. Please use the "
106
                "correct splitter for your vertex and try again.")
107

108
    def create_machine_vertex(
1✔
109
            self, source_app_vertex: ApplicationVertex, vertex_slice: Slice):
110
        """
111
        Creates a delay extension machine vertex and adds to the tracker.
112

113
        :param ~pacman.model.graphs.machine.MachineVertex source_vertex:
114
            The source of the delay
115
        :return: machine vertex
116
        :rtype: DelayExtensionMachineVertex
117
        """
118
        label = f"Delay extension for {source_app_vertex}"
1✔
119
        sdram = self.get_sdram_used_by_atoms()
1✔
120

121
        machine_vertex = DelayExtensionMachineVertex(
1✔
122
            sdram, label, vertex_slice, self.governed_app_vertex)
123

124
        self._machine_vertex_by_slice[vertex_slice] = machine_vertex
1✔
125
        return machine_vertex
1✔
126

127
    def get_sdram_used_by_atoms(self) -> AbstractSDRAM:
1✔
128
        """
129
        Gets the amount of SDRAM used by the delay extension.
130

131
        :rtype: ~pacman.model.resources.ConstantSDRAM
132
        """
133
        return ConstantSDRAM(
1✔
134
            SYSTEM_BYTES_REQUIREMENT +
135
            self.governed_app_vertex.delay_params_size() +
136
            DelayExtensionMachineVertex.get_provenance_data_size(
137
                DelayExtensionMachineVertex.N_EXTRA_PROVENANCE_DATA_ENTRIES))
138

139
    @overrides(AbstractSplitterCommon.machine_vertices_for_recording)
1✔
140
    def machine_vertices_for_recording(
1✔
141
            self, variable_to_record: str) -> Iterable[MachineVertex]:
UNCOV
142
        raise PacmanInvalidParameterException(
×
143
            variable_to_record, variable_to_record, self.DELAY_RECORDING_ERROR)
144

145
    @overrides(AbstractSplitterCommon.reset_called)
1✔
146
    def reset_called(self) -> None:
1✔
147
        self._machine_vertex_by_slice = dict()
×
148

149
    def get_machine_vertex(
1✔
150
            self, vertex_slice: Slice) -> DelayExtensionMachineVertex:
151
        """
152
        Get a delay extension machine vertex for a given vertex slice.
153

154
        :param ~pacman.model.graphs.common.Slice vertex_slice:
155
            The slice to get the data for
156
        :rtype: DelayExtensionMachineVertex
157
        """
158
        return self._machine_vertex_by_slice[vertex_slice]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc