aboutsummaryrefslogtreecommitdiff
path: root/driver_library/python/src/ethosu_driver/swig/driver.i
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2023-10-17 13:05:38 +0200
committerMikael Olsson <mikael.olsson@arm.com>2023-11-06 09:36:00 +0100
commit075451507cda3e8f543caecacfadf226a69e5a05 (patch)
treed12ec47fa73c61a7bec3543a29c5dd2ae6b66c93 /driver_library/python/src/ethosu_driver/swig/driver.i
parent45d47991f745094e328f32e769c22d811d397b1d (diff)
downloadethos-u-linux-driver-stack-075451507cda3e8f543caecacfadf226a69e5a05.tar.gz
Remove buffer capacity, offset and resize in UAPI
The UAPI no longer supports the buffer capacity, offset and resize functionality. Instead, the UAPI now only accepts a fixed size given at the creation of the buffer. This change was made because the features were not used and made the buffer handling more complicated. The user knows how big buffers they need for their networks so they don't need resize support or partial buffer usage support by having separate size and capacity with an offset. Without these features, the buffer instance no longer needs any IOCTL call support so it has been removed. However, to still be able to check the size of a buffer from its file descriptor, seek support has been implemented so lseek and similar functions can be used to get the size. The driver library's clear function that previously only reset the size and offset values of the buffer will now clear the buffer content instead. These are breaking changes so the Linux kernel NPU driver version and the driver library version have been given major version bumps. All the tests and other applications affected by these changes have been updated accordingly. Change-Id: Ifc34cf04724a95853ad23fd7398dd286f73bcdab Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'driver_library/python/src/ethosu_driver/swig/driver.i')
-rw-r--r--driver_library/python/src/ethosu_driver/swig/driver.i46
1 files changed, 4 insertions, 42 deletions
diff --git a/driver_library/python/src/ethosu_driver/swig/driver.i b/driver_library/python/src/ethosu_driver/swig/driver.i
index 1ff8ded..3e4e384 100644
--- a/driver_library/python/src/ethosu_driver/swig/driver.i
+++ b/driver_library/python/src/ethosu_driver/swig/driver.i
@@ -210,31 +210,22 @@ public:
Buffer object represents a RW mapping in the virtual address space of the caller.
Created mapping is shareable, updates to the mapping are visible to other processes mapping the same region.
- Issues ETHOSU_IOCTL_BUFFER_CREATE I/O request to the device with given Maximum capacity.
+ Issues ETHOSU_IOCTL_BUFFER_CREATE I/O request to the device with given size.
- Buffer could be created for a device with given maximum capacity or instantiated directly from
+ Buffer could be created for a device with given size or instantiated directly from
a file containing binary data.
Examples:
>>> import ethosu_driver as driver
>>> # from file:
>>> buf = driver.Buffer(device, '/path/to/file')
- >>> # Empty, with maximum capacity:
+ >>> # Empty, with size:
>>> buf = driver.Buffer(device, 1024)
") Buffer;
%nodefaultctor Buffer;
class Buffer {
public:
- Buffer(const Device &device, const size_t capacity);
-
- %feature("docstring",
- "
- Returns maximum buffer capacity set during initialisation.
-
- Returns:
- int: maximum buffer capacity.
- ") capacity;
- size_t capacity() const;
+ Buffer(const Device &device, const size_t size);
%feature("docstring",
"
@@ -255,32 +246,6 @@ public:
%feature("docstring",
"
- Sets a size of the memory buffer for the device.
-
- 'offset + size' must not exceed the capacity of the buffer.
- Does not change the size of the mapped region.
-
- Issues ETHOSU_IOCTL_BUFFER_SET I/O request with a given size and offset.
-
- Args:
- size (int): Device buffer size.
- offset (int): Offset to where the data starts.
- ") resize;
- void resize(size_t size, size_t offset = 0) const;
-
- %feature("docstring",
- "
- Queries device and returns buffer data offset.
-
- Issues ETHOSU_IOCTL_BUFFER_GET I/O request.
-
- Returns:
- int: data offset
- ") offset;
- size_t offset() const;
-
- %feature("docstring",
- "
Queries device and returns buffer data size.
Issues ETHOSU_IOCTL_BUFFER_GET I/O request.
@@ -313,7 +278,6 @@ public:
stream.seekg(0, std::ios_base::beg);
auto buffer = new EthosU::Buffer(device, size);
- buffer->resize(size);
stream.read(buffer->data(), size);
return buffer;
@@ -324,7 +288,6 @@ public:
Fills the buffer from python buffer.
Copies python buffer data to the mapped memory region.
- Input buffer size must be within `Buffer` maximum capacity.
Args:
buffer: data to be copied to the mapped memory.
@@ -332,7 +295,6 @@ public:
") from_buffer;
%mutable_buffer(char* buffer, size_t size);
void from_buffer(char* buffer, size_t size) {
- self->resize(size);
char* data = $self->data();
std::memcpy(data, buffer, size);
}