aboutsummaryrefslogtreecommitdiff
path: root/delegate/opaque/src
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2023-03-16 17:01:56 +0000
committerFrancis Murtagh <francis.murtagh@arm.com>2023-03-31 13:44:19 +0100
commitc4fb0dd4145e05123c546458ba5d281abfcc2b28 (patch)
treef4c6aebaaf4055ff1109a8e963c559aa7ba69945 /delegate/opaque/src
parent6d4e761f12b0ec34294bae1bfafacd8f468e7e0e (diff)
downloadarmnn-c4fb0dd4145e05123c546458ba5d281abfcc2b28.tar.gz
IVGCVSW-7556 Introduce Opaque Delegate API
* Also added cmake for the new layers to reduce merge conflicts. Signed-off-by: Francis Murtagh <francis.murtagh@arm.com> Change-Id: Ieb59aa2b7e2a18c57c9357b8d5b5cd63d8211c85
Diffstat (limited to 'delegate/opaque/src')
-rw-r--r--delegate/opaque/src/Activation.hpp4
-rw-r--r--delegate/opaque/src/ArgMinMax.hpp4
-rw-r--r--delegate/opaque/src/BatchMatMul.hpp4
-rw-r--r--delegate/opaque/src/BatchSpace.hpp4
-rw-r--r--delegate/opaque/src/Comparison.hpp4
-rw-r--r--delegate/opaque/src/Control.hpp4
-rw-r--r--delegate/opaque/src/Convolution.hpp4
-rw-r--r--delegate/opaque/src/ElementwiseBinary.hpp4
-rw-r--r--delegate/opaque/src/ElementwiseUnary.hpp4
-rw-r--r--delegate/opaque/src/Fill.hpp4
-rw-r--r--delegate/opaque/src/FullyConnected.hpp4
-rw-r--r--delegate/opaque/src/Gather.hpp4
-rw-r--r--delegate/opaque/src/GatherNd.hpp4
-rw-r--r--delegate/opaque/src/LogicalBinary.hpp4
-rw-r--r--delegate/opaque/src/Lstm.hpp4
-rw-r--r--delegate/opaque/src/MultiLayerFacade.hpp4
-rw-r--r--delegate/opaque/src/Normalization.hpp4
-rw-r--r--delegate/opaque/src/Pack.hpp4
-rw-r--r--delegate/opaque/src/Pad.hpp4
-rw-r--r--delegate/opaque/src/Pooling.hpp4
-rw-r--r--delegate/opaque/src/Prelu.hpp4
-rw-r--r--delegate/opaque/src/Quantization.hpp4
-rw-r--r--delegate/opaque/src/Redefine.hpp4
-rw-r--r--delegate/opaque/src/Reduce.hpp4
-rw-r--r--delegate/opaque/src/Resize.hpp4
-rw-r--r--delegate/opaque/src/Round.hpp4
-rw-r--r--delegate/opaque/src/Shape.hpp4
-rw-r--r--delegate/opaque/src/Slice.hpp4
-rw-r--r--delegate/opaque/src/Softmax.hpp4
-rw-r--r--delegate/opaque/src/SpaceDepth.hpp4
-rw-r--r--delegate/opaque/src/Split.hpp4
-rw-r--r--delegate/opaque/src/StridedSlice.hpp4
-rw-r--r--delegate/opaque/src/Transpose.hpp4
-rw-r--r--delegate/opaque/src/UnidirectionalSequenceLstm.hpp4
-rw-r--r--delegate/opaque/src/Unpack.hpp4
-rw-r--r--delegate/opaque/src/armnn_delegate.cpp136
-rw-r--r--delegate/opaque/src/armnn_external_delegate.cpp4
37 files changed, 280 insertions, 0 deletions
diff --git a/delegate/opaque/src/Activation.hpp b/delegate/opaque/src/Activation.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Activation.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/ArgMinMax.hpp b/delegate/opaque/src/ArgMinMax.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/ArgMinMax.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/BatchMatMul.hpp b/delegate/opaque/src/BatchMatMul.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/BatchMatMul.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/BatchSpace.hpp b/delegate/opaque/src/BatchSpace.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/BatchSpace.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Comparison.hpp b/delegate/opaque/src/Comparison.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Comparison.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Control.hpp b/delegate/opaque/src/Control.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Control.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Convolution.hpp b/delegate/opaque/src/Convolution.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Convolution.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/ElementwiseBinary.hpp b/delegate/opaque/src/ElementwiseBinary.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/ElementwiseBinary.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/ElementwiseUnary.hpp b/delegate/opaque/src/ElementwiseUnary.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/ElementwiseUnary.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Fill.hpp b/delegate/opaque/src/Fill.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Fill.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/FullyConnected.hpp b/delegate/opaque/src/FullyConnected.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/FullyConnected.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Gather.hpp b/delegate/opaque/src/Gather.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Gather.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/GatherNd.hpp b/delegate/opaque/src/GatherNd.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/GatherNd.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/LogicalBinary.hpp b/delegate/opaque/src/LogicalBinary.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/LogicalBinary.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Lstm.hpp b/delegate/opaque/src/Lstm.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Lstm.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/MultiLayerFacade.hpp b/delegate/opaque/src/MultiLayerFacade.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/MultiLayerFacade.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Normalization.hpp b/delegate/opaque/src/Normalization.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Normalization.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Pack.hpp b/delegate/opaque/src/Pack.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Pack.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Pad.hpp b/delegate/opaque/src/Pad.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Pad.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Pooling.hpp b/delegate/opaque/src/Pooling.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Pooling.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Prelu.hpp b/delegate/opaque/src/Prelu.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Prelu.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Quantization.hpp b/delegate/opaque/src/Quantization.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Quantization.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Redefine.hpp b/delegate/opaque/src/Redefine.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Redefine.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Reduce.hpp b/delegate/opaque/src/Reduce.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Reduce.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Resize.hpp b/delegate/opaque/src/Resize.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Resize.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Round.hpp b/delegate/opaque/src/Round.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Round.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Shape.hpp b/delegate/opaque/src/Shape.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Shape.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Slice.hpp b/delegate/opaque/src/Slice.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Slice.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Softmax.hpp b/delegate/opaque/src/Softmax.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Softmax.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/SpaceDepth.hpp b/delegate/opaque/src/SpaceDepth.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/SpaceDepth.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Split.hpp b/delegate/opaque/src/Split.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Split.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/StridedSlice.hpp b/delegate/opaque/src/StridedSlice.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/StridedSlice.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Transpose.hpp b/delegate/opaque/src/Transpose.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Transpose.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/UnidirectionalSequenceLstm.hpp b/delegate/opaque/src/UnidirectionalSequenceLstm.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/UnidirectionalSequenceLstm.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/Unpack.hpp b/delegate/opaque/src/Unpack.hpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/Unpack.hpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
diff --git a/delegate/opaque/src/armnn_delegate.cpp b/delegate/opaque/src/armnn_delegate.cpp
new file mode 100644
index 0000000000..190c386666
--- /dev/null
+++ b/delegate/opaque/src/armnn_delegate.cpp
@@ -0,0 +1,136 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <armnn_delegate.hpp>
+
+#include <Version.hpp>
+
+#include "Activation.hpp"
+#include "ArgMinMax.hpp"
+#include "BatchMatMul.hpp"
+#include "BatchSpace.hpp"
+#include "Comparison.hpp"
+#include "Convolution.hpp"
+#include "Control.hpp"
+#include "ElementwiseBinary.hpp"
+#include "ElementwiseUnary.hpp"
+#include "Fill.hpp"
+#include "FullyConnected.hpp"
+#include "Gather.hpp"
+#include "GatherNd.hpp"
+#include "LogicalBinary.hpp"
+#include "Lstm.hpp"
+#include "Normalization.hpp"
+#include "Pack.hpp"
+#include "Pad.hpp"
+#include "Pooling.hpp"
+#include "Prelu.hpp"
+#include "Quantization.hpp"
+#include "Redefine.hpp"
+#include "Reduce.hpp"
+#include "Resize.hpp"
+#include "Round.hpp"
+#include "Shape.hpp"
+#include "Slice.hpp"
+#include "StridedSlice.hpp"
+#include "Softmax.hpp"
+#include "SpaceDepth.hpp"
+#include "Split.hpp"
+#include "Transpose.hpp"
+#include "UnidirectionalSequenceLstm.hpp"
+#include "Unpack.hpp"
+
+#include <armnn/utility/IgnoreUnused.hpp>
+#include <armnnUtils/Filesystem.hpp>
+#include <armnn/utility/Timer.hpp>
+#include <flatbuffers/flatbuffers.h>
+#include <tensorflow/lite/context_util.h>
+#include <tensorflow/lite/schema/schema_generated.h>
+#include <tensorflow/lite/minimal_logging.h>
+#include <tensorflow/lite/logger.h>
+
+#include <algorithm>
+#include <iostream>
+#include <sstream>
+
+namespace armnnOpaqueDelegate
+{
+
+ArmnnOpaqueDelegate::ArmnnOpaqueDelegate(armnnDelegate::DelegateOptions options)
+ : m_Options(std::move(options))
+{
+ // Configures logging for ARMNN
+ if (m_Options.IsLoggingEnabled())
+ {
+ armnn::ConfigureLogging(true, true, m_Options.GetLoggingSeverity());
+ }
+ // Create/Get the static ArmNN Runtime. Note that the m_Runtime will be shared by all armnn_delegate
+ // instances so the RuntimeOptions cannot be altered for different armnn_delegate instances.
+ m_Runtime = GetRuntime(m_Options.GetRuntimeOptions());
+ std::vector<armnn::BackendId> backends;
+ if (m_Runtime)
+ {
+ const armnn::BackendIdSet supportedDevices = m_Runtime->GetDeviceSpec().GetSupportedBackends();
+ for (auto& backend : m_Options.GetBackends())
+ {
+ if (std::find(supportedDevices.cbegin(), supportedDevices.cend(), backend) == supportedDevices.cend())
+ {
+ TFLITE_LOG_PROD(tflite::TFLITE_LOG_INFO,
+ "TfLiteArmnnDelegate: Requested unknown backend %s", backend.Get().c_str());
+ }
+ else
+ {
+ backends.push_back(backend);
+ }
+ }
+ }
+
+ if (backends.empty())
+ {
+ // No known backend specified
+ throw armnn::InvalidArgumentException("TfLiteArmnnOpaqueDelegate: No known backend specified.");
+ }
+ m_Options.SetBackends(backends);
+
+ TFLITE_LOG_PROD_ONCE(tflite::TFLITE_LOG_INFO, "TfLiteArmnnOpaqueDelegate: Created TfLite ArmNN delegate.");
+}
+
+TfLiteOpaqueDelegate* TfLiteArmnnOpaqueDelegateCreate(const void* settings)
+{
+ // This method will always create Opaque Delegate with default settings until
+ // we have a DelegateOptions Constructor which can parse the void* settings
+ armnn::IgnoreUnused(settings);
+ auto options = TfLiteArmnnDelegateOptionsDefault();
+ auto* armnnDelegate = new ::armnnOpaqueDelegate::ArmnnOpaqueDelegate(options);
+ return TfLiteOpaqueDelegateCreate(armnnDelegate->GetDelegateBuilder());
+}
+
+::armnnDelegate::DelegateOptions TfLiteArmnnDelegateOptionsDefault()
+{
+ ::armnnDelegate::DelegateOptions options(armnn::Compute::CpuRef);
+ return options;
+}
+
+void TfLiteArmnnOpaqueDelegateDelete(TfLiteOpaqueDelegate* tfLiteDelegate)
+{
+ if (tfLiteDelegate != nullptr)
+ {
+ delete static_cast<::armnnOpaqueDelegate::ArmnnOpaqueDelegate*>(TfLiteOpaqueDelegateGetData(tfLiteDelegate));
+ TfLiteOpaqueDelegateDelete(tfLiteDelegate);
+ }
+}
+
+const TfLiteOpaqueDelegatePlugin* GetArmnnDelegatePluginApi()
+{
+ static constexpr TfLiteOpaqueDelegatePlugin armnnPlugin{
+ TfLiteArmnnOpaqueDelegateCreate, TfLiteArmnnOpaqueDelegateDelete, TfLiteArmnnOpaqueDelegateErrno};
+ return &armnnPlugin;
+}
+
+const std::string ArmnnOpaqueDelegate::GetVersion() {
+ return OPAQUE_DELEGATE_VERSION;
+}
+
+} // armnnOpaqueDelegate namespace \ No newline at end of file
diff --git a/delegate/opaque/src/armnn_external_delegate.cpp b/delegate/opaque/src/armnn_external_delegate.cpp
new file mode 100644
index 0000000000..e16969768e
--- /dev/null
+++ b/delegate/opaque/src/armnn_external_delegate.cpp
@@ -0,0 +1,4 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//