telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include "backends/WorkloadDataFwd.hpp" |
| 8 | |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include <memory> |
| 13 | #include <set> |
| 14 | |
| 15 | #include <boost/assert.hpp> |
| 16 | |
| 17 | #include "armnn/INetwork.hpp" |
| 18 | #include "armnn/Types.hpp" |
| 19 | #include "armnn/Descriptors.hpp" |
| 20 | #include "armnn/Tensor.hpp" |
| 21 | #include "ITensorHandle.hpp" |
| 22 | |
| 23 | namespace armnn |
| 24 | { |
| 25 | |
| 26 | class ITensorHandle; |
| 27 | class IWorkloadFactory; |
| 28 | class OutputSlot; |
| 29 | class WorkloadDataCollector; |
| 30 | |
| 31 | class OutputHandler |
| 32 | { |
| 33 | public: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame^] | 34 | /// @brief - Sets the TensorInfo used by this output handler. |
| 35 | /// @param tensorInfo - TensorInfo for the output. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | void SetTensorInfo(const TensorInfo& tensorInfo); |
| 37 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame^] | 38 | /// @brief - Creates tensor handlers used by the intermediate tensors. Does not allocate memory. |
| 39 | /// @param factory - Factory to be used for handler creation. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 40 | void CreateTensorHandles(const IWorkloadFactory& factory); |
| 41 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame^] | 42 | /// @brief - Gets the matching TensorInfo for the output. |
| 43 | /// @return - References to the output TensorInfo. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | const TensorInfo& GetTensorInfo() const { return m_TensorInfo; } |
| 45 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame^] | 46 | /// @brief - Gets the allocated tensor memory. |
| 47 | /// @return - Pointer to the tensor memory. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 48 | ITensorHandle* GetData() const { return m_TensorHandle.get(); } |
| 49 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame^] | 50 | /// Fill the outputs for a given queue descriptor. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | void CollectWorkloadOutputs(WorkloadDataCollector& dataCollector) const; |
| 52 | |
| 53 | void SetData(std::unique_ptr<ITensorHandle> data) { m_TensorHandle = std::move(data); } |
| 54 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 55 | /// @brief Returns true if SetTensorInfo() has been called at least once on this. |
| 56 | bool IsTensorInfoSet() const { return m_bTensorInfoSet; } |
| 57 | private: |
| 58 | std::unique_ptr<ITensorHandle> m_TensorHandle; |
| 59 | TensorInfo m_TensorInfo; |
| 60 | bool m_bTensorInfoSet = false; |
| 61 | }; |
| 62 | |
| 63 | } //namespace armnn |