Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +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. |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefTransposeConvolution2dWorkload.hpp" |
| 7 | |
| 8 | #include "RefWorkloadUtils.hpp" |
| 9 | #include "TransposeConvolution2d.hpp" |
| 10 | |
| 11 | #include <Profiling.hpp> |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | RefTransposeConvolution2dWorkload::RefTransposeConvolution2dWorkload( |
| 17 | const TransposeConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) : |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 18 | RefBaseWorkload<TransposeConvolution2dQueueDescriptor>(descriptor, info) |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 19 | { |
| 20 | // set up weights decoder |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 21 | m_Weights = std::make_unique<ScopedTensorHandle>(*(descriptor.m_Weight)); |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 22 | const TensorInfo& weightsInfo = m_Weights->GetTensorInfo(); |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 23 | |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 24 | m_WeightsDecoder = MakeDecoder<float>(weightsInfo, m_Weights->Map(true)); |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 25 | m_WeightsShape = weightsInfo.GetShape(); |
| 26 | |
| 27 | // set up biases decoder |
| 28 | if (descriptor.m_Parameters.m_BiasEnabled) |
| 29 | { |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 30 | m_Biases = std::make_unique<ScopedTensorHandle>(*(descriptor.m_Bias)); |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 31 | const TensorInfo& biasesInfo = m_Biases->GetTensorInfo(); |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 32 | m_BiasesDecoder = MakeDecoder<float>(biasesInfo, m_Biases->Map(true)); |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 33 | } |
| 34 | } |
| 35 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 36 | void RefTransposeConvolution2dWorkload::Execute() const |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 37 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 38 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 41 | void RefTransposeConvolution2dWorkload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 42 | { |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 43 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 44 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void RefTransposeConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 48 | std::vector<ITensorHandle*> outputs) const |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 49 | { |
| 50 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefTransposeConvolution2dWorkload_Execute"); |
| 51 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 52 | const TensorInfo& inputInfo = GetTensorInfo(inputs[0]); |
| 53 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
| 54 | |
| 55 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->Map()); |
| 56 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(outputInfo, outputs[0]->Map()); |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 57 | |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 58 | TransposeConvolution2dImpl(m_Data.m_Parameters, |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 59 | inputInfo.GetShape(), |
| 60 | *inputDecoder, |
| 61 | outputInfo.GetShape(), |
| 62 | *outputEncoder, |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 63 | m_WeightsShape, |
| 64 | *m_WeightsDecoder, |
| 65 | m_BiasesDecoder.get()); |
| 66 | } |
| 67 | |
| 68 | } // namespace armnn |