From 6e76c924d084109802127a22f81a35407a8f31b1 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 2 Jan 2024 10:56:45 +0000 Subject: [PATCH 01/10] overrides typing --- spinn_pdp2/input_vertex.py | 23 +++++++++++++++-------- spinn_pdp2/sum_vertex.py | 22 +++++++++++++++------- spinn_pdp2/threshold_vertex.py | 28 ++++++++++++++++++---------- spinn_pdp2/weight_vertex.py | 22 +++++++++++++++------- 4 files changed, 63 insertions(+), 32 deletions(-) diff --git a/spinn_pdp2/input_vertex.py b/spinn_pdp2/input_vertex.py index 1c6460e..81806c3 100644 --- a/spinn_pdp2/input_vertex.py +++ b/spinn_pdp2/input_vertex.py @@ -14,8 +14,12 @@ # along with this program. If not, see . import struct +from typing import Iterable, Optional + +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine.machine_vertex import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_utilities.overrides import overrides @@ -25,7 +29,8 @@ from spinn_front_end_common.abstract_models.impl \ import MachineDataSpecableVertex from spinn_front_end_common.data import FecDataView -from spinn_front_end_common.interface.ds import DataType +from spinn_front_end_common.interface.ds import ( + DataSpecificationGenerator, DataSpecificationReloader, DataType) from spinn_front_end_common.utilities.constants \ import SYSTEM_BYTES_REQUIREMENT @@ -193,17 +198,18 @@ def config (self): @property @overrides (MachineVertex.sdram_required) - def sdram_required (self): + def sdram_required (self) -> ConstantSDRAM: return ConstantSDRAM(SYSTEM_BYTES_REQUIREMENT + self._sdram_usage) @overrides (MachineVertex.get_n_keys_for_partition) - def get_n_keys_for_partition (self, partition_id): + def get_n_keys_for_partition(self, partition_id: str) -> int: return MLPConstants.KEY_SPACE_SIZE - @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): routing_info = FecDataView.get_routing_infos() # Generate the system data region for simulation.c requirements @@ -321,7 +327,8 @@ def generate_machine_data_specification( @overrides(AbstractRewritesDataSpecification.regenerate_data_specification) - def regenerate_data_specification(self, spec, placement): + def regenerate_data_specification( + self, spec: DataSpecificationReloader, placement: Placement): # Reserve and write the stage configuration region spec.reserve_memory_region (MLPRegions.STAGE.value, self._STAGE_CONFIGURATION_BYTES) @@ -336,12 +343,12 @@ def regenerate_data_specification(self, spec, placement): @overrides(AbstractRewritesDataSpecification.reload_required) - def reload_required(self): + def reload_required(self) -> bool: return True @overrides(AbstractRewritesDataSpecification.set_reload_required) - def set_reload_required(self, new_value): + def set_reload_required(self, new_value: bool): """ TODO: not really sure what this method is used for! """ diff --git a/spinn_pdp2/sum_vertex.py b/spinn_pdp2/sum_vertex.py index c302c46..b4534f2 100644 --- a/spinn_pdp2/sum_vertex.py +++ b/spinn_pdp2/sum_vertex.py @@ -14,11 +14,15 @@ # along with this program. If not, see . import struct +from typing import Iterable, Optional + +from spinn_machine.tags import IPTag, ReverseIPTag import spinnaker_graph_front_end as gfe from pacman.model.graphs.machine import MachineEdge from pacman.model.graphs.machine.machine_vertex import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_utilities.overrides import overrides @@ -28,7 +32,8 @@ from spinn_front_end_common.abstract_models.impl \ import MachineDataSpecableVertex from spinn_front_end_common.data import FecDataView -from spinn_front_end_common.interface.ds import DataType +from spinn_front_end_common.interface.ds import ( + DataSpecificationGenerator, DataSpecificationReloader, DataType) from spinn_front_end_common.utilities.constants \ import SYSTEM_BYTES_REQUIREMENT @@ -248,18 +253,20 @@ def config (self): @property @overrides (MachineVertex.sdram_required) - def sdram_required (self): + def sdram_required (self) -> ConstantSDRAM: return ConstantSDRAM(SYSTEM_BYTES_REQUIREMENT + self._sdram_usage) @overrides (MachineVertex.get_n_keys_for_partition) - def get_n_keys_for_partition (self, partition_id): + def get_n_keys_for_partition(self, partition_id: str) -> int: return MLPConstants.KEY_SPACE_SIZE @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): routing_info = FecDataView.get_routing_infos() # Generate the system data region for simulation.c requirements generate_steps_system_data_region(spec, MLPRegions.SYSTEM.value, self) @@ -347,7 +354,8 @@ def generate_machine_data_specification( @overrides(AbstractRewritesDataSpecification.regenerate_data_specification) - def regenerate_data_specification(self, spec, placement): + def regenerate_data_specification( + self, spec: DataSpecificationReloader, placement: Placement): # Reserve and write the stage configuration region spec.reserve_memory_region (MLPRegions.STAGE.value, self._STAGE_CONFIGURATION_BYTES) @@ -362,12 +370,12 @@ def regenerate_data_specification(self, spec, placement): @overrides(AbstractRewritesDataSpecification.reload_required) - def reload_required(self): + def reload_required(self) -> bool: return True @overrides(AbstractRewritesDataSpecification.set_reload_required) - def set_reload_required(self, new_value): + def set_reload_required(self, new_value: bool): """ TODO: not really sure what this method is used for! """ diff --git a/spinn_pdp2/threshold_vertex.py b/spinn_pdp2/threshold_vertex.py index 7bd5b7e..fa0cf50 100644 --- a/spinn_pdp2/threshold_vertex.py +++ b/spinn_pdp2/threshold_vertex.py @@ -14,9 +14,13 @@ # along with this program. If not, see . import struct +from typing import Iterable, Optional + +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine.machine_vertex import MachineVertex -from pacman.model.resources import VariableSDRAM, ConstantSDRAM +from pacman.model.placements import Placement +from pacman.model.resources import AbstractSDRAM, ConstantSDRAM, VariableSDRAM from spinn_utilities.overrides import overrides @@ -25,7 +29,8 @@ from spinn_front_end_common.abstract_models.impl \ import MachineDataSpecableVertex from spinn_front_end_common.data import FecDataView -from spinn_front_end_common.interface.ds import DataType +from spinn_front_end_common.interface.ds import ( + DataSpecificationGenerator, DataSpecificationReloader, DataType) from spinn_front_end_common.utilities.constants \ import SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD from spinn_front_end_common.interface.buffer_management.buffer_models import ( @@ -341,7 +346,7 @@ def config (self): @property @overrides (MachineVertex.sdram_required) - def sdram_required (self): + def sdram_required (self) -> AbstractSDRAM: if self.group.output_grp: return VariableSDRAM(self._sdram_fixed, self._sdram_variable) else: @@ -349,7 +354,7 @@ def sdram_required (self): @overrides (MachineVertex.get_n_keys_for_partition) - def get_n_keys_for_partition (self, partition_id): + def get_n_keys_for_partition(self, partition_id: str) -> int: return MLPConstants.KEY_SPACE_SIZE @@ -373,7 +378,9 @@ def read(self, placement, buffer_manager, channel): @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): routing_info = FecDataView.get_routing_infos() # Generate the system data region for simulation.c requirements generate_steps_system_data_region(spec, MLPRegions.SYSTEM.value, self) @@ -531,7 +538,8 @@ def generate_machine_data_specification( @overrides(AbstractRewritesDataSpecification.regenerate_data_specification) - def regenerate_data_specification(self, spec, placement): + def regenerate_data_specification( + self, spec: DataSpecificationReloader, placement: Placement): # reserve and write the stage configuration region spec.reserve_memory_region (MLPRegions.STAGE.value, self._STAGE_CONFIGURATION_BYTES) @@ -546,12 +554,12 @@ def regenerate_data_specification(self, spec, placement): @overrides(AbstractRewritesDataSpecification.reload_required) - def reload_required(self): + def reload_required(self) -> bool: return True @overrides(AbstractRewritesDataSpecification.set_reload_required) - def set_reload_required(self, new_value): + def set_reload_required(self, new_value: bool): """ TODO: not really sure what this method is used for! """ @@ -560,7 +568,7 @@ def set_reload_required(self, new_value): @overrides(AbstractReceiveBuffersToHost.get_recorded_region_ids) - def get_recorded_region_ids(self): + def get_recorded_region_ids(self) -> list[int]: if self.group.output_grp: ids = [ch.value for ch in MLPVarSizeRecordings] ids.extend([ch.value for ch in MLPConstSizeRecordings]) @@ -575,6 +583,6 @@ def get_recorded_region_ids(self): @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement): + def get_recording_region_base_address(self, placement: Placement) -> int: return locate_memory_region_for_placement( placement, MLPRegions.REC_INFO.value) diff --git a/spinn_pdp2/weight_vertex.py b/spinn_pdp2/weight_vertex.py index 6d036d5..87a0f44 100644 --- a/spinn_pdp2/weight_vertex.py +++ b/spinn_pdp2/weight_vertex.py @@ -14,8 +14,12 @@ # along with this program. If not, see . import struct +from typing import Iterable, Optional + +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine.machine_vertex import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_utilities.overrides import overrides @@ -25,7 +29,8 @@ from spinn_front_end_common.abstract_models.impl \ import MachineDataSpecableVertex from spinn_front_end_common.data import FecDataView -from spinn_front_end_common.interface.ds import DataType +from spinn_front_end_common.interface.ds import ( + DataSpecificationGenerator, DataSpecificationReloader, DataType) from spinn_front_end_common.utilities.constants \ import SYSTEM_BYTES_REQUIREMENT @@ -259,18 +264,20 @@ def config (self): @property @overrides (MachineVertex.sdram_required) - def sdram_required (self): + def sdram_required (self) -> ConstantSDRAM: return ConstantSDRAM(SYSTEM_BYTES_REQUIREMENT + self._sdram_usage) @overrides (MachineVertex.get_n_keys_for_partition) - def get_n_keys_for_partition (self, partition_id): + def get_n_keys_for_partition(self, partition_id: str) -> int: return MLPConstants.KEY_SPACE_SIZE @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): routing_info = FecDataView.get_routing_infos() # Generate the system data region for simulation.c requirements @@ -381,7 +388,8 @@ def generate_machine_data_specification( @overrides(AbstractRewritesDataSpecification.regenerate_data_specification) - def regenerate_data_specification(self, spec, placement): + def regenerate_data_specification( + self, spec: DataSpecificationReloader, placement: Placement): # Reserve and write the stage configuration region spec.reserve_memory_region (MLPRegions.STAGE.value, self._STAGE_CONFIGURATION_BYTES) @@ -396,12 +404,12 @@ def regenerate_data_specification(self, spec, placement): @overrides(AbstractRewritesDataSpecification.reload_required) - def reload_required(self): + def reload_required(self) -> bool: return True @overrides(AbstractRewritesDataSpecification.set_reload_required) - def set_reload_required(self, new_value): + def set_reload_required(self, new_value: bool): """ TODO: not really sure what this method is used for! """ From cedae103cd91922612936224504e1c81e9413bcc Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 2 Jan 2024 12:25:59 +0000 Subject: [PATCH 02/10] use typing List --- spinn_pdp2/threshold_vertex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spinn_pdp2/threshold_vertex.py b/spinn_pdp2/threshold_vertex.py index fa0cf50..9674015 100644 --- a/spinn_pdp2/threshold_vertex.py +++ b/spinn_pdp2/threshold_vertex.py @@ -14,7 +14,7 @@ # along with this program. If not, see . import struct -from typing import Iterable, Optional +from typing import Iterable, List, Optional from spinn_machine.tags import IPTag, ReverseIPTag @@ -568,7 +568,7 @@ def set_reload_required(self, new_value: bool): @overrides(AbstractReceiveBuffersToHost.get_recorded_region_ids) - def get_recorded_region_ids(self) -> list[int]: + def get_recorded_region_ids(self) -> List[int]: if self.group.output_grp: ids = [ch.value for ch in MLPVarSizeRecordings] ids.extend([ch.value for ch in MLPConstSizeRecordings]) From 9d5ef5eb2c96ddf948ace7e27283ddf50a892704 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 08:24:58 +0000 Subject: [PATCH 03/10] activate mypy --- .github/workflows/python_actions.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 883873b..a061fb3 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -91,3 +91,6 @@ jobs: # uses: ./support/actions/sphinx # with: # directory: doc/source + + - name: Lint with mypy + run: mypy $BASE_PKG From 38dfb63477153b7eeb4114c46b9b6c5f835e4e85 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 09:33:59 +0000 Subject: [PATCH 04/10] Install mypy --- .github/workflows/python_actions.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index a061fb3..b2a66dc 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -45,7 +45,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install pip, etc uses: ./support/actions/python-tools - + - name: Install mypy + run: pip install mypy - name: Install Spinnaker Dependencies uses: ./support/actions/install-spinn-deps with: From b49e4b16d8424b23b684978027c741bcf95f0794 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 09:50:51 +0000 Subject: [PATCH 05/10] run mypy --- .github/workflows/python_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index b2a66dc..27b3937 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -94,4 +94,4 @@ jobs: # directory: doc/source - name: Lint with mypy - run: mypy $BASE_PKG + run: mypy spinn_pdp2 examples From b593d8f592717ff812f65d71a76fcea5efe8e9b4 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 13:08:39 +0000 Subject: [PATCH 06/10] add py.typed marker --- spinn_pdp2/py.typed | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spinn_pdp2/py.typed diff --git a/spinn_pdp2/py.typed b/spinn_pdp2/py.typed new file mode 100644 index 0000000..91eaa0c --- /dev/null +++ b/spinn_pdp2/py.typed @@ -0,0 +1,13 @@ +# Copyright (c) 2023 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. From f64c40911e3ce54bd83c9d91437d3eb4638f187d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 16:22:59 +0000 Subject: [PATCH 07/10] mypy spinn_pdp2 --- .github/workflows/python_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 27b3937..eb1e109 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -94,4 +94,4 @@ jobs: # directory: doc/source - name: Lint with mypy - run: mypy spinn_pdp2 examples + run: mypy spinn_pdp2 From e907c7b6b3d08ccec226e85ea3b4780a1b3c263c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 9 Jan 2024 06:44:52 +0000 Subject: [PATCH 08/10] removed __init__.py from outer directory --- __init__.py | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index c617e64..0000000 --- a/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2015 The University of Manchester -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - From 92666e35dbf18580ce6b3c6d01650f0e13ec4199 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 9 Jan 2024 07:01:02 +0000 Subject: [PATCH 09/10] assert value is not None befere writing --- spinn_pdp2/input_vertex.py | 12 ++++++++---- spinn_pdp2/sum_vertex.py | 22 ++++++++++++++-------- spinn_pdp2/threshold_vertex.py | 18 ++++++++++++------ spinn_pdp2/weight_vertex.py | 24 ++++++++++++++++-------- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/spinn_pdp2/input_vertex.py b/spinn_pdp2/input_vertex.py index 81806c3..1ad1184 100644 --- a/spinn_pdp2/input_vertex.py +++ b/spinn_pdp2/input_vertex.py @@ -294,12 +294,16 @@ def generate_machine_data_specification( spec.switch_write_focus (MLPRegions.ROUTING.value) # write link keys: fwd - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.fwd_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.fwd_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: bkp - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.bkp_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.bkp_link) + assert key is not None + spec.write_value (key, data_type = DataType.UINT32) # write link keys: bps (padding) spec.write_value (0, data_type = DataType.UINT32) diff --git a/spinn_pdp2/sum_vertex.py b/spinn_pdp2/sum_vertex.py index b4534f2..23c51d5 100644 --- a/spinn_pdp2/sum_vertex.py +++ b/spinn_pdp2/sum_vertex.py @@ -319,12 +319,14 @@ def generate_machine_data_specification( spec.switch_write_focus (MLPRegions.ROUTING.value) # write link keys: fwd - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.fwd_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.fwd_link) + spec.write_value(key, data_type=DataType.UINT32) # write link keys: bkp - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.bkp_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.bkp_link) + spec.write_value(key, data_type=DataType.UINT32) # write link keys: bps (padding) spec.write_value (0, data_type = DataType.UINT32) @@ -333,12 +335,16 @@ def generate_machine_data_specification( spec.write_value (0, data_type = DataType.UINT32) # write link keys: lds - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.lds_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.lds_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: fsg - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.fsg_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex ( + self, self.fsg_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # Reserve and write the stage configuration region spec.reserve_memory_region (MLPRegions.STAGE.value, diff --git a/spinn_pdp2/threshold_vertex.py b/spinn_pdp2/threshold_vertex.py index 9674015..e290738 100644 --- a/spinn_pdp2/threshold_vertex.py +++ b/spinn_pdp2/threshold_vertex.py @@ -484,19 +484,25 @@ def generate_machine_data_specification( spec.switch_write_focus (MLPRegions.ROUTING.value) # write link keys: fwd - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.fwd_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.fwd_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: bkp - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.bkp_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.bkp_link) + assert key is not None + spec.write_value (key, data_type = DataType.UINT32) # write link keys: bps (padding) spec.write_value (0, data_type = DataType.UINT32) # write link keys: stp - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.stp_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.stp_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: lds (padding) spec.write_value (0, data_type = DataType.UINT32) diff --git a/spinn_pdp2/weight_vertex.py b/spinn_pdp2/weight_vertex.py index 87a0f44..f7598dd 100644 --- a/spinn_pdp2/weight_vertex.py +++ b/spinn_pdp2/weight_vertex.py @@ -353,12 +353,16 @@ def generate_machine_data_specification( spec.switch_write_focus (MLPRegions.ROUTING.value) # write link keys: fwd - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.fwd_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.fwd_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: bkp - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.bkp_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.bkp_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: bps (padding) spec.write_value (0, data_type = DataType.UINT32) @@ -367,12 +371,16 @@ def generate_machine_data_specification( spec.write_value (0, data_type = DataType.UINT32) # write link keys: lds - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.lds_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.lds_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # write link keys: fsg - spec.write_value (routing_info.get_first_key_from_pre_vertex ( - self, self.fsg_link), data_type = DataType.UINT32) + key = routing_info.get_first_key_from_pre_vertex( + self, self.fsg_link) + assert key is not None + spec.write_value(key, data_type=DataType.UINT32) # Reserve and write the stage configuration region spec.reserve_memory_region (MLPRegions.STAGE.value, From 9bb655a037de63a7a3a0f79d4a072fc470e16b3f Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 9 Jan 2024 07:13:34 +0000 Subject: [PATCH 10/10] assert value is not None befere writing --- spinn_pdp2/sum_vertex.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spinn_pdp2/sum_vertex.py b/spinn_pdp2/sum_vertex.py index 23c51d5..9158283 100644 --- a/spinn_pdp2/sum_vertex.py +++ b/spinn_pdp2/sum_vertex.py @@ -321,11 +321,13 @@ def generate_machine_data_specification( # write link keys: fwd key = routing_info.get_first_key_from_pre_vertex( self, self.fwd_link) + assert key is not None spec.write_value(key, data_type=DataType.UINT32) # write link keys: bkp key = routing_info.get_first_key_from_pre_vertex( self, self.bkp_link) + assert key is not None spec.write_value(key, data_type=DataType.UINT32) # write link keys: bps (padding)