aboutsummaryrefslogtreecommitdiff
path: root/ArmnnPreparedModel_1_2.hpp
diff options
context:
space:
mode:
authorMike Kelly <mike.kelly@arm.com>2019-06-11 16:35:25 +0100
committerMike Kelly <mike.kelly@arm.com>2019-06-11 16:35:25 +0100
commitb5fdf38f0c6596958fab2b84882f2792a31e585a (patch)
treed6b578b51c1923c759653d8a04efa90923ad4dd8 /ArmnnPreparedModel_1_2.hpp
parentb92f8901fc34749337ea7a9ad7a2717fc9490de5 (diff)
downloadandroid-nn-driver-b5fdf38f0c6596958fab2b84882f2792a31e585a.tar.gz
IVGCVSW-3181 Add HAL 1.2 support to android-nn-driver
* Updated Android.mk to build HAL 1.2 driver * Added 1.2 HalPolicy and ArmnnDriver * Added 1.2 ArmnnPreparedModel * Updated converters and utilities to accept new HAL 1.2 operands and operand types. Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Signed-off-by: Mike Kelly <mike.kelly@arm.com> Change-Id: I62856deab24e106f72cccce09468db4971756fa6
Diffstat (limited to 'ArmnnPreparedModel_1_2.hpp')
-rw-r--r--ArmnnPreparedModel_1_2.hpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/ArmnnPreparedModel_1_2.hpp b/ArmnnPreparedModel_1_2.hpp
new file mode 100644
index 00000000..4e883b6b
--- /dev/null
+++ b/ArmnnPreparedModel_1_2.hpp
@@ -0,0 +1,80 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "ArmnnDriver.hpp"
+#include "ArmnnDriverImpl.hpp"
+#include "RequestThread.hpp"
+#include "ModelToINetworkConverter.hpp"
+
+#include <NeuralNetworks.h>
+#include <armnn/ArmNN.hpp>
+
+#include <string>
+#include <vector>
+
+namespace armnn_driver
+{
+
+template <typename HalVersion>
+class ArmnnPreparedModel_1_2 : public V1_2::IPreparedModel
+{
+public:
+ using HalModel = typename V1_2::Model;
+
+ ArmnnPreparedModel_1_2(armnn::NetworkId networkId,
+ armnn::IRuntime* runtime,
+ const HalModel& model,
+ const std::string& requestInputsAndOutputsDumpDir,
+ const bool gpuProfilingEnabled);
+
+ virtual ~ArmnnPreparedModel_1_2();
+
+ virtual Return<ErrorStatus> execute(const Request& request,
+ const ::android::sp<V1_0::IExecutionCallback>& callback) override;
+
+ virtual Return<ErrorStatus> execute_1_2(const Request& request, MeasureTiming measure,
+ const sp<V1_2::IExecutionCallback>& callback) override;
+
+ virtual Return<void> executeSynchronously(const Request &request,
+ MeasureTiming measure,
+ V1_2::IPreparedModel::executeSynchronously_cb cb) override;
+
+ virtual Return<void> configureExecutionBurst(
+ const sp<V1_2::IBurstCallback>& callback,
+ const android::hardware::MQDescriptorSync<V1_2::FmqRequestDatum>& requestChannel,
+ const android::hardware::MQDescriptorSync<V1_2::FmqResultDatum>& resultChannel,
+ configureExecutionBurst_cb cb) override;
+
+ /// execute the graph prepared from the request
+ void ExecuteGraph(std::shared_ptr<std::vector<::android::nn::RunTimePoolInfo>>& pMemPools,
+ std::shared_ptr<armnn::InputTensors>& pInputTensors,
+ std::shared_ptr<armnn::OutputTensors>& pOutputTensors,
+ const ::android::sp<V1_0::IExecutionCallback>& callback);
+
+ /// Executes this model with dummy inputs (e.g. all zeroes).
+ /// \return false on failure, otherwise true
+ bool ExecuteWithDummyInputs();
+
+private:
+ template <typename ExecutionCallback>
+ Return <ErrorStatus> Execute(const Request &request, const sp <ExecutionCallback> &callback);
+
+ template <typename TensorBindingCollection>
+ void DumpTensorsIfRequired(char const* tensorNamePrefix, const TensorBindingCollection& tensorBindings);
+
+ armnn::NetworkId m_NetworkId;
+ armnn::IRuntime* m_Runtime;
+ V1_2::Model m_Model;
+ // There must be a single RequestThread for all ArmnnPreparedModel objects to ensure serial execution of workloads
+ // It is specific to this class, so it is declared as static here
+ static RequestThread<ArmnnPreparedModel_1_2, HalVersion> m_RequestThread;
+ uint32_t m_RequestCount;
+ const std::string& m_RequestInputsAndOutputsDumpDir;
+ const bool m_GpuProfilingEnabled;
+};
+
+}