aboutsummaryrefslogtreecommitdiff
path: root/tests/run_inference_test.cpp
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 /tests/run_inference_test.cpp
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 'tests/run_inference_test.cpp')
-rw-r--r--tests/run_inference_test.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/run_inference_test.cpp b/tests/run_inference_test.cpp
index 6075d7a..6b17ac2 100644
--- a/tests/run_inference_test.cpp
+++ b/tests/run_inference_test.cpp
@@ -19,6 +19,7 @@
#include <uapi/ethosu.h>
#include <cstring>
+#include <errno.h>
#include <iostream>
#include <list>
#include <memory>
@@ -69,6 +70,36 @@ void testCapabilties(const Device &device) {
TEST_ASSERT(capabilities.hwId.architecture > SemanticVersion());
}
+void testBufferSeek(const Device &device) {
+ try {
+ Buffer buf{device, 1024};
+
+ // SEEK_END should return the size of the buffer
+ TEST_ASSERT(lseek(buf.getFd(), 0, SEEK_END) == 1024);
+
+ // SEEK_SET is supported when moving the file pointer to the start
+ TEST_ASSERT(lseek(buf.getFd(), 0, SEEK_SET) == 0);
+
+ // SEEK_CUR is not supported
+ errno = 0;
+ TEST_ASSERT(lseek(buf.getFd(), 0, SEEK_CUR) == -1);
+ TEST_ASSERT(errno == EINVAL);
+
+ // Non-zero offset is not supported
+ errno = 0;
+ TEST_ASSERT(lseek(buf.getFd(), 1, SEEK_CUR) == -1);
+ TEST_ASSERT(errno == EINVAL);
+
+ errno = 0;
+ TEST_ASSERT(lseek(buf.getFd(), 2, SEEK_END) == -1);
+ TEST_ASSERT(errno == EINVAL);
+
+ errno = 0;
+ TEST_ASSERT(lseek(buf.getFd(), 3, SEEK_SET) == -1);
+ TEST_ASSERT(errno == EINVAL);
+ } catch (std::exception &e) { throw TestFailureException("Buffer seek test: ", e.what()); }
+}
+
void testNetworkInfoNotExistentIndex(const Device &device) {
try {
Network(device, 0);
@@ -81,7 +112,6 @@ void testNetworkInfoNotExistentIndex(const Device &device) {
void testNetworkInfoBuffer(const Device &device) {
try {
std::shared_ptr<Buffer> buffer = std::make_shared<Buffer>(device, sizeof(networkModelData));
- buffer->resize(sizeof(networkModelData));
std::memcpy(buffer->data(), networkModelData, sizeof(networkModelData));
Network network(device, buffer);
@@ -93,7 +123,6 @@ void testNetworkInfoBuffer(const Device &device) {
void testNetworkInfoUnparsableBuffer(const Device &device) {
try {
auto buffer = std::make_shared<Buffer>(device, sizeof(networkModelData) / 4);
- buffer->resize(sizeof(networkModelData) / 4);
std::memcpy(buffer->data(), networkModelData + sizeof(networkModelData) / 4, sizeof(networkModelData) / 4);
try {
@@ -122,7 +151,6 @@ void testNetworkInvalidType(const Device &device) {
void testRunInferenceBuffer(const Device &device) {
try {
auto networkBuffer = std::make_shared<Buffer>(device, sizeof(networkModelData));
- networkBuffer->resize(sizeof(networkModelData));
std::memcpy(networkBuffer->data(), networkModelData, sizeof(networkModelData));
auto network = std::make_shared<Network>(device, networkBuffer);
@@ -130,7 +158,6 @@ void testRunInferenceBuffer(const Device &device) {
std::vector<std::shared_ptr<Buffer>> outputBuffers;
auto inputBuffer = std::make_shared<Buffer>(device, sizeof(inputData));
- inputBuffer->resize(sizeof(inputData));
std::memcpy(inputBuffer->data(), inputData, sizeof(inputData));
inputBuffers.push_back(inputBuffer);
@@ -168,6 +195,7 @@ int main() {
testPing(device);
testDriverVersion(device);
testCapabilties(device);
+ testBufferSeek(device);
testNetworkInvalidType(device);
testNetworkInfoNotExistentIndex(device);
testNetworkInfoBuffer(device);