Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 1 | // |
Mike Kelly | 0e3fe10 | 2023-01-23 19:32:06 +0000 | [diff] [blame] | 2 | // Copyright © 2018-2023 Arm Ltd and Contributors. All rights reserved. |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include <armnn/TypesUtils.hpp> |
Colm Donelan | a98e79a | 2022-12-06 21:32:29 +0000 | [diff] [blame] | 9 | #include <armnn/Tensor.hpp> |
| 10 | #include <armnn/Types.hpp> |
Mike Kelly | 0e3fe10 | 2023-01-23 19:32:06 +0000 | [diff] [blame] | 11 | #include <armnnUtils/TensorUtils.hpp> |
Colm Donelan | a98e79a | 2022-12-06 21:32:29 +0000 | [diff] [blame] | 12 | #include <utility> |
| 13 | #include <vector> |
| 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | class ITensorHandle; |
| 18 | } // namespace armnn |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 19 | |
| 20 | namespace armnnUtils |
| 21 | { |
| 22 | armnn::TensorShape GetTensorShape(unsigned int numberOfBatches, |
| 23 | unsigned int numberOfChannels, |
| 24 | unsigned int height, |
| 25 | unsigned int width, |
| 26 | const armnn::DataLayout dataLayout); |
| 27 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 28 | armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, |
| 29 | unsigned int numberOfChannels, |
| 30 | unsigned int height, |
| 31 | unsigned int width, |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 32 | const armnn::DataLayout dataLayout, |
| 33 | const armnn::DataType dataType); |
| 34 | |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 35 | armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, |
| 36 | unsigned int numberOfChannels, |
| 37 | unsigned int depth, |
| 38 | unsigned int height, |
| 39 | unsigned int width, |
| 40 | const armnn::DataLayout dataLayout, |
| 41 | const armnn::DataType dataType); |
| 42 | |
Jim Flynn | f92dfce | 2019-05-02 11:33:25 +0100 | [diff] [blame] | 43 | std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle); |
| 44 | |
Mike Kelly | 0e3fe10 | 2023-01-23 19:32:06 +0000 | [diff] [blame] | 45 | armnn::TensorShape ReduceDims(const armnn::TensorShape& tensorInfo, unsigned int dimensions); |
| 46 | |
| 47 | armnn::TensorInfo ReduceDims(const armnn::TensorInfo& tensorInfo, unsigned int dimensions); |
| 48 | |
Narumol Prangnawarat | 0280785 | 2019-09-11 16:43:09 +0100 | [diff] [blame] | 49 | armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis); |
| 50 | |
Ryan OShea | a544f0f | 2023-01-25 18:10:20 +0000 | [diff] [blame] | 51 | armnn::TensorShape ExpandDimsToRank(const armnn::TensorShape& tensorShape, unsigned int rank); |
| 52 | |
Mike Kelly | 80512b0 | 2022-05-16 23:10:42 +0100 | [diff] [blame] | 53 | std::vector<unsigned int> SqueezeDims(const armnn::TensorShape& tensorShape); |
| 54 | |
Narumol Prangnawarat | 4dc64a6 | 2019-09-16 17:00:22 +0100 | [diff] [blame] | 55 | unsigned int GetNumElementsBetween(const armnn::TensorShape& shape, |
| 56 | unsigned int firstAxisInclusive, |
| 57 | unsigned int lastAxisExclusive); |
| 58 | |
| 59 | unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis); |
| 60 | |
Aron Virginas-Tar | b67f957 | 2019-11-04 15:00:19 +0000 | [diff] [blame] | 61 | unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis); |
Keith Davis | 5236e1d | 2019-11-04 08:58:33 +0000 | [diff] [blame] | 62 | |
Aron Virginas-Tar | b67f957 | 2019-11-04 15:00:19 +0000 | [diff] [blame] | 63 | std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info); |
Keith Davis | 5236e1d | 2019-11-04 08:58:33 +0000 | [diff] [blame] | 64 | |
Mike Kelly | 0506ef0 | 2023-01-03 16:29:44 +0000 | [diff] [blame] | 65 | template<typename PrimitiveType> |
| 66 | std::unique_ptr<float[]> ToFloatArray(const std::vector<PrimitiveType>& data, const armnn::TensorInfo& tensorInfo); |
| 67 | |
| 68 | std::unique_ptr<float[]> ToFloatArray(const std::vector<uint8_t>& data, const armnn::TensorInfo& tensorInfo); |
| 69 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 70 | } // namespace armnnUtils |