blob: 240b369fabd5a2f85f7e08fc782397a666876eb2 [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"
telsoa014fcda012018-03-09 14:13:49 +00008
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00009#include <armnn/Descriptors.hpp>
10#include <armnn/INetwork.hpp>
11#include <armnn/Tensor.hpp>
12#include <armnn/Types.hpp>
13
14#include <backendsCommon/WorkloadDataFwd.hpp>
telsoa014fcda012018-03-09 14:13:49 +000015
16#include <memory>
17#include <set>
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000018#include <string>
19#include <vector>
telsoa014fcda012018-03-09 14:13:49 +000020
21#include <boost/assert.hpp>
22
telsoa014fcda012018-03-09 14:13:49 +000023namespace armnn
24{
25
26class ITensorHandle;
27class IWorkloadFactory;
28class OutputSlot;
29class WorkloadDataCollector;
30
31class OutputHandler
32{
33public:
telsoa01c577f2c2018-08-31 09:22:23 +010034 /// @brief - Sets the TensorInfo used by this output handler.
35 /// @param tensorInfo - TensorInfo for the output.
telsoa014fcda012018-03-09 14:13:49 +000036 void SetTensorInfo(const TensorInfo& tensorInfo);
37
telsoa01c577f2c2018-08-31 09:22:23 +010038 /// @brief - Creates tensor handlers used by the intermediate tensors. Does not allocate memory.
39 /// @param factory - Factory to be used for handler creation.
telsoa014fcda012018-03-09 14:13:49 +000040 void CreateTensorHandles(const IWorkloadFactory& factory);
41
Francis Murtagh351d13d2018-09-24 15:01:18 +010042 /// @brief - Creates tensor handlers used by the intermediate tensors. Does not allocate memory.
43 /// @param factory - Factory to be used for handler creation.
44 /// @param dataLayout - Data Layout to be used for handler creation.
45 void CreateTensorHandles(const IWorkloadFactory& factory, DataLayout dataLayout);
46
telsoa01c577f2c2018-08-31 09:22:23 +010047 /// @brief - Gets the matching TensorInfo for the output.
48 /// @return - References to the output TensorInfo.
telsoa014fcda012018-03-09 14:13:49 +000049 const TensorInfo& GetTensorInfo() const { return m_TensorInfo; }
50
telsoa01c577f2c2018-08-31 09:22:23 +010051 /// @brief - Gets the allocated tensor memory.
52 /// @return - Pointer to the tensor memory.
telsoa014fcda012018-03-09 14:13:49 +000053 ITensorHandle* GetData() const { return m_TensorHandle.get(); }
54
telsoa01c577f2c2018-08-31 09:22:23 +010055 /// Fill the outputs for a given queue descriptor.
telsoa014fcda012018-03-09 14:13:49 +000056 void CollectWorkloadOutputs(WorkloadDataCollector& dataCollector) const;
57
58 void SetData(std::unique_ptr<ITensorHandle> data) { m_TensorHandle = std::move(data); }
59
telsoa014fcda012018-03-09 14:13:49 +000060 /// @brief Returns true if SetTensorInfo() has been called at least once on this.
61 bool IsTensorInfoSet() const { return m_bTensorInfoSet; }
62private:
63 std::unique_ptr<ITensorHandle> m_TensorHandle;
64 TensorInfo m_TensorInfo;
65 bool m_bTensorInfoSet = false;
66};
67
68} //namespace armnn