Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | ec5f7d1 | 2021-10-22 17:15:00 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 5 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 6 | #include <aclCommon/ArmComputeUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 8 | #include "armnn/Exceptions.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | #include <armnn/Descriptors.hpp> |
| 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | namespace armcomputetensorutils |
| 14 | { |
| 15 | |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 16 | arm_compute::DataType GetArmComputeDataType(armnn::DataType dataType, bool multiScales) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | { |
| 18 | switch(dataType) |
| 19 | { |
Narumol Prangnawarat | 250d392 | 2020-03-30 16:11:04 +0100 | [diff] [blame] | 20 | case armnn::DataType::BFloat16: |
| 21 | return arm_compute::DataType::BFLOAT16; |
Mike Kelly | 130ec60 | 2019-11-08 12:08:35 +0000 | [diff] [blame] | 22 | case armnn::DataType::Boolean: |
| 23 | return arm_compute::DataType::U8; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 24 | case armnn::DataType::Float16: |
| 25 | return arm_compute::DataType::F16; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 26 | case armnn::DataType::Float32: |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | return arm_compute::DataType::F32; |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 28 | case armnn::DataType::QAsymmS8: |
| 29 | return arm_compute::DataType::QASYMM8_SIGNED; |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 30 | case armnn::DataType::QAsymmU8: |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | return arm_compute::DataType::QASYMM8; |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 32 | case armnn::DataType::QSymmS16: |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 33 | return arm_compute::DataType::QSYMM16; |
Inki Dae | d4619e2 | 2020-09-10 15:33:54 +0900 | [diff] [blame] | 34 | case armnn::DataType::Signed64: |
| 35 | return arm_compute::DataType::S64; |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 36 | case armnn::DataType::QSymmS8: |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 37 | { |
| 38 | return multiScales ? arm_compute::DataType::QSYMM8_PER_CHANNEL : arm_compute::DataType::QSYMM8; |
| 39 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 40 | case armnn::DataType::Signed32: |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | return arm_compute::DataType::S32; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | default: |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 43 | ARMNN_ASSERT_MSG(false, "Unknown data type"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | return arm_compute::DataType::UNKNOWN; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | |
Cathal Corbett | fd5bec4 | 2022-03-03 15:13:23 +0000 | [diff] [blame^] | 48 | armnn::DataType GetArmNNDataType(arm_compute::DataType dataType) |
| 49 | { |
| 50 | switch(dataType) |
| 51 | { |
| 52 | case arm_compute::DataType::BFLOAT16: |
| 53 | return armnn::DataType::BFloat16; |
| 54 | case arm_compute::DataType::U8: |
| 55 | return armnn::DataType::Boolean; |
| 56 | case arm_compute::DataType::F16: |
| 57 | return armnn::DataType::Float16; |
| 58 | case arm_compute::DataType::F32: |
| 59 | return armnn::DataType::Float32; |
| 60 | case arm_compute::DataType::QASYMM8_SIGNED: |
| 61 | return armnn::DataType::QAsymmS8; |
| 62 | case arm_compute::DataType::QASYMM8: |
| 63 | return armnn::DataType::QAsymmU8; |
| 64 | case arm_compute::DataType::QSYMM16: |
| 65 | return armnn::DataType::QSymmS16; |
| 66 | case arm_compute::DataType::S64: |
| 67 | return armnn::DataType::Signed64; |
| 68 | case arm_compute::DataType::QSYMM8_PER_CHANNEL: |
| 69 | return armnn::DataType::QSymmS8; |
| 70 | case arm_compute::DataType::QSYMM8: |
| 71 | return armnn::DataType::QSymmS8; |
| 72 | case arm_compute::DataType::S32: |
| 73 | return armnn::DataType::Signed32; |
| 74 | default: |
| 75 | ARMNN_ASSERT_MSG(false, "Unknown data type"); |
| 76 | return armnn::DataType::Float32; |
| 77 | } |
| 78 | } |
| 79 | |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 80 | arm_compute::Coordinates BuildArmComputeReductionCoordinates(size_t inputDimensions, |
| 81 | unsigned int originalInputRank, |
| 82 | const std::vector<unsigned int>& armnnAxes) |
| 83 | { |
| 84 | arm_compute::Coordinates outAclCoords; |
| 85 | |
| 86 | if (armnnAxes.empty()) |
| 87 | { |
| 88 | // If no reduction axes were provided, then the input must be reduced along all dimensions. |
| 89 | // Since Compute Library does not accept an empty vector as the reduction dimensions, we then |
| 90 | // manually create a vector including all the input dimensions (in reversed order) as: |
| 91 | // |
| 92 | // { inputDimensions - 1, inputDimensions - 2, ..., 1, 0 } |
| 93 | // |
| 94 | outAclCoords.set_num_dimensions(inputDimensions); |
| 95 | std::generate(outAclCoords.begin(), outAclCoords.end(), [d = inputDimensions - 1] () mutable { return d--; }); |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | // Create a vector of reduction dimensions (in reversed order) with the given reduction axes. |
| 100 | // |
| 101 | // Adjust the given reduction axes according to the original rank of the input tensor (before ACL applied any |
| 102 | // dimension correction). |
| 103 | // For example, if the input tensor originally had 4 dimensions, and one of the reduction axes was 2, then the |
| 104 | // new value for that reduction axis should be 1. |
| 105 | // |
| 106 | // Example: |
| 107 | // ArmNN input shape = { 1, 1, 3, 2 } -> ACL input shape = { 2, 3 } |
| 108 | // ArmNN reduction axis = { 2 } -> ACL reduction axis = { 1 } |
| 109 | // ArmNN reduction axis = { 3 } -> ACL reduction axis = { 0 } |
| 110 | // |
| 111 | // The transformation: ACL reduction axis index = original rank - ArmNN reduction axis index - 1 |
| 112 | // |
| 113 | outAclCoords.set_num_dimensions(armnnAxes.size()); |
| 114 | std::transform(armnnAxes.begin(), armnnAxes.end(), |
| 115 | outAclCoords.begin(), |
| 116 | [originalInputRank](unsigned int i){ return originalInputRank - i - 1; }); |
| 117 | } |
| 118 | |
| 119 | return outAclCoords; |
| 120 | } |
| 121 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 122 | arm_compute::TensorShape BuildArmComputeTensorShape(const armnn::TensorShape& tensorShape) |
| 123 | { |
| 124 | arm_compute::TensorShape shape; |
| 125 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 126 | // armnn tensors are (batch, channels, height, width). |
| 127 | // arm_compute tensors are (width, height, channels, batch). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 128 | for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); i++) |
| 129 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 130 | // Note that our dimensions are stored in the opposite order to ACL's. |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 131 | shape.set(tensorShape.GetNumDimensions() - i - 1, tensorShape[i], false); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 132 | |
| 133 | // TensorShape::set() flattens leading ones, so that batch size 1 cannot happen. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 134 | // arm_compute tensors expect this. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | // prevent arm_compute issue where tensor is flattened to nothing |
| 138 | if (shape.num_dimensions() == 0) |
| 139 | { |
| 140 | shape.set_num_dimensions(1); |
| 141 | } |
| 142 | |
| 143 | return shape; |
| 144 | } |
| 145 | |
| 146 | // Utility function used to build a TensorInfo object, that can be used to initialise |
| 147 | // ARM Compute Tensor and CLTensor allocators. |
| 148 | arm_compute::TensorInfo BuildArmComputeTensorInfo(const armnn::TensorInfo& tensorInfo) |
| 149 | { |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 150 | bool multiScales = tensorInfo.HasMultipleQuantizationScales(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 151 | const arm_compute::TensorShape aclTensorShape = BuildArmComputeTensorShape(tensorInfo.GetShape()); |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 152 | const arm_compute::DataType aclDataType = GetArmComputeDataType(tensorInfo.GetDataType(), multiScales); |
Aron Virginas-Tar | 13b653f | 2019-11-01 11:40:39 +0000 | [diff] [blame] | 153 | |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 154 | const arm_compute::QuantizationInfo aclQuantizationInfo = multiScales ? |
Aron Virginas-Tar | 13b653f | 2019-11-01 11:40:39 +0000 | [diff] [blame] | 155 | arm_compute::QuantizationInfo(tensorInfo.GetQuantizationScales()) : |
| 156 | arm_compute::QuantizationInfo(tensorInfo.GetQuantizationScale(), tensorInfo.GetQuantizationOffset()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 157 | |
| 158 | return arm_compute::TensorInfo(aclTensorShape, 1, aclDataType, aclQuantizationInfo); |
| 159 | } |
| 160 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 161 | arm_compute::TensorInfo BuildArmComputeTensorInfo(const armnn::TensorInfo& tensorInfo, |
| 162 | armnn::DataLayout dataLayout) |
| 163 | { |
Aron Virginas-Tar | 13b653f | 2019-11-01 11:40:39 +0000 | [diff] [blame] | 164 | arm_compute::TensorInfo aclTensorInfo = BuildArmComputeTensorInfo(tensorInfo); |
| 165 | aclTensorInfo.set_data_layout(ConvertDataLayout(dataLayout)); |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 166 | |
Aron Virginas-Tar | 13b653f | 2019-11-01 11:40:39 +0000 | [diff] [blame] | 167 | return aclTensorInfo; |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Matteo Martincigh | 747ef82 | 2018-12-18 09:26:39 +0000 | [diff] [blame] | 170 | arm_compute::DataLayout ConvertDataLayout(armnn::DataLayout dataLayout) |
| 171 | { |
| 172 | switch(dataLayout) |
| 173 | { |
| 174 | case armnn::DataLayout::NHWC : return arm_compute::DataLayout::NHWC; |
| 175 | |
| 176 | case armnn::DataLayout::NCHW : return arm_compute::DataLayout::NCHW; |
| 177 | |
Teresa Charlin | ec5f7d1 | 2021-10-22 17:15:00 +0100 | [diff] [blame] | 178 | case armnn::DataLayout::NDHWC : return arm_compute::DataLayout::NDHWC; |
| 179 | |
| 180 | case armnn::DataLayout::NCDHW : return arm_compute::DataLayout::NCDHW; |
| 181 | |
Matteo Martincigh | 747ef82 | 2018-12-18 09:26:39 +0000 | [diff] [blame] | 182 | default: throw InvalidArgumentException("Unknown armnn::DataLayout: [" + |
| 183 | std::to_string(static_cast<int>(dataLayout)) + "]"); |
| 184 | } |
| 185 | } |
| 186 | |
Sadik Armagan | a3600ba | 2019-10-10 10:43:20 +0100 | [diff] [blame] | 187 | arm_compute::PoolingLayerInfo BuildArmComputePoolingLayerInfo(const Pooling2dDescriptor& descriptor, |
| 188 | bool fpMixedPrecision) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 189 | { |
| 190 | using arm_compute::PoolingType; |
| 191 | using arm_compute::DimensionRoundingType; |
| 192 | using arm_compute::PadStrideInfo; |
| 193 | using arm_compute::PoolingLayerInfo; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 194 | using arm_compute::Size2D; |
Teresa Charlin | c809a29 | 2020-01-31 10:21:44 +0000 | [diff] [blame] | 195 | using arm_compute::DataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 196 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 197 | // Resolve ARM Compute layer parameters. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 198 | const PoolingType poolingType = ConvertPoolingAlgorithmToAclPoolingType(descriptor.m_PoolType); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 199 | |
Teresa Charlin | c809a29 | 2020-01-31 10:21:44 +0000 | [diff] [blame] | 200 | const DataLayout dataLayout = ConvertDataLayout(descriptor.m_DataLayout); |
| 201 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 202 | bool isGlobalPooling = (descriptor.m_StrideX==0 && descriptor.m_StrideY==0); |
| 203 | //use specific constructor if global pooling |
| 204 | if(isGlobalPooling) |
| 205 | { |
Teresa Charlin | c809a29 | 2020-01-31 10:21:44 +0000 | [diff] [blame] | 206 | return arm_compute::PoolingLayerInfo(poolingType, dataLayout); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 207 | } |
| 208 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 209 | const DimensionRoundingType rounding = ConvertOutputShapeRoundingToAclDimensionRoundingType( |
| 210 | descriptor.m_OutputShapeRounding); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 211 | const PadStrideInfo padStrideInfo(descriptor.m_StrideX, |
| 212 | descriptor.m_StrideY, |
| 213 | descriptor.m_PadLeft, |
| 214 | descriptor.m_PadRight, |
| 215 | descriptor.m_PadTop, |
| 216 | descriptor.m_PadBottom, |
| 217 | rounding); |
| 218 | |
| 219 | const bool excludePadding = (descriptor.m_PaddingMethod == PaddingMethod::Exclude); |
| 220 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 221 | const Size2D poolSize(descriptor.m_PoolWidth, descriptor.m_PoolHeight); |
| 222 | |
Teresa Charlin | c809a29 | 2020-01-31 10:21:44 +0000 | [diff] [blame] | 223 | return arm_compute::PoolingLayerInfo(poolingType, poolSize, dataLayout, padStrideInfo, excludePadding, |
| 224 | fpMixedPrecision); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | arm_compute::NormalizationLayerInfo BuildArmComputeNormalizationLayerInfo(const NormalizationDescriptor& descriptor) |
| 228 | { |
| 229 | const arm_compute::NormType normType = |
| 230 | ConvertNormalizationAlgorithmChannelToAclNormType(descriptor.m_NormChannelType); |
| 231 | return arm_compute::NormalizationLayerInfo(normType, |
| 232 | descriptor.m_NormSize, |
| 233 | descriptor.m_Alpha, |
| 234 | descriptor.m_Beta, |
| 235 | descriptor.m_K, |
| 236 | false); |
| 237 | } |
| 238 | |
| 239 | arm_compute::PermutationVector BuildArmComputePermutationVector(const armnn::PermutationVector& perm) |
| 240 | { |
| 241 | arm_compute::PermutationVector aclPerm; |
| 242 | |
| 243 | unsigned int start = 0; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 244 | while ((start < perm.GetSize()) && (start == perm[start])) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 245 | { |
| 246 | ++start; |
| 247 | } |
| 248 | |
| 249 | for (unsigned int i = start; i < perm.GetSize(); ++i) |
| 250 | { |
| 251 | aclPerm.set(i - start, perm[i] - start); |
| 252 | } |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 253 | return aclPerm; |
| 254 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 255 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 256 | arm_compute::PermutationVector BuildArmComputeTransposeVector(const armnn::PermutationVector& perm) |
| 257 | { |
| 258 | arm_compute::PermutationVector aclPerm; |
| 259 | std::map<unsigned int, unsigned int> permuteMappings; |
| 260 | for (unsigned int i = 0; i < perm.GetSize(); ++i) |
| 261 | { |
| 262 | permuteMappings[perm[i]] = i; |
| 263 | } |
| 264 | |
| 265 | std::vector<unsigned int> permuteVector; |
| 266 | for (unsigned int i = 0; i < perm.GetSize(); ++i) |
| 267 | { |
| 268 | permuteVector.push_back(permuteMappings.at(i)); |
| 269 | } |
| 270 | |
| 271 | unsigned int start = 0; |
| 272 | while ((start < perm.GetSize()) && (start == permuteVector[start])) |
| 273 | { |
| 274 | ++start; |
| 275 | } |
| 276 | |
| 277 | for (unsigned int i = start; i < perm.GetSize(); ++i) |
| 278 | { |
| 279 | aclPerm.set(i - start, permuteVector[i] - start); |
| 280 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 281 | return aclPerm; |
| 282 | } |
| 283 | |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 284 | arm_compute::Size2D BuildArmComputeSize2D(const unsigned int width, const unsigned int height) |
| 285 | { |
| 286 | return arm_compute::Size2D(width, height); |
| 287 | } |
| 288 | |
Matthew Sloyan | 2e5d0b2 | 2021-10-21 14:05:31 +0100 | [diff] [blame] | 289 | arm_compute::PixelValue GetPixelValue(const arm_compute::ITensorInfo* tensorInfo, float pixelValue) |
Mike Kelly | 0a08ec6 | 2019-07-25 08:39:31 +0100 | [diff] [blame] | 290 | { |
Matthew Sloyan | 2e5d0b2 | 2021-10-21 14:05:31 +0100 | [diff] [blame] | 291 | switch (tensorInfo->data_type()) |
Mike Kelly | 0a08ec6 | 2019-07-25 08:39:31 +0100 | [diff] [blame] | 292 | { |
Mike Kelly | 0a08ec6 | 2019-07-25 08:39:31 +0100 | [diff] [blame] | 293 | case arm_compute::DataType::F16: |
| 294 | return arm_compute::PixelValue(static_cast<Half>(pixelValue)); |
| 295 | case arm_compute::DataType::F32: |
| 296 | return arm_compute::PixelValue(pixelValue); |
Mike Kelly | 130ec60 | 2019-11-08 12:08:35 +0000 | [diff] [blame] | 297 | case arm_compute::DataType::QASYMM8: |
| 298 | return arm_compute::PixelValue(static_cast<uint8_t>(pixelValue)); |
| 299 | case arm_compute::DataType::QSYMM16: |
| 300 | return arm_compute::PixelValue(static_cast<int16_t>(pixelValue)); |
Tamas Nyiri | d3065d7 | 2021-11-12 11:22:50 +0000 | [diff] [blame] | 301 | case arm_compute::DataType::QSYMM8: |
Sadik Armagan | e5d0b93 | 2020-04-09 15:48:44 +0100 | [diff] [blame] | 302 | case arm_compute::DataType::QASYMM8_SIGNED: |
Mike Kelly | 130ec60 | 2019-11-08 12:08:35 +0000 | [diff] [blame] | 303 | case arm_compute::DataType::QSYMM8_PER_CHANNEL: |
| 304 | return arm_compute::PixelValue(static_cast<int8_t>(pixelValue)); |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 305 | case arm_compute::DataType::S32: |
| 306 | return arm_compute::PixelValue(static_cast<int32_t>(pixelValue)); |
Mike Kelly | 0a08ec6 | 2019-07-25 08:39:31 +0100 | [diff] [blame] | 307 | default: |
| 308 | throw InvalidArgumentException("Unsupported DataType: [" + |
Matthew Sloyan | 2e5d0b2 | 2021-10-21 14:05:31 +0100 | [diff] [blame] | 309 | std::to_string(static_cast<int>(tensorInfo->data_type())) + "]"); |
Mike Kelly | 0a08ec6 | 2019-07-25 08:39:31 +0100 | [diff] [blame] | 310 | } |
| 311 | } |
| 312 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 313 | } // namespace armcomputetensorutils |
| 314 | } // namespace armnn |