aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl
diff options
context:
space:
mode:
authorMatthew Bentham <matthew.bentham@arm.com>2018-12-31 15:49:42 +0000
committerEanna O Cathain Arm <eanna.ocathain@arm.com>2019-01-02 11:44:02 +0000
commitfd899966cb881f5bb1ccce7903253a32d360419d (patch)
tree3ed188e119961aa9696186461d788307cab05bd7 /src/backends/cl
parent6f37f83a27160948fee366b9f195c52f78cb88f0 (diff)
downloadarmnn-fd899966cb881f5bb1ccce7903253a32d360419d.tar.gz
MLCE-82 Add Neon Mean support and unit tests
Factor out new BuildArmComputeReductionCoordinates function from CL backend into ArmComputeTensorUtils. Update NEON LayerSupport and WorkloadFactory objects Change-Id: Icc975ec699199bffafbdb207323df509d35e1e04
Diffstat (limited to 'src/backends/cl')
-rw-r--r--src/backends/cl/workloads/ClMeanWorkload.cpp60
1 files changed, 6 insertions, 54 deletions
diff --git a/src/backends/cl/workloads/ClMeanWorkload.cpp b/src/backends/cl/workloads/ClMeanWorkload.cpp
index 960fca2732..470b6a883d 100644
--- a/src/backends/cl/workloads/ClMeanWorkload.cpp
+++ b/src/backends/cl/workloads/ClMeanWorkload.cpp
@@ -10,50 +10,6 @@
#include "ClWorkloadUtils.hpp"
-namespace
-{
-
-void ConvertArmnnAxesToAclCoordinates(size_t inputDimensions,
- unsigned int originalInputRank,
- const std::vector<unsigned int>& armnnAxes,
- arm_compute::Coordinates& outAclCoords)
-{
- if (armnnAxes.empty())
- {
- // If no reduction axes were provided, then the input must be reduced along all dimensions.
- // Since arm_compute::CLReduceMean does not accept an empty vector as the reduction dimensions, we then
- // manually create a vector including all the input dimensions (in reversed order) as:
- //
- // { inputDimensions - 1, inputDimensions - 2, ..., 1, 0 }
- //
- outAclCoords.set_num_dimensions(inputDimensions);
- std::generate(outAclCoords.begin(), outAclCoords.end(), [d = inputDimensions - 1] () mutable { return d--; });
- }
- else
- {
- // Create a vector of reduction dimensions (in reversed order) with the given reduction axes.
- //
- // Adjust the given reduction axes according to the original rank of the input tensor (before ACL applied any
- // dimension correction).
- // For example, if the input tensor originally had 4 dimensions, and one of the reduction axes was 2, then the
- // new value for that reduction axis should be 1.
- //
- // Example:
- // ArmNN input shape = { 1, 1, 3, 2 } -> ACL input shape = { 2, 3 }
- // ArmNN reduction axis = { 2 } -> ACL reduction axis = { 1 }
- // ArmNN reduction axis = { 3 } -> ACL reduction axis = { 0 }
- //
- // The transformation: ACL reduction axis index = original rank - ArmNN reduction axis index - 1
- //
- outAclCoords.set_num_dimensions(armnnAxes.size());
- std::transform(armnnAxes.begin(), armnnAxes.end(),
- outAclCoords.begin(),
- [originalInputRank](unsigned int i){ return originalInputRank - i - 1; });
- }
-}
-
-} // anonymous namespace
-
namespace armnn
{
using namespace armcomputetensorutils;
@@ -65,11 +21,9 @@ arm_compute::Status ClMeanValidate(const TensorInfo& input,
const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
- arm_compute::Coordinates coords;
- ConvertArmnnAxesToAclCoordinates(aclInputInfo.num_dimensions(),
- input.GetNumDimensions(),
- desc.m_Axis,
- coords);
+ arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
+ input.GetNumDimensions(),
+ desc.m_Axis);
return arm_compute::CLReduceMean::validate(&aclInputInfo, coords, desc.m_KeepDims, &aclOutputInfo);
}
@@ -82,11 +36,9 @@ ClMeanWorkload::ClMeanWorkload(const MeanQueueDescriptor& descriptor, const Work
arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
- arm_compute::Coordinates coords;
- ConvertArmnnAxesToAclCoordinates(input.info()->num_dimensions(),
- info.m_InputTensorInfos[0].GetNumDimensions(),
- m_Data.m_Parameters.m_Axis,
- coords);
+ arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(input.info()->num_dimensions(),
+ info.m_InputTensorInfos[0].GetNumDimensions(),
+ m_Data.m_Parameters.m_Axis);
m_Layer.configure(&input, coords, m_Data.m_Parameters.m_KeepDims, &output);
}