blob: 01e255deaa7d8d19a8f55c0bd7c9fa44e94867ef [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
15#include <backendsCommon/WorkloadDataFwd.hpp>
telsoa014fcda012018-03-09 14:13:49 +000016
17#include <memory>
18#include <set>
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000019#include <string>
20#include <vector>
telsoa014fcda012018-03-09 14:13:49 +000021
22#include <boost/assert.hpp>
23
telsoa014fcda012018-03-09 14:13:49 +000024namespace armnn
25{
26
27class ITensorHandle;
28class IWorkloadFactory;
29class OutputSlot;
30class WorkloadDataCollector;
31
32class OutputHandler
33{
34public:
telsoa01c577f2c2018-08-31 09:22:23 +010035 /// @brief - Sets the TensorInfo used by this output handler.
36 /// @param tensorInfo - TensorInfo for the output.
telsoa014fcda012018-03-09 14:13:49 +000037 void SetTensorInfo(const TensorInfo& tensorInfo);
38
Derek Lamberti84da38b2019-06-13 11:40:08 +010039 /// @brief - Creates tensor handles used by the intermediate tensors. Does not allocate memory.
telsoa01c577f2c2018-08-31 09:22:23 +010040 /// @param factory - Factory to be used for handler creation.
telsoa014fcda012018-03-09 14:13:49 +000041 void CreateTensorHandles(const IWorkloadFactory& factory);
Derek Lamberti84da38b2019-06-13 11:40:08 +010042 void CreateTensorHandles(const ITensorHandleFactory& factory);
Francis Murtagh351d13d2018-09-24 15:01:18 +010043
telsoa01c577f2c2018-08-31 09:22:23 +010044 /// @brief - Gets the matching TensorInfo for the output.
45 /// @return - References to the output TensorInfo.
telsoa014fcda012018-03-09 14:13:49 +000046 const TensorInfo& GetTensorInfo() const { return m_TensorInfo; }
47
telsoa01c577f2c2018-08-31 09:22:23 +010048 /// @brief - Gets the allocated tensor memory.
49 /// @return - Pointer to the tensor memory.
telsoa014fcda012018-03-09 14:13:49 +000050 ITensorHandle* GetData() const { return m_TensorHandle.get(); }
51
telsoa01c577f2c2018-08-31 09:22:23 +010052 /// Fill the outputs for a given queue descriptor.
telsoa014fcda012018-03-09 14:13:49 +000053 void CollectWorkloadOutputs(WorkloadDataCollector& dataCollector) const;
54
55 void SetData(std::unique_ptr<ITensorHandle> data) { m_TensorHandle = std::move(data); }
56
telsoa014fcda012018-03-09 14:13:49 +000057 /// @brief Returns true if SetTensorInfo() has been called at least once on this.
58 bool IsTensorInfoSet() const { return m_bTensorInfoSet; }
59private:
60 std::unique_ptr<ITensorHandle> m_TensorHandle;
61 TensorInfo m_TensorInfo;
62 bool m_bTensorInfoSet = false;
63};
64
65} //namespace armnn