ArmNN
 24.02
TensorUtils.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2018-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <armnn/TypesUtils.hpp>
9 #include <armnn/Tensor.hpp>
10 #include <armnn/Types.hpp>
12 #include <utility>
13 #include <vector>
14 
15 namespace armnn
16 {
17 class ITensorHandle;
18 } // namespace armnn
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 
28 armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches,
29  unsigned int numberOfChannels,
30  unsigned int height,
31  unsigned int width,
32  const armnn::DataLayout dataLayout,
33  const armnn::DataType dataType);
34 
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 
43 std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle);
44 
45 armnn::TensorShape ReduceDims(const armnn::TensorShape& tensorInfo, unsigned int dimensions);
46 
47 armnn::TensorInfo ReduceDims(const armnn::TensorInfo& tensorInfo, unsigned int dimensions);
48 
49 armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis);
50 
51 armnn::TensorShape ExpandDimsToRank(const armnn::TensorShape& tensorShape, unsigned int rank);
52 
53 std::vector<unsigned int> SqueezeDims(const armnn::TensorShape& tensorShape);
54 
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 
61 unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis);
62 
63 std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info);
64 
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 
70 } // namespace armnnUtils
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnnUtils::SqueezeDims
std::vector< unsigned int > SqueezeDims(const armnn::TensorShape &tensorShape)
Definition: TensorUtils.cpp:195
armnnUtils::GetUnsignedAxis
unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)
Definition: TensorUtils.cpp:236
TypesUtils.hpp
armnnUtils::ExpandDimsToRank
armnn::TensorShape ExpandDimsToRank(const armnn::TensorShape &tensorShape, unsigned int rank)
Definition: TensorUtils.cpp:170
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::ITensorHandle
Definition: ITensorHandle.hpp:16
TensorUtils.hpp
armnnUtils::GetPerAxisParams
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
Definition: TensorUtils.cpp:280
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::DataType
DataType
Definition: Types.hpp:48
armnnUtils
Definition: CompatibleTypes.hpp:10
armnnUtils::ExpandDims
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:142
Tensor.hpp
armnnUtils::GetNumElementsBetween
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
Definition: TensorUtils.cpp:209
armnnUtils::GetNumElementsAfter
unsigned int GetNumElementsAfter(const armnn::TensorShape &shape, unsigned int axis)
Definition: TensorUtils.cpp:261
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
Types.hpp
armnnUtils::FindMinMax
std::pair< float, float > FindMinMax(armnn::ITensorHandle *tensorHandle)
Definition: TensorUtils.cpp:81
armnnUtils::ReduceDims
armnn::TensorShape ReduceDims(const armnn::TensorShape &tensorInfo, unsigned int dimensions)
Definition: TensorUtils.cpp:108
armnnUtils::GetTensorInfo
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:40
armnnUtils::ToFloatArray
std::unique_ptr< float[]> ToFloatArray(const std::vector< PrimitiveType > &data, const armnn::TensorInfo &tensorInfo)
Definition: TensorUtils.cpp:307
armnnUtils::GetTensorShape
armnn::TensorShape GetTensorShape(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout)
Definition: TensorUtils.cpp:21