aboutsummaryrefslogtreecommitdiff
path: root/driver_library/python
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2024-02-16 11:04:46 +0100
committerMikael Olsson <mikael.olsson@arm.com>2024-02-19 13:27:51 +0100
commitdc18ceaa54957d5ac05292b363a5ac6fe479f409 (patch)
treeb7fae5e1448ef4436e78c0c838f4a07e59ce3039 /driver_library/python
parent16be28550f0906e2bfff20b94dd373f59b4a2ccf (diff)
downloadethos-u-linux-driver-stack-dc18ceaa54957d5ac05292b363a5ac6fe479f409.tar.gz
Add NPU device type to capabilities
In preparation to support the Linux kernel driver directly managing the NPU without a subsystem. A NPU device type has been added to the capabilities to be able to specify what kind of NPU is used. Change-Id: I45345b7d75d234f821d70b858453d3af2a99194e Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'driver_library/python')
-rw-r--r--driver_library/python/src/ethosu_driver/swig/driver.i16
-rw-r--r--driver_library/python/test/test_capabilities.py12
2 files changed, 21 insertions, 7 deletions
diff --git a/driver_library/python/src/ethosu_driver/swig/driver.i b/driver_library/python/src/ethosu_driver/swig/driver.i
index a8db7c1..721e4d0 100644
--- a/driver_library/python/src/ethosu_driver/swig/driver.i
+++ b/driver_library/python/src/ethosu_driver/swig/driver.i
@@ -1,5 +1,5 @@
//
-// SPDX-FileCopyrightText: Copyright 2020, 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+// SPDX-FileCopyrightText: Copyright 2020, 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
// SPDX-License-Identifier: Apache-2.0
//
%module driver
@@ -117,10 +117,21 @@ version. This also specifies is custom DMA is enabled or not.
%nodefaultctor HardwareConfiguration;
class HardwareConfiguration {
public:
- HardwareConfiguration(uint32_t macs = 0, uint32_t cmdStreamVersion = 0, bool customDma = false);
+ HardwareConfiguration(uint32_t macs = 0, uint32_t cmdStreamVersion = 0, uint32_t type = static_cast<uint32_t>(DeviceType::UNKNOWN), bool customDma = false);
+
+ %feature("docstring",
+ "
+ DeviceType enumeration
+ ") DeviceType;
+ enum class DeviceType {
+ UNKNOWN = 0,
+ SUBSYSTEM,
+ DIRECT,
+ };
uint32_t macsPerClockCycle;
uint32_t cmdStreamVersion;
+ DeviceType type;
bool customDma;
};
@@ -129,6 +140,7 @@ class HardwareConfiguration {
std::ostringstream out;
out << "{macsPerClockCycle=" << $self->macsPerClockCycle <<
", cmdStreamVersion=" << $self->cmdStreamVersion <<
+ ", type=" << $self->type <<
", customDma=" << ($self->customDma? "True": "False") << "}";
return out.str();
}
diff --git a/driver_library/python/test/test_capabilities.py b/driver_library/python/test/test_capabilities.py
index ffb201c..7af1f0e 100644
--- a/driver_library/python/test/test_capabilities.py
+++ b/driver_library/python/test/test_capabilities.py
@@ -1,5 +1,5 @@
#
-# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2021-2022, 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
from ethosu_driver._generated.driver import SemanticVersion
@@ -37,13 +37,14 @@ def test_hardware_id():
def test_hw_configuration():
- hw_cfg = HardwareConfiguration(128, 1, True)
+ hw_cfg = HardwareConfiguration(128, 1, HardwareConfiguration.DeviceType_SUBSYSTEM, True)
assert 1 == hw_cfg.cmdStreamVersion
assert 128 == hw_cfg.macsPerClockCycle
assert hw_cfg.customDma
+ assert HardwareConfiguration.DeviceType_SUBSYSTEM == hw_cfg.type
- assert "{macsPerClockCycle=128, cmdStreamVersion=1, customDma=True}" == hw_cfg.__str__()
+ assert "{macsPerClockCycle=128, cmdStreamVersion=1, type=subsystem, customDma=True}" == hw_cfg.__str__()
def test_capabilities():
@@ -51,7 +52,7 @@ def test_capabilities():
product = SemanticVersion(400, 500, 600)
architecture = SemanticVersion(700, 800, 900)
hw_id = HardwareId(1, version, product, architecture)
- hw_cfg = HardwareConfiguration(256, 1000, False)
+ hw_cfg = HardwareConfiguration(256, 1000, HardwareConfiguration.DeviceType_SUBSYSTEM, False)
driver_v = SemanticVersion(10, 20, 30)
cap = Capabilities(hw_id, hw_cfg, driver_v)
@@ -64,10 +65,11 @@ def test_capabilities():
assert 1000 == cap.hwCfg.cmdStreamVersion
assert 256 == cap.hwCfg.macsPerClockCycle
+ assert HardwareConfiguration.DeviceType_SUBSYSTEM == cap.hwCfg.type
assert not cap.hwCfg.customDma
assert '{hwId={versionStatus=1, version={ major=100, minor=200, patch=300 }, ' \
'product={ major=400, minor=500, patch=600 }, ' \
'architecture={ major=700, minor=800, patch=900 }}, ' \
- 'hwCfg={macsPerClockCycle=256, cmdStreamVersion=1000, customDma=False}, ' \
+ 'hwCfg={macsPerClockCycle=256, cmdStreamVersion=1000, type=subsystem, customDma=False}, ' \
'driver={ major=10, minor=20, patch=30 }}' == cap.__str__()