Added Python interface for Arm Ethos-U NPU driver library.

Python `ethosu_driver` could be built as part of Arm Ethos-U Linux
driver library CMake flow.

See driver_library/python/README.md for more details.

Change-Id: I177a890add5c13df9a839f4f43621f972afe5ab1
Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
diff --git a/driver_library/python/src/ethosu_driver/swig/typemaps/buffer.i b/driver_library/python/src/ethosu_driver/swig/typemaps/buffer.i
new file mode 100644
index 0000000..13b7909
--- /dev/null
+++ b/driver_library/python/src/ethosu_driver/swig/typemaps/buffer.i
@@ -0,0 +1,42 @@
+//
+// SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+// SPDX-License-Identifier: Apache-2.0
+//
+%define %mutable_buffer(TYPEMAP, SIZE)
+    %typemap(in) (TYPEMAP, SIZE) {
+      int res; void *buf = 0; size_t size = 0;
+      Py_buffer view;
+      res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE);
+      buf = view.buf;
+      size = view.len;
+      PyBuffer_Release(&view);
+      if (res < 0) {
+        PyErr_Clear();
+        %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+      }
+      $1 = ($1_ltype) buf;
+      $2 = ($2_ltype) size;
+    }
+
+    %typemap(typecheck) (TYPEMAP, SIZE) {
+        $1 = PyObject_CheckBuffer($input) || PyTuple_Check($input) ? 1 : 0;
+    }
+%enddef
+
+%define %clear_mutable_buffer(TYPEMAP, SIZE)
+    %typemap(in) (TYPEMAP, SIZE);
+    %typemap(typecheck) (TYPEMAP, SIZE);
+%enddef
+
+
+%define %driver_buffer_out
+    %typemap(out) (char*) {
+        auto size = arg1->size();
+        int readOnly = 0;
+        $result = PyMemoryView_FromMemory($1, size, readOnly);
+    }
+%enddef
+
+%define %clear_driver_buffer_out
+    %typemap(out) (char*);
+%enddef