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 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | #include <memory> |
| 16 | #include <set> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 17 | #include <string> |
| 18 | #include <vector> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 19 | |
| 20 | #include <boost/assert.hpp> |
| 21 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | namespace armnn |
| 23 | { |
| 24 | |
| 25 | class ITensorHandle; |
| 26 | class IWorkloadFactory; |
| 27 | class OutputSlot; |
| 28 | class WorkloadDataCollector; |
| 29 | |
| 30 | class OutputHandler |
| 31 | { |
| 32 | public: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 33 | /// @brief - Sets the TensorInfo used by this output handler. |
| 34 | /// @param tensorInfo - TensorInfo for the output. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 35 | void SetTensorInfo(const TensorInfo& tensorInfo); |
| 36 | |
Derek Lamberti | 84da38b | 2019-06-13 11:40:08 +0100 | [diff] [blame] | 37 | /// @brief - Creates tensor handles used by the intermediate tensors. Does not allocate memory. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 38 | /// @param factory - Factory to be used for handler creation. |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 39 | void CreateTensorHandles(const IWorkloadFactory& factory, const bool IsMemoryManaged = true); |
| 40 | void CreateTensorHandles(const ITensorHandleFactory& factory, const bool IsMemoryManaged = true); |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 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 |