blob: f6af208e8a10e35160fd89daebacb5fc0609d71e [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa014fcda012018-03-09 14:13:49 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#include "RefPermuteWorkload.hpp"
7#include "RefWorkloadUtils.hpp"
8
Matteo Martincighe011d202019-11-28 11:35:47 +00009#include <armnnUtils/Permute.hpp>
10
Aron Virginas-Tard4f0fea2019-04-09 14:08:06 +010011#include <ResolveType.hpp>
telsoa014fcda012018-03-09 14:13:49 +000012
13namespace armnn
14{
15
16template <armnn::DataType DataType>
17void RefPermuteWorkload<DataType>::Execute() const
18{
Finn Williamsb8181f72021-04-07 10:23:21 +010019 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
20}
21
22template <armnn::DataType DataType>
23void RefPermuteWorkload<DataType>::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor)
24{
25 Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs);
26}
27
28template <armnn::DataType DataType>
29void RefPermuteWorkload<DataType>::Execute(std::vector<ITensorHandle*> inputs,
30 std::vector<ITensorHandle*> outputs) const
31{
telsoa014fcda012018-03-09 14:13:49 +000032 using T = ResolveType<DataType>;
33
34 ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, GetName() + "_Execute");
35
Finn Williamsb8181f72021-04-07 10:23:21 +010036 const ITensorHandle* src = inputs[0];
37 ITensorHandle* dst = outputs[0];
telsoa014fcda012018-03-09 14:13:49 +000038 const PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings;
39
Matteo Martincighd5b9e642019-01-04 18:01:21 +000040 armnnUtils::Permute(GetTensorInfo(dst).GetShape(), mappings,
Matthew Bentham4cefc412019-06-18 16:14:34 +010041 src->Map(), dst->Map(), sizeof(T));
telsoa014fcda012018-03-09 14:13:49 +000042}
43
Narumol Prangnawarat44179c32020-03-11 14:51:27 +000044template class RefPermuteWorkload<DataType::BFloat16>;
arovir01616e7752018-10-01 17:08:59 +010045template class RefPermuteWorkload<DataType::Float16>;
telsoa014fcda012018-03-09 14:13:49 +000046template class RefPermuteWorkload<DataType::Float32>;
Sadik Armagan303980c2020-04-17 12:45:14 +010047template class RefPermuteWorkload<DataType::QAsymmS8>;
Derek Lambertif90c56d2020-01-10 17:14:08 +000048template class RefPermuteWorkload<DataType::QAsymmU8>;
49template class RefPermuteWorkload<DataType::QSymmS16>;
telsoa014fcda012018-03-09 14:13:49 +000050
51} //namespace armnn