aboutsummaryrefslogtreecommitdiff
path: root/driver_library/python/src/ethosu_driver/swig/standard_header.i
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-09-30 16:42:50 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2022-10-25 16:36:45 +0000
commitf9efe0ddf865c55d28bcaa203fefffa94bf09b42 (patch)
tree928da5f68dafd7e5a0dee05a75f2f6fcd52df170 /driver_library/python/src/ethosu_driver/swig/standard_header.i
parent569aa558f5e7638852a928feede1f21e7323f664 (diff)
downloadethos-u-linux-driver-stack-f9efe0ddf865c55d28bcaa203fefffa94bf09b42.tar.gz
Added Python interface for Arm Ethos-U NPU driver library.22.11-rc1
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>
Diffstat (limited to 'driver_library/python/src/ethosu_driver/swig/standard_header.i')
-rw-r--r--driver_library/python/src/ethosu_driver/swig/standard_header.i50
1 files changed, 50 insertions, 0 deletions
diff --git a/driver_library/python/src/ethosu_driver/swig/standard_header.i b/driver_library/python/src/ethosu_driver/swig/standard_header.i
new file mode 100644
index 0000000..03cf015
--- /dev/null
+++ b/driver_library/python/src/ethosu_driver/swig/standard_header.i
@@ -0,0 +1,50 @@
+//
+// SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+// SPDX-License-Identifier: Apache-2.0
+//
+%include "stl.i"
+%include "cstring.i"
+%include "std_string.i"
+%include "std_vector.i"
+%include "std_unordered_set.i"
+%include "std_pair.i"
+%include "stdint.i"
+%include "carrays.i"
+%include "exception.i"
+%include "typemaps.i"
+%include "std_iostream.i"
+%include "std_shared_ptr.i"
+
+%ignore *::operator=;
+%ignore *::operator[];
+
+
+// Define exception typemap to wrap exception into python exception.
+
+%exception{
+ try {
+ $action
+ } catch (const EthosU::Exception& e) {
+ SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.what()));
+ }
+};
+
+%exception __getitem__ {
+ try {
+ $action
+ } catch (const std::out_of_range &e) {
+ SWIG_exception(SWIG_IndexError, const_cast<char*>(e.what()));
+ } catch (const std::exception &e) {
+ SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.what()));
+ }
+};
+
+%exception __setitem__ {
+ try {
+ $action
+ } catch (const std::out_of_range &e) {
+ SWIG_exception(SWIG_IndexError, const_cast<char*>(e.what()));
+ } catch (const std::exception &e) {
+ SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.what()));
+ }
+};