blob: 2d6ec2fea4f011eb29bb40e482a0140b283bb700 [file] [log] [blame]
Nina Drozdd41b2592018-11-19 13:03:36 +00001//
Colm Donelana98e79a2022-12-06 21:32:29 +00002// Copyright © 2019,2022 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>
11#include <utility>
12#include <vector>
13
14namespace armnn
15{
16class ITensorHandle;
17} // namespace armnn
Nina Drozdd41b2592018-11-19 13:03:36 +000018
19namespace armnnUtils
20{
21armnn::TensorShape GetTensorShape(unsigned int numberOfBatches,
22 unsigned int numberOfChannels,
23 unsigned int height,
24 unsigned int width,
25 const armnn::DataLayout dataLayout);
26
Nina Drozdd41b2592018-11-19 13:03:36 +000027armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches,
28 unsigned int numberOfChannels,
29 unsigned int height,
30 unsigned int width,
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000031 const armnn::DataLayout dataLayout,
32 const armnn::DataType dataType);
33
Tamás Nyíri7b885b32021-10-26 14:47:57 +010034armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches,
35 unsigned int numberOfChannels,
36 unsigned int depth,
37 unsigned int height,
38 unsigned int width,
39 const armnn::DataLayout dataLayout,
40 const armnn::DataType dataType);
41
Jim Flynnf92dfce2019-05-02 11:33:25 +010042std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle);
43
Narumol Prangnawarat02807852019-09-11 16:43:09 +010044armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis);
45
Mike Kelly80512b02022-05-16 23:10:42 +010046std::vector<unsigned int> SqueezeDims(const armnn::TensorShape& tensorShape);
47
Narumol Prangnawarat4dc64a62019-09-16 17:00:22 +010048unsigned int GetNumElementsBetween(const armnn::TensorShape& shape,
49 unsigned int firstAxisInclusive,
50 unsigned int lastAxisExclusive);
51
52unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis);
53
Aron Virginas-Tarb67f9572019-11-04 15:00:19 +000054unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis);
Keith Davis5236e1d2019-11-04 08:58:33 +000055
Aron Virginas-Tarb67f9572019-11-04 15:00:19 +000056std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info);
Keith Davis5236e1d2019-11-04 08:58:33 +000057
Mike Kelly0506ef02023-01-03 16:29:44 +000058template<typename PrimitiveType>
59std::unique_ptr<float[]> ToFloatArray(const std::vector<PrimitiveType>& data, const armnn::TensorInfo& tensorInfo);
60
61std::unique_ptr<float[]> ToFloatArray(const std::vector<uint8_t>& data, const armnn::TensorInfo& tensorInfo);
62
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000063} // namespace armnnUtils