From 245d64c60d0ea30f5080ff53225b5169927e24d6 Mon Sep 17 00:00:00 2001 From: Matthew Bentham Date: Mon, 2 Dec 2019 12:59:43 +0000 Subject: Work in progress of python bindings for Arm NN Not built or tested in any way Signed-off-by: Matthew Bentham Change-Id: Ie7f92b529aa5087130f0c5cc8c17db1581373236 --- python/pyarmnn/src/pyarmnn/swig/standard_header.i | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 python/pyarmnn/src/pyarmnn/swig/standard_header.i (limited to 'python/pyarmnn/src/pyarmnn/swig/standard_header.i') diff --git a/python/pyarmnn/src/pyarmnn/swig/standard_header.i b/python/pyarmnn/src/pyarmnn/swig/standard_header.i new file mode 100644 index 0000000000..c412dc3bff --- /dev/null +++ b/python/pyarmnn/src/pyarmnn/swig/standard_header.i @@ -0,0 +1,53 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// +%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" + +%ignore *::operator=; +%ignore *::operator[]; + + +// Define exception typemap to wrap armnn exception into python exception. + +%exception{ + try { + $action + } catch (armnn::Exception &e) { + SWIG_exception(SWIG_RuntimeError, const_cast(e.what())); + } +}; + +%exception __getitem__ { + try { + $action + } catch (armnn::InvalidArgumentException &e) { + SWIG_exception(SWIG_ValueError, const_cast(e.what())); + } catch (const std::out_of_range &e) { + SWIG_exception(SWIG_IndexError, const_cast(e.what())); + } catch (const std::exception &e) { + SWIG_exception(SWIG_RuntimeError, const_cast(e.what())); + } +}; + +%exception __setitem__ { + try { + $action + } catch (armnn::InvalidArgumentException &e) { + SWIG_exception(SWIG_ValueError, const_cast(e.what())); + } catch (const std::out_of_range &e) { + SWIG_exception(SWIG_IndexError, const_cast(e.what())); + } catch (const std::exception &e) { + SWIG_exception(SWIG_RuntimeError, const_cast(e.what())); + } +}; -- cgit v1.2.1