aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJan Eilers <jan.eilers@arm.com>2021-09-24 15:45:46 +0100
committerJan Eilers <jan.eilers@arm.com>2021-10-02 16:27:39 +0100
commit1b2654fb799c3d25ffcef4d31b5d026d359e2f8f (patch)
tree0397fdf24f286715e26a0e63bddaa0502f64caf7 /python
parentb63a31170aee1d28267d83a4bc67b57708fb6b05 (diff)
downloadarmnn-1b2654fb799c3d25ffcef4d31b5d026d359e2f8f.tar.gz
IVGCVSW-5985 Remove deprecated code
* Removes deprecated AddLayer, IsLayerSupported functions * Marks the whole LayerVisitor class as deprecated not just the constructor. This required to wrap all Accept functions in a no deprecate macro because the LayerVisitor is used as a parameter in there * Removes usage of deprecated LayerVisitor and replaces it with ExecuteStrategy. This required a few structural changes in the unit tests * Adds a default implementation for IStrategy called StrategyBase * Changes pyarmnn to use non deprecated constructor for INetworkProperties and adds related unit test * Marks usage of deprecated code in pyarmnn as deprecated. This required to extend INetworkProperties to allow backwards compatibility * Removes deprecated functions from CpuAcc, GpuAcc and Ref backends Note: This patch breaks compatibility with backends that are not updated in this patch !android-nn-driver:6325 Signed-off-by: Jan Eilers <jan.eilers@arm.com> Change-Id: Id13b6f37a74d26eadeda2da1dc92915e725ed5a5
Diffstat (limited to 'python')
-rw-r--r--python/pyarmnn/README.md6
-rw-r--r--python/pyarmnn/src/pyarmnn/__init__.py4
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/armnn_deserializer.i1
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/armnn_tfliteparser.i1
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i1
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i5
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/modules/armnn_runtime.i55
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/modules/armnn_types.i4
-rw-r--r--python/pyarmnn/test/test_runtime.py25
9 files changed, 82 insertions, 20 deletions
diff --git a/python/pyarmnn/README.md b/python/pyarmnn/README.md
index 0c88cccac8..ae263463da 100644
--- a/python/pyarmnn/README.md
+++ b/python/pyarmnn/README.md
@@ -72,9 +72,9 @@ PyArmNN can also be built using the provided python scripts only. The advantage
*ARMNN_INCLUDE* and *ARMNN_LIB* are mandatory and should point to Arm NN includes and libraries against which you will be generating the wrappers. *SWIG_EXECUTABLE* should only be set if you have multiple versions of SWIG installed or you used a custom location for your installation:
```bash
-$ export SWIG_EXECUTABLE=<path_to_swig>
-$ export ARMNN_INCLUDE=<path_to_armnn_include>
-$ export ARMNN_LIB=<path_to_armnn_libraries>
+$ export SWIG_EXECUTABLE=/full/path/to/swig/executable
+$ export ARMNN_INCLUDE=/full/path/to/armnn/include:/full/path/to/armnn/profiling/common/include
+$ export ARMNN_LIB=/path/to/libs
```
##### 2. Clean and build SWIG wrappers:
diff --git a/python/pyarmnn/src/pyarmnn/__init__.py b/python/pyarmnn/src/pyarmnn/__init__.py
index 5cb8bfb6cd..13fdf95c6f 100644
--- a/python/pyarmnn/src/pyarmnn/__init__.py
+++ b/python/pyarmnn/src/pyarmnn/__init__.py
@@ -67,6 +67,10 @@ from ._generated.pyarmnn import IProfiler
from ._generated.pyarmnn import DataType_Float16, DataType_Float32, DataType_QAsymmU8, DataType_Signed32, \
DataType_Boolean, DataType_QSymmS16, DataType_QSymmS8, DataType_QAsymmS8
from ._generated.pyarmnn import DataLayout_NCHW, DataLayout_NHWC
+from ._generated.pyarmnn import MemorySource_Malloc, MemorySource_Undefined, MemorySource_DmaBuf, \
+ MemorySource_DmaBufProtected
+from ._generated.pyarmnn import ProfilingDetailsMethod_Undefined, ProfilingDetailsMethod_DetailsWithEvents, \
+ ProfilingDetailsMethod_DetailsOnly
from ._generated.pyarmnn import ActivationFunction_Abs, ActivationFunction_BoundedReLu, ActivationFunction_LeakyReLu, \
ActivationFunction_Linear, ActivationFunction_ReLu, ActivationFunction_Sigmoid, ActivationFunction_SoftReLu, \
diff --git a/python/pyarmnn/src/pyarmnn/swig/armnn_deserializer.i b/python/pyarmnn/src/pyarmnn/swig/armnn_deserializer.i
index 073fadaba9..bc8228a5eb 100644
--- a/python/pyarmnn/src/pyarmnn/swig/armnn_deserializer.i
+++ b/python/pyarmnn/src/pyarmnn/swig/armnn_deserializer.i
@@ -6,7 +6,6 @@
%{
#include "armnnDeserializer/IDeserializer.hpp"
#include "armnn/Types.hpp"
-#include "ProfilingGuid.hpp"
#include "armnn/INetwork.hpp"
#include "armnn/Exceptions.hpp"
#include <string>
diff --git a/python/pyarmnn/src/pyarmnn/swig/armnn_tfliteparser.i b/python/pyarmnn/src/pyarmnn/swig/armnn_tfliteparser.i
index d2d79cc627..3ed5d6b8fd 100644
--- a/python/pyarmnn/src/pyarmnn/swig/armnn_tfliteparser.i
+++ b/python/pyarmnn/src/pyarmnn/swig/armnn_tfliteparser.i
@@ -6,7 +6,6 @@
%{
#include "armnnTfLiteParser/ITfLiteParser.hpp"
#include "armnn/Types.hpp"
-#include "ProfilingGuid.hpp"
#include "armnn/INetwork.hpp"
%}
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
index 00b835bfb3..a050722bb9 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
@@ -5,7 +5,6 @@
%{
#include "armnn/Descriptors.hpp"
#include "armnn/Types.hpp"
-#include "ProfilingGuid.hpp"
%}
namespace std {
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
index 7dc88ac176..f4581ca5ec 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
@@ -6,7 +6,6 @@
#include "armnn/INetwork.hpp"
#include "armnn/BackendId.hpp"
#include "armnn/Types.hpp"
-#include "ProfilingGuid.hpp"
#include "armnn/Optional.hpp"
#include <fstream>
%}
@@ -989,7 +988,7 @@ public:
const armnn::ConstTensor& weights,
armnn::ConstTensor* biases = nullptr,
const char* name = nullptr) {
-
+ ARMNN_NO_DEPRECATE_WARN_BEGIN
if (biases) {
return $self->AddFullyConnectedLayer(fullyConnectedDescriptor, weights,
armnn::Optional<armnn::ConstTensor>(*biases), name);
@@ -997,7 +996,7 @@ public:
return $self->AddFullyConnectedLayer(fullyConnectedDescriptor, weights,
armnn::Optional<armnn::ConstTensor>(), name);
}
-
+ ARMNN_NO_DEPRECATE_WARN_END
}
%feature("docstring",
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_runtime.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_runtime.i
index ec65cc010a..e56464dd2f 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_runtime.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_runtime.i
@@ -4,6 +4,7 @@
//
%{
#include "armnn/IRuntime.hpp"
+#include "armnn/Deprecated.hpp"
#include <iostream>
#include <ostream>
#include <sstream>
@@ -97,25 +98,43 @@ struct CreationOptions
ExternalProfilingOptions m_ProfilingOptions;
};
+%{
+typedef armnn::INetworkProperties INetworkProperties;
+%}
+
namespace armnn
{
+%nodefaultctor INetworkProperties;
struct INetworkProperties
{
%feature("docstring",
- "
+ "
Structure for holding network properties.
Contains:
- m_ImportEnabled (bool): Enable import.
-
- m_ExportEnabled (bool): Enable export.
+ m_AsyncEnabled (bool): Enable asynchronous execution of multiple network.
+ m_InputSource (MemorySource): When inputs are imported this defines the type of the imported memory.
+ m_OutputSource (MemorySource): When outputs are imported this defines the type of the imported memory.
+ m_ProfilingEnabled (bool): Enable profiling.
+ ProfilingDetailsMethod (ProfilingDetailsMethod): Customize profiling details.
") INetworkProperties;
- INetworkProperties(bool importEnabled = false, bool exportEnabled = false);
+ INetworkProperties(bool asyncEnabled,
+ MemorySource inputSource,
+ MemorySource outputSource,
+ bool profilingEnabled = false,
+ ProfilingDetailsMethod detailsMethod = ProfilingDetailsMethod::Undefined);
+
+
+ const bool m_AsyncEnabled;
+
+ const bool m_ProfilingEnabled;
+
+ const ProfilingDetailsMethod m_OutputNetworkDetailsMethod;
- const bool m_ImportEnabled;
- const bool m_ExportEnabled;
+ const MemorySource m_InputSource;
+ const MemorySource m_OutputSource;
};
%feature("docstring",
@@ -293,5 +312,27 @@ public:
}
+%extend INetworkProperties {
+ %feature("docstring",
+ "
+ Structure for holding network properties.
+
+ Contains:
+ m_ImportEnabled (bool): Enable import.
+
+ m_ExportEnabled (bool): Enable export.
+
+ ") INetworkProperties;
+ INetworkProperties(bool importEnabled = false, bool exportEnabled = false) {
+ ARMNN_NO_DEPRECATE_WARN_BEGIN
+ return new INetworkProperties(importEnabled, exportEnabled);
+ ARMNN_NO_DEPRECATE_WARN_END
+ }
+ %pythonprepend INetworkProperties(bool, bool) %{
+ import warnings
+ warnings.warn("Deprecated: Use constructor with MemorySource argument instead.", DeprecationWarning)
+ %}
+}
+
}
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_types.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_types.i
index b838fce53d..83da4558fb 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_types.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_types.i
@@ -4,12 +4,10 @@
//
%{
#include "armnn/Types.hpp"
-#include "ProfilingGuid.hpp"
%}
%include <typemaps/permutation_vector.i>
-
namespace armnn
{
@@ -106,12 +104,10 @@ Returns:
") GetSupportedBackends;
-%ignore ProfilingGuid;
%ignore PermutationVector;
#define ARMNN_DEPRECATED_ENUM // SWIG does not support C++ attributes, need this to help generate from Deprecated.hpp.
#define ARMNN_DEPRECATED_ENUM_MSG(message) // SWIG does not support C++ attributes, need this to help generate from Deprecated.hpp.
%include "armnn/Types.hpp"
-%include "ProfilingGuid.hpp"
diff --git a/python/pyarmnn/test/test_runtime.py b/python/pyarmnn/test/test_runtime.py
index ff0ad40b55..295c870370 100644
--- a/python/pyarmnn/test/test_runtime.py
+++ b/python/pyarmnn/test/test_runtime.py
@@ -3,6 +3,7 @@
import os
import pytest
+import warnings
import numpy as np
import pyarmnn as ann
@@ -156,6 +157,30 @@ def test_load_network_properties_provided(random_runtime):
assert "" == messages
assert net_id == 0
+def test_network_properties_constructor(random_runtime):
+ preferred_backends = random_runtime[0]
+ network = random_runtime[1]
+ runtime = random_runtime[2]
+
+ opt_network, _ = ann.Optimize(network, preferred_backends,
+ runtime.GetDeviceSpec(), ann.OptimizerOptions())
+
+ inputSource = ann.MemorySource_Undefined
+ outputSource = ann.MemorySource_Undefined
+ properties = ann.INetworkProperties(True, inputSource, outputSource)
+ assert properties.m_AsyncEnabled == True
+ assert properties.m_ProfilingEnabled == False
+ assert properties.m_OutputNetworkDetailsMethod == ann.ProfilingDetailsMethod_Undefined
+ assert properties.m_InputSource == ann.MemorySource_Undefined
+ assert properties.m_OutputSource == ann.MemorySource_Undefined
+
+ net_id, messages = runtime.LoadNetwork(opt_network, properties)
+ assert "" == messages
+ assert net_id == 0
+
+def test_network_properties_deprecated_constructor():
+ with pytest.warns(DeprecationWarning):
+ warnings.warn("Deprecated: Use constructor with MemorySource argument instead.", DeprecationWarning)
def test_unload_network_fails_for_invalid_net_id(random_runtime):
preferred_backends = random_runtime[0]