| 305 | |
| 306 | template<typename PrimitiveType> |
| 307 | std::unique_ptr<float[]> ToFloatArray(const std::vector<PrimitiveType>& data, const armnn::TensorInfo& tensorInfo) |
| 308 | { |
| 309 | CheckSizes(data, tensorInfo); |
| 310 | |
| 311 | std::unique_ptr<float[]> returnBuffer(new float[tensorInfo.GetNumElements()]); |
| 312 | |
| 313 | if (tensorInfo.HasPerAxisQuantization()) |
| 314 | { |
| 315 | unsigned int axis = tensorInfo.GetQuantizationDim().value(); |
| 316 | auto axisDimensionality = tensorInfo.GetShape()[axis]; |
| 317 | auto axisFactor = armnnUtils::GetNumElementsAfter(tensorInfo.GetShape(), axis); |
| 318 | |
| 319 | for (unsigned int i = 0; i < tensorInfo.GetNumElements(); ++i) |
| 320 | { |
| 321 | unsigned int axisIndex; |
| 322 | |
| 323 | if (i < axisFactor) |
| 324 | { |
| 325 | axisIndex = 0; |
| 326 | } |
| 327 | else |
| 328 | { |
| 329 | axisIndex = (i / axisFactor) % axisDimensionality; |
| 330 | } |
| 331 | returnBuffer[i] = Dequantize<PrimitiveType>(data[i], |
| 332 | tensorInfo.GetQuantizationScales()[axisIndex], |
| 333 | tensorInfo.GetQuantizationOffset()); |
| 334 | } |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | for (unsigned int i = 0; i < tensorInfo.GetNumElements(); ++i) |
| 339 | { |
| 340 | returnBuffer[i] = Dequantize<PrimitiveType>(data[i], |
| 341 | tensorInfo.GetQuantizationScale(), |
| 342 | tensorInfo.GetQuantizationOffset()); |
| 343 | } |
| 344 | } |
| 345 | return returnBuffer; |
| 346 | } |
| 347 | |
| 348 | std::unique_ptr<float[]> ToFloatArray(const std::vector<uint8_t>& data, const armnn::TensorInfo& tensorInfo) |
| 349 | { |
no test coverage detected