blob: 81768c6f5e3d5c2e3931b5b74239867e4f6b82a6 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#pragma once
6
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00007#include "ITensorHandle.hpp"
Derek Lamberti84da38b2019-06-13 11:40:08 +01008#include "ITensorHandleFactory.hpp"
telsoa014fcda012018-03-09 14:13:49 +00009
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000010#include <armnn/Descriptors.hpp>
11#include <armnn/INetwork.hpp>
12#include <armnn/Tensor.hpp>
13#include <armnn/Types.hpp>
14
telsoa014fcda012018-03-09 14:13:49 +000015#include <memory>
16#include <set>
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000017#include <string>
18#include <vector>
telsoa014fcda012018-03-09 14:13:49 +000019
20#include <boost/assert.hpp>
21
telsoa014fcda012018-03-09 14:13:49 +000022namespace armnn
23{
24
25class ITensorHandle;
26class IWorkloadFactory;
27class OutputSlot;
28class WorkloadDataCollector;
29
30class OutputHandler
31{
32public:
telsoa01c577f2c2018-08-31 09:22:23 +010033 /// @brief - Sets the TensorInfo used by this output handler.
34 /// @param tensorInfo - TensorInfo for the output.
telsoa014fcda012018-03-09 14:13:49 +000035 void SetTensorInfo(const TensorInfo& tensorInfo);
36
Derek Lamberti84da38b2019-06-13 11:40:08 +010037 /// @brief - Creates tensor handles used by the intermediate tensors. Does not allocate memory.
telsoa01c577f2c2018-08-31 09:22:23 +010038 /// @param factory - Factory to be used for handler creation.
David Monahan3fb7e102019-08-20 11:25:29 +010039 void CreateTensorHandles(const IWorkloadFactory& factory, const bool IsMemoryManaged = true);
40 void CreateTensorHandles(const ITensorHandleFactory& factory, const bool IsMemoryManaged = true);
Francis Murtagh351d13d2018-09-24 15:01:18 +010041
telsoa01c577f2c2018-08-31 09:22:23 +010042 /// @brief - Gets the matching TensorInfo for the output.
43 /// @return - References to the output TensorInfo.
telsoa014fcda012018-03-09 14:13:49 +000044 const TensorInfo& GetTensorInfo() const { return m_TensorInfo; }
45
telsoa01c577f2c2018-08-31 09:22:23 +010046 /// @brief - Gets the allocated tensor memory.
47 /// @return - Pointer to the tensor memory.
telsoa014fcda012018-03-09 14:13:49 +000048 ITensorHandle* GetData() const { return m_TensorHandle.get(); }
49
telsoa01c577f2c2018-08-31 09:22:23 +010050 /// Fill the outputs for a given queue descriptor.
telsoa014fcda012018-03-09 14:13:49 +000051 void CollectWorkloadOutputs(WorkloadDataCollector& dataCollector) const;
52
53 void SetData(std::unique_ptr<ITensorHandle> data) { m_TensorHandle = std::move(data); }
54
telsoa014fcda012018-03-09 14:13:49 +000055 /// @brief Returns true if SetTensorInfo() has been called at least once on this.
56 bool IsTensorInfoSet() const { return m_bTensorInfoSet; }
57private:
58 std::unique_ptr<ITensorHandle> m_TensorHandle;
59 TensorInfo m_TensorInfo;
60 bool m_bTensorInfoSet = false;
61};
62
63} //namespace armnn