Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 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 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 41 | void RefTransposeConvolution2dWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 42 | { |
| 43 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 44 | } |
| 45 | |
| 46 | void RefTransposeConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 47 | std::vector<ITensorHandle*> outputs) const |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 48 | { |
| 49 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefTransposeConvolution2dWorkload_Execute"); |
| 50 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 51 | const TensorInfo& inputInfo = GetTensorInfo(inputs[0]); |
| 52 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
| 53 | |
| 54 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->Map()); |
| 55 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(outputInfo, outputs[0]->Map()); |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 56 | |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 57 | TransposeConvolution2dImpl(m_Data.m_Parameters, |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 58 | inputInfo.GetShape(), |
| 59 | *inputDecoder, |
| 60 | outputInfo.GetShape(), |
| 61 | *outputEncoder, |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 62 | m_WeightsShape, |
| 63 | *m_WeightsDecoder, |
| 64 | m_BiasesDecoder.get()); |
| 65 | } |
| 66 | |
| 67 | } // namespace armnn |