From 351d13d0b5fa698b72130012b2f069d30b911cb3 Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Mon, 24 Sep 2018 15:01:18 +0100 Subject: IVGCVSW-1888 Plumb data layout parameter for Convolution2D * Added the DataLayout parameter to the Convolution2dDescriptor * Added the DataLayout parameter the Convolution2dQueueDescriptor * Set the DataLayout on the Descriptor in CreateWorkload() * Added overloaded factory methods for CreateTensorHandle() * Updated BuildArmComputeTensorInfo() to take DataLayout parameter. * Updated handles to take DataLayout parameter * Updated (Cl/Neon)Convolution2dWorkloadValidate * Updated (Cl/Neon)Convolution2dFloatWorkload * Updated (Cl/Neon)Convolution2dUint8Workload Change-Id: I8410668b3d727ca587bee66755cc4c4c78422f1f --- src/backends/ArmComputeTensorUtils.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/backends/ArmComputeTensorUtils.cpp') diff --git a/src/backends/ArmComputeTensorUtils.cpp b/src/backends/ArmComputeTensorUtils.cpp index ba9fb40cfc..e65c4ad35f 100644 --- a/src/backends/ArmComputeTensorUtils.cpp +++ b/src/backends/ArmComputeTensorUtils.cpp @@ -5,6 +5,7 @@ #include "ArmComputeTensorUtils.hpp" #include "ArmComputeUtils.hpp" +#include "armnn/Exceptions.hpp" #include namespace armnn @@ -66,6 +67,33 @@ arm_compute::TensorInfo BuildArmComputeTensorInfo(const armnn::TensorInfo& tenso return arm_compute::TensorInfo(aclTensorShape, 1, aclDataType, aclQuantizationInfo); } +arm_compute::DataLayout ConvertDataLayout(armnn::DataLayout dataLayout) +{ + switch(dataLayout) + { + case armnn::DataLayout::NHWC : return arm_compute::DataLayout::NHWC; + + case armnn::DataLayout::NCHW : return arm_compute::DataLayout::NCHW; + + default: throw InvalidArgumentException("Unknown armnn::DataLayout: [" + + std::to_string(static_cast(dataLayout)) + "]"); + } +} + +arm_compute::TensorInfo BuildArmComputeTensorInfo(const armnn::TensorInfo& tensorInfo, + armnn::DataLayout dataLayout) +{ + const arm_compute::TensorShape aclTensorShape = BuildArmComputeTensorShape(tensorInfo.GetShape()); + const arm_compute::DataType aclDataType = GetArmComputeDataType(tensorInfo.GetDataType()); + const arm_compute::QuantizationInfo aclQuantizationInfo(tensorInfo.GetQuantizationScale(), + tensorInfo.GetQuantizationOffset()); + + arm_compute::TensorInfo clTensorInfo(aclTensorShape, 1, aclDataType, aclQuantizationInfo); + clTensorInfo.set_data_layout(ConvertDataLayout(dataLayout)); + + return clTensorInfo; +} + arm_compute::PoolingLayerInfo BuildArmComputePoolingLayerInfo(const Pooling2dDescriptor& descriptor) { using arm_compute::PoolingType; -- cgit v1.2.1