ArmNN
 25.11
Loading...
Searching...
No Matches
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
9#include <armnn/Tensor.hpp>
10#include <armnn/Types.hpp>
12#include <utility>
13#include <vector>
14
15namespace armnn
16{
17class ITensorHandle;
18} // namespace armnn
19
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
28armnn::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
35armnn::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
43std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle);
44
45armnn::TensorShape ReduceDims(const armnn::TensorShape& tensorInfo, unsigned int dimensions);
46
47armnn::TensorInfo ReduceDims(const armnn::TensorInfo& tensorInfo, unsigned int dimensions);
48
49armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis);
50
51armnn::TensorShape ExpandDimsToRank(const armnn::TensorShape& tensorShape, unsigned int rank);
52
53std::vector<unsigned int> SqueezeDims(const armnn::TensorShape& tensorShape);
54
55unsigned 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
61unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis);
62
63std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info);
64
65template<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
70} // namespace armnnUtils
Copyright (c) 2021 ARM Limited and Contributors.
DataLayout
Definition Types.hpp:63
DataType
Definition Types.hpp:49
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
std::pair< float, float > FindMinMax(armnn::ITensorHandle *tensorHandle)
unsigned int GetNumElementsAfter(const armnn::TensorShape &shape, unsigned int axis)
armnn::TensorShape ReduceDims(const armnn::TensorShape &tensorInfo, unsigned int dimensions)
std::unique_ptr< float[]> ToFloatArray(const std::vector< PrimitiveType > &data, const armnn::TensorInfo &tensorInfo)
armnn::TensorShape ExpandDimsToRank(const armnn::TensorShape &tensorShape, unsigned int rank)
armnn::TensorShape GetTensorShape(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout)
std::vector< unsigned int > SqueezeDims(const armnn::TensorShape &tensorShape)
unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)