diff options
author | Francis Murtagh <francis.murtagh@arm.com> | 2018-09-24 15:01:18 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-10 16:16:57 +0100 |
commit | 351d13d0b5fa698b72130012b2f069d30b911cb3 (patch) | |
tree | b9417a78336e3e1b4c7d8775a2b3fd5bce0d624a /src/backends/ArmComputeTensorUtils.cpp | |
parent | 2ca4696639c9d2361b24adbd9a33225d18527fde (diff) | |
download | armnn-351d13d0b5fa698b72130012b2f069d30b911cb3.tar.gz |
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
Diffstat (limited to 'src/backends/ArmComputeTensorUtils.cpp')
-rw-r--r-- | src/backends/ArmComputeTensorUtils.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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 <armnn/Descriptors.hpp> 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<int>(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; |