From fd627ffaec8fd8801d980b4c91ee7c0607ab6aaf Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Thu, 25 Feb 2021 17:44:00 +0000 Subject: IVGCVSW-5687 Update Doxygen Docu * Update Doxygen Documentation for 21.02 release Signed-off-by: Jan Eilers Change-Id: I9ed2f9caab038836ea99d7b378d7899fe431a4e5 --- 21.02/_permute_8cpp_source.xhtml | 131 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 21.02/_permute_8cpp_source.xhtml (limited to '21.02/_permute_8cpp_source.xhtml') diff --git a/21.02/_permute_8cpp_source.xhtml b/21.02/_permute_8cpp_source.xhtml new file mode 100644 index 0000000000..79d7df11d7 --- /dev/null +++ b/21.02/_permute_8cpp_source.xhtml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + +ArmNN: src/armnnUtils/Permute.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Permute.cpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <armnn/Tensor.hpp>
7 
8 #include <armnnUtils/Permute.hpp>
9 
10 #include "Half.hpp"
11 
12 #include <cassert>
13 #include <cstring>
14 
15 namespace
16 {
17 
18 class PermuteLoop
19 {
20 public:
21  using size_type = unsigned int;
22 
23  PermuteLoop(const armnn::TensorShape& dstShape, const armnn::PermutationVector& mappings)
24  : m_DstShape(dstShape)
25  {
26  assert(dstShape.GetNumDimensions() == mappings.GetSize());
27 
28  const size_type numDims = dstShape.GetNumDimensions();
29 
30  size_type srcStride = 1U;
31  size_type dstStride = 1U;
32 
33  for (size_type i = numDims - 1U, k = 0U; k < numDims; ++k, --i)
34  {
35  m_SrcStrides[mappings[i]] = srcStride;
36  m_DstStrides[i] = dstStride;
37 
38  srcStride *= dstShape[mappings[i]];
39  dstStride *= dstShape[i];
40  }
41  }
42 
43  void Unroll(const void* srcData, void* dstData, size_t dataTypeSize)
44  {
45  assert(srcData);
46  assert(dstData);
47  assert(dataTypeSize > 0);
48 
49  const unsigned char* srcDataPtr = reinterpret_cast<const unsigned char*>(srcData);
50  unsigned char* dstDataPtr = reinterpret_cast<unsigned char*>(dstData);
51 
52  const unsigned char* const srcEndPtr = srcDataPtr + m_DstShape.GetNumElements() * dataTypeSize;
53  unsigned char* const dstEndPtr = dstDataPtr + m_DstShape.GetNumElements() * dataTypeSize;
54 
55  Unroll(0, srcDataPtr, dstDataPtr, srcEndPtr, dstEndPtr, dataTypeSize);
56  }
57 
58 private:
59  void Unroll(size_type dimension,
60  const unsigned char* srcData, unsigned char* dstData,
61  const unsigned char* srcEnd, unsigned char* dstEnd,
62  size_t dataTypeSize)
63  {
64  assert(srcData);
65  assert(dstData);
66  assert(srcEnd);
67  assert(dstEnd);
68  assert(srcData < srcEnd);
69  assert(dstData < dstEnd);
70  assert(dataTypeSize > 0);
71 
72  if (dimension >= m_DstShape.GetNumDimensions())
73  {
74  ::memcpy(dstData, srcData, dataTypeSize);
75  }
76  else
77  {
78  for (size_type i = 0; i < m_DstShape[dimension]; i++)
79  {
80  Unroll(dimension + 1, srcData, dstData, srcEnd, dstEnd, dataTypeSize);
81 
82  srcData += m_SrcStrides[dimension] * dataTypeSize;
83  dstData += m_DstStrides[dimension] * dataTypeSize;
84  }
85  }
86  }
87 
88  armnn::TensorShape m_DstShape;
89  std::array<size_type, armnn::MaxNumOfTensorDimensions> m_SrcStrides;
90  std::array<size_type, armnn::MaxNumOfTensorDimensions> m_DstStrides;
91 };
92 
93 } // namespace
94 
95 namespace armnnUtils
96 {
97 
99  const armnn::PermutationVector& mappings)
100 {
101  assert(srcShape.GetNumDimensions() == mappings.GetSize());
102 
103  const unsigned int numDims = mappings.GetSize();
104  unsigned int outDims[armnn::MaxNumOfTensorDimensions];
105 
106  for (unsigned int i = 0U; i < numDims; ++i)
107  {
108  outDims[mappings[i]] = srcShape[i];
109  }
110 
111  armnn::TensorShape permutedShape(numDims, outDims);
112  return permutedShape;
113 }
114 
116  const armnn::PermutationVector& mappings,
117  bool perChannelPermute)
118 {
119  armnn::TensorInfo outInfo(info);
120  outInfo.SetShape(Permuted(info.GetShape(), mappings));
121 
122  // If TensorInfo has Per-Axis Quantization then permute QuantizationDim to mapping
123  if (info.HasPerAxisQuantization() && perChannelPermute)
124  {
125  outInfo.SetQuantizationDim(mappings[info.GetQuantizationDim().value()]);
126  }
127 
128  return outInfo;
129 }
130 
131 void Permute(const armnn::TensorShape& dstShape, const armnn::PermutationVector& mappings,
132  const void* src, void* dst, size_t dataTypeSize)
133 {
134  PermuteLoop(dstShape, mappings).Unroll(src, dst, dataTypeSize);
135 }
136 
137 } // namespace armnnUtils
+
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
+ +
bool HasPerAxisQuantization() const
Definition: Tensor.cpp:437
+
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:485
+ +
SizeType GetSize() const
Definition: Types.hpp:241
+ +
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
+
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
+ + +
void SetQuantizationDim(const Optional< unsigned int > &quantizationDim)
Definition: Tensor.cpp:490
+ +
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
+ +
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98
+
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18
+
+
+ + + + -- cgit v1.2.1