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) : |
| 18 | BaseWorkload<TransposeConvolution2dQueueDescriptor>(descriptor, info) |
| 19 | { |
| 20 | // set up weights decoder |
| 21 | m_Weights = std::make_unique<ScopedCpuTensorHandle>(*(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 | { |
| 30 | m_Biases = std::make_unique<ScopedCpuTensorHandle>(*(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 | |
| 36 | void RefTransposeConvolution2dWorkload::PostAllocationConfigure() |
| 37 | { |
| 38 | // set up input decoder |
| 39 | const ITensorHandle* input = m_Data.m_Inputs[0]; |
| 40 | const TensorInfo& inputInfo = GetTensorInfo(input); |
| 41 | |
| 42 | m_InputShape = inputInfo.GetShape(); |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 43 | m_InputDecoder = MakeDecoder<float>(inputInfo); |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 44 | |
| 45 | // set up output encoder |
| 46 | ITensorHandle* output = m_Data.m_Outputs[0]; |
| 47 | const TensorInfo& outputInfo = GetTensorInfo(output); |
| 48 | |
| 49 | m_OutputShape = outputInfo.GetShape(); |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 50 | m_OutputEncoder = MakeEncoder<float>(outputInfo); |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void RefTransposeConvolution2dWorkload::Execute() const |
| 54 | { |
| 55 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefTransposeConvolution2dWorkload_Execute"); |
| 56 | |
Matthew Bentham | 4686af0 | 2019-07-02 15:45:18 +0100 | [diff] [blame] | 57 | m_InputDecoder->Reset(m_Data.m_Inputs[0]->Map()); |
| 58 | m_OutputEncoder->Reset(m_Data.m_Outputs[0]->Map()); |
| 59 | |
Aron Virginas-Tar | 735a450 | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 60 | TransposeConvolution2dImpl(m_Data.m_Parameters, |
| 61 | m_InputShape, |
| 62 | *m_InputDecoder, |
| 63 | m_OutputShape, |
| 64 | *m_OutputEncoder, |
| 65 | m_WeightsShape, |
| 66 | *m_WeightsDecoder, |
| 67 | m_BiasesDecoder.get()); |
| 68 | } |
| 69 | |
| 70 | } // namespace armnn |