blob: 7bf41c1ac817fb62c199cb2f3e370caf89552e87 [file] [log] [blame]
Nina Drozdd41b2592018-11-19 13:03:36 +00001//
Mike Kelly0e3fe102023-01-23 19:32:06 +00002// Copyright © 2018-2023 Arm Ltd and Contributors. All rights reserved.
Nina Drozdd41b2592018-11-19 13:03:36 +00003// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <armnn/TypesUtils.hpp>
Colm Donelana98e79a2022-12-06 21:32:29 +00009#include <armnn/Tensor.hpp>
10#include <armnn/Types.hpp>
Mike Kelly0e3fe102023-01-23 19:32:06 +000011#include <armnnUtils/TensorUtils.hpp>
Colm Donelana98e79a2022-12-06 21:32:29 +000012#include <utility>
13#include <vector>
14
15namespace armnn
16{
17class ITensorHandle;
18} // namespace armnn
Nina Drozdd41b2592018-11-19 13:03:36 +000019
20namespace armnnUtils
21{
22armnn::TensorShape GetTensorShape(unsigned int numberOfBatches,
23 unsigned int numberOfChannels,
24 unsigned int height,
25 unsigned int width,
26 const armnn::DataLayout dataLayout);
27
Nina Drozdd41b2592018-11-19 13:03:36 +000028armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches,
29 unsigned int numberOfChannels,
30 unsigned int height,
31 unsigned int width,
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000032 const armnn::DataLayout dataLayout,
33 const armnn::DataType dataType);
34
Tamás Nyíri7b885b32021-10-26 14:47:57 +010035armnn::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 Flynnf92dfce2019-05-02 11:33:25 +010043std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle);
44
Mike Kelly0e3fe102023-01-23 19:32:06 +000045armnn::TensorShape ReduceDims(const armnn::TensorShape& tensorInfo, unsigned int dimensions);
46
47armnn::TensorInfo ReduceDims(const armnn::TensorInfo& tensorInfo, unsigned int dimensions);
48
Narumol Prangnawarat02807852019-09-11 16:43:09 +010049armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis);
50
Ryan OSheaa544f0f2023-01-25 18:10:20 +000051armnn::TensorShape ExpandDimsToRank(const armnn::TensorShape& tensorShape, unsigned int rank);
52
Mike Kelly80512b02022-05-16 23:10:42 +010053std::vector<unsigned int> SqueezeDims(const armnn::TensorShape& tensorShape);
54
Narumol Prangnawarat4dc64a62019-09-16 17:00:22 +010055unsigned int GetNumElementsBetween(const armnn::TensorShape& shape,
56 unsigned int firstAxisInclusive,
57 unsigned int lastAxisExclusive);
58
59unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis);
60
Aron Virginas-Tarb67f9572019-11-04 15:00:19 +000061unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis);
Keith Davis5236e1d2019-11-04 08:58:33 +000062
Aron Virginas-Tarb67f9572019-11-04 15:00:19 +000063std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info);
Keith Davis5236e1d2019-11-04 08:58:33 +000064
Mike Kelly0506ef02023-01-03 16:29:44 +000065template<typename PrimitiveType>
66std::unique_ptr<float[]> ToFloatArray(const std::vector<PrimitiveType>& data, const armnn::TensorInfo& tensorInfo);
67
68std::unique_ptr<float[]> ToFloatArray(const std::vector<uint8_t>& data, const armnn::TensorInfo& tensorInfo);
69
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000070} // namespace armnnUtils