Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 1 | // |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 8 | #include "RefBaseWorkload.hpp" |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 9 | #include <armnn/backends/WorkloadData.hpp> |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 10 | |
| 11 | #include "RefWorkloadUtils.hpp" |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 16 | struct RefShapeWorkload : public RefBaseWorkload<ShapeQueueDescriptor> |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 17 | { |
| 18 | public: |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 19 | using RefBaseWorkload<ShapeQueueDescriptor>::RefBaseWorkload; |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 20 | virtual void Execute() const override |
| 21 | { |
| 22 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 23 | } |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 24 | void ExecuteAsync(ExecutionData& executionData) override |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 25 | { |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 26 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 27 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | private: |
| 31 | void Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 32 | { |
| 33 | const TensorShape Shape = GetTensorInfo(inputs[0]).GetShape(); |
| 34 | |
| 35 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
| 36 | |
| 37 | unsigned int numBytes = |
| 38 | GetTensorInfo(inputs[0]).GetNumDimensions() * GetDataTypeSize(outputInfo.GetDataType()); |
| 39 | |
| 40 | std::memcpy(outputs[0]->Map(), &Shape, numBytes); |
| 41 | outputs[0]->Unmap(); |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | } //namespace armnn |
| 46 | |
| 47 | |
| 48 | |
| 49 | |