Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c32394d
Add provenance writing for app_vertex
andrewgait Oct 27, 2021
3d682df
Use the correct type
andrewgait Oct 27, 2021
7b3b104
Merge branch 'master' into weight_scale
andrewgait Nov 5, 2021
55a6f3e
Merge branch 'master' into weight_scale
andrewgait Nov 5, 2021
f2d18fb
Merge branch 'master' into weight_scale
andrewgait Nov 10, 2021
2febcfd
Merge branch 'master' into weight_scale
andrewgait Nov 11, 2021
0ffb914
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 25, 2021
e9a3286
Merge branch 'master' into weight_scale
andrewgait Jan 10, 2022
31aef2a
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Feb 25, 2022
fbba09b
Merge branch 'master' into weight_scale
andrewgait Mar 11, 2022
1c017c0
Merge branch 'master' into weight_scale
andrewgait Mar 28, 2022
37d8925
Merge branch 'master' into weight_scale
andrewgait Apr 14, 2022
31db8d0
Merge branch 'master' into weight_scale
andrewgait Apr 20, 2022
de856ca
Merge branch 'master' into weight_scale
andrewgait May 9, 2022
3438aa8
Merge branch 'master' into weight_scale
andrewgait May 19, 2022
3c0dbe2
Merge branch 'master' into weight_scale
andrewgait May 25, 2022
dcf968e
Merge branch 'master' into weight_scale
andrewgait Jun 16, 2022
1cecff0
Merge branch 'master' into weight_scale
andrewgait Jul 11, 2022
8be9e9f
Merge branch 'master' into weight_scale
andrewgait Jul 22, 2022
8ca2f04
Rename to label as that's what is being used
andrewgait Jul 22, 2022
1683e89
Merge branch 'master' into weight_scale
andrewgait Aug 3, 2022
a6f5ec6
Merge branch 'master' into weight_scale
andrewgait Aug 4, 2022
aa9bb8f
Merge branch 'master' into weight_scale
andrewgait Aug 22, 2022
c1ade29
Merge branch 'master' into weight_scale
andrewgait Sep 9, 2022
99ad84e
Merge branch 'master' into weight_scale
andrewgait Sep 14, 2022
e0a525c
Merge branch 'master' into weight_scale
andrewgait Sep 15, 2022
1827764
Merge branch 'master' into weight_scale
andrewgait Sep 15, 2022
48a50d1
Merge branch 'master' into weight_scale
andrewgait Sep 16, 2022
62afeb6
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 26, 2022
cd1eaf4
Merge properly
andrewgait Sep 26, 2022
f5e8634
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 27, 2022
41a906c
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 18, 2022
741e691
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 24, 2022
3a9f5c2
Merge branch 'master' into weight_scale
andrewgait Jan 11, 2023
b11a98f
Merge branch 'master' into weight_scale
andrewgait Jan 11, 2023
a3fb89f
Merge branch 'master' into weight_scale
andrewgait Jan 12, 2023
a8f3777
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jan 24, 2023
b69d547
Merge branch 'master' into weight_scale
andrewgait Feb 10, 2023
a617bc7
Merge branch 'master' into weight_scale
andrewgait Feb 20, 2023
7d7a087
Merge branch 'master' into weight_scale
andrewgait Mar 1, 2023
2b9fd91
Merge branch 'master' into weight_scale
andrewgait Apr 11, 2023
2a45126
Merge branch 'master' into weight_scale
andrewgait Apr 21, 2023
8fd131e
Merge branch 'master' into weight_scale
andrewgait May 17, 2023
283a492
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jun 23, 2023
58dc28a
Fix doc strings
andrewgait Jun 23, 2023
fc27dc6
Merge branch 'master' into weight_scale
andrewgait Jul 6, 2023
35d85ce
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 7, 2023
baa87ed
Merge branch 'master' into weight_scale
andrewgait Jul 17, 2023
05e8187
Merge branch 'master' into weight_scale
andrewgait Jul 18, 2023
5a310d1
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 21, 2023
510c0ab
Merge branch 'master' into weight_scale
andrewgait Aug 2, 2023
702f2e8
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 12, 2023
8726858
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 26, 2023
439ce85
Update test
andrewgait Sep 26, 2023
f35411a
Merge branch 'master' into weight_scale
andrewgait Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 52 additions & 8 deletions spinn_front_end_common/interface/ds/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
import numpy as np


def _round_to_int(value):
""" Rounds a number to the closest integer
:param float value: The value to round
:rtype: int
"""
if isinstance(value, int):
return value
return int(round(value))


class DataType(Enum):
"""
Supported data types.
Expand Down Expand Up @@ -49,7 +59,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"B",
False,
int,
_round_to_int,
np.uint8,
"8-bit unsigned integer")
#: 16-bit unsigned integer
Expand All @@ -60,7 +70,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"H",
False,
int,
_round_to_int,
np.uint16,
"16-bit unsigned integer")
#: 32-bit unsigned integer
Expand All @@ -71,7 +81,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"I",
False,
int,
_round_to_int,
np.uint32,
"32-bit unsigned integer")
#: 64-bit unsigned integer
Expand All @@ -82,7 +92,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"Q",
False,
int,
_round_to_int,
np.uint64,
"64-bit unsigned integer")
#: 8-bit signed integer
Expand All @@ -93,7 +103,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"b",
False,
int,
_round_to_int,
np.int8,
"8-bit signed integer")
#: 16-bit signed integer
Expand All @@ -104,7 +114,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"h",
False,
int,
_round_to_int,
np.int16,
"16-bit signed integer")
#: 32-bit signed integer
Expand All @@ -115,7 +125,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"i",
False,
int,
_round_to_int,
np.int32,
"32-bit signed integer")
#: 64-bit signed integer
Expand All @@ -126,7 +136,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"q",
False,
int,
_round_to_int,
np.int64,
"64-bit signed integer")
#: 8.8 unsigned fixed point number
Expand Down Expand Up @@ -402,6 +412,31 @@ def numpy_typename(self):
"""
return self._numpy_typename

def closest_representable_value(self, value):
"""
Returns the closest value to the given value that can be represented
by this type

:param value:
:type value: float or in
:rtype: float
"""
return self.decode_from_int(self.encode_as_int(value))

def closest_representable_value_above(self, value):
"""
Returns the closest value above the given value that can be
represented by this type.

:param value:
:type value: float or in
:rtype: float
"""
closest_value = self.decode_from_int(self.encode_as_int(value))
if closest_value >= value:
return closest_value
return self.decode_from_int(self.encode_as_int(value)+1)

def encode_as_int(self, value):
"""
Returns the value as an integer, according to this type.
Expand All @@ -425,6 +460,15 @@ def encode_as_int(self, value):
return self._force_cast(value)
return value

def decode_from_int(self, value):
"""
Decode a single value represented as an int according to this type.

:param int array:
:rtype: float or int
"""
return value / float(self._scale)

def encode_as_numpy_int(self, value):
"""
Returns the value as a numpy integer, according to this type.
Expand Down
18 changes: 18 additions & 0 deletions spinn_front_end_common/interface/provenance/provenance_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,21 @@ def insert_board_provenance(self, connections):
VALUES (?, ?, ?)
""", ((x, y, ipaddress)
for ((x, y), ipaddress) in connections.items()))

def insert_app_vertex(
self, label, the_type, description, the_value):
"""
Inserts app level data into the app_vertex_provenance

:param str label: Label of the app_vertex
:param str the_type: Class of the app_vertex
:param str description: type of value
:param float the_value: data
"""
self.execute(
"""
INSERT OR IGNORE INTO app_vertex_provenance(
label, the_type, description, the_value)
VALUES(?, ?, ?, ?)
""",
[label, the_type, description, the_value])
10 changes: 10 additions & 0 deletions spinn_front_end_common/utilities/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,13 @@ CREATE TABLE IF NOT EXISTS boards_provenance(
ip_addres STRING NOT NULL,
ethernet_x INTEGER NOT NULL,
ethernet_y INTEGER NOT NULL);

---------------------------------------------------------------------
-- A table app vertex provenance
CREATE TABLE IF NOT EXISTS app_vertex_provenance(
app_vertex_id INTEGER PRIMARY KEY AUTOINCREMENT,
label STRING NOT NULL,
the_type STRING NOT NULL,
description STRING NOT NULL,
the_value FLOAT NOT NULL);

8 changes: 8 additions & 0 deletions unittests/interface/provenance/test_provenance_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ def test_board(self):
with ProvenanceWriter() as db:
db.insert_board_provenance(data)

def test_app_vertex(self):
with ProvenanceWriter() as db:
db.insert_app_vertex("pop", "type", "description", 0.5)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type tested here does not match the CREATE TABLE.

While it works it is not the cleanest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - good spot, edited.

with ProvenanceReader() as db:
data = db.run_query("Select * from app_vertex_provenance")
expected = [(1, 'pop', 'type', 'description', 0.5)]
self.assertListEqual(expected, data)

def test_log(self):
db1 = LogStoreDB()
db2 = LogStoreDB()
Expand Down