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" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #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> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
| 16 | #include <memory> |
| 17 | #include <set> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 18 | #include <string> |
| 19 | #include <vector> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | |
| 21 | #include <boost/assert.hpp> |
| 22 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 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 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 42 | /// @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 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 47 | /// @brief - Gets the matching TensorInfo for the output. |
| 48 | /// @return - References to the output TensorInfo. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 49 | const TensorInfo& GetTensorInfo() const { return m_TensorInfo; } |
| 50 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 51 | /// @brief - Gets the allocated tensor memory. |
| 52 | /// @return - Pointer to the tensor memory. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | ITensorHandle* GetData() const { return m_TensorHandle.get(); } |
| 54 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 55 | /// Fill the outputs for a given queue descriptor. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 56 | void CollectWorkloadOutputs(WorkloadDataCollector& dataCollector) const; |
| 57 | |
| 58 | void SetData(std::unique_ptr<ITensorHandle> data) { m_TensorHandle = std::move(data); } |
| 59 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | /// @brief Returns true if SetTensorInfo() has been called at least once on this. |
| 61 | bool IsTensorInfoSet() const { return m_bTensorInfoSet; } |
| 62 | private: |
| 63 | std::unique_ptr<ITensorHandle> m_TensorHandle; |
| 64 | TensorInfo m_TensorInfo; |
| 65 | bool m_bTensorInfoSet = false; |
| 66 | }; |
| 67 | |
| 68 | } //namespace armnn |