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