From 5307bc10ac488261e84ac76b2dede6039ea3fe96 Mon Sep 17 00:00:00 2001 From: telsoa01 Date: Fri, 9 Mar 2018 13:51:08 +0000 Subject: Release 18.02 Change-Id: I41a89c149534a7c354a58e2c66a32cba572fc0c1 --- ArmnnPreparedModel.hpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 ArmnnPreparedModel.hpp (limited to 'ArmnnPreparedModel.hpp') diff --git a/ArmnnPreparedModel.hpp b/ArmnnPreparedModel.hpp new file mode 100644 index 00000000..f61d56ce --- /dev/null +++ b/ArmnnPreparedModel.hpp @@ -0,0 +1,83 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#pragma once + +#include "RequestThread.hpp" + +#include "HalInterfaces.h" +#include "NeuralNetworks.h" +#include + +#include +#include + +namespace armnn_driver +{ + +class ArmnnPreparedModel : public IPreparedModel +{ +public: + ArmnnPreparedModel(armnn::NetworkId networkId, + armnn::IRuntime* runtime, + const Model& model, + const std::string& requestInputsAndOutputsDumpDir); + + virtual ~ArmnnPreparedModel(); + + virtual Return execute(const Request& request, + const ::android::sp& callback) override; + + /// execute the graph prepared from the request + void ExecuteGraph(std::shared_ptr>& pMemPools, + std::shared_ptr& pInputTensors, + std::shared_ptr& pOutputTensors, + const ::android::sp& callback); + + /// Executes this model with dummy inputs (e.g. all zeroes). + void ExecuteWithDummyInputs(); + +private: + + template + void DumpTensorsIfRequired(char const* tensorNamePrefix, const TensorBindingCollection& tensorBindings); + + armnn::NetworkId m_NetworkId; + armnn::IRuntime* m_Runtime; + 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 m_RequestThread; + uint32_t m_RequestCount; + const std::string& m_RequestInputsAndOutputsDumpDir; +}; + +class AndroidNnCpuExecutorPreparedModel : public IPreparedModel +{ +public: + + AndroidNnCpuExecutorPreparedModel(const Model& model, const std::string& requestInputsAndOutputsDumpDir); + virtual ~AndroidNnCpuExecutorPreparedModel() { } + + bool Initialize(); + + virtual Return execute(const Request& request, + const ::android::sp& callback) override; + +private: + + void DumpTensorsIfRequired( + char const* tensorNamePrefix, + const hidl_vec& operandIndices, + const hidl_vec& requestArgs, + const std::vector& requestPoolInfos); + + Model m_Model; + std::vector m_ModelPoolInfos; + const std::string& m_RequestInputsAndOutputsDumpDir; + uint32_t m_RequestCount; +}; + +} -- cgit v1.2.1