From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- ...2reference_2workloads_2_slice_8cpp_source.xhtml | 125 +++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 20.02/backends_2reference_2workloads_2_slice_8cpp_source.xhtml (limited to '20.02/backends_2reference_2workloads_2_slice_8cpp_source.xhtml') diff --git a/20.02/backends_2reference_2workloads_2_slice_8cpp_source.xhtml b/20.02/backends_2reference_2workloads_2_slice_8cpp_source.xhtml new file mode 100644 index 0000000000..900dc2fcc9 --- /dev/null +++ b/20.02/backends_2reference_2workloads_2_slice_8cpp_source.xhtml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + +ArmNN: src/backends/reference/workloads/Slice.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Slice.cpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "Slice.hpp"
7 
9 
10 #include <boost/assert.hpp>
11 #include <boost/numeric/conversion/cast.hpp>
12 
13 namespace armnn
14 {
15 
16 void Slice(const TensorInfo& inputInfo,
17  const SliceDescriptor& descriptor,
18  const void* inputData,
19  void* outputData,
20  unsigned int dataTypeSize)
21 {
22  const TensorShape& inputShape = inputInfo.GetShape();
23  const unsigned int numDims = inputShape.GetNumDimensions();
24 
25  BOOST_ASSERT(descriptor.m_Begin.size() == numDims);
26  BOOST_ASSERT(descriptor.m_Size.size() == numDims);
27 
28  constexpr unsigned int maxNumDims = 4;
29  BOOST_ASSERT(numDims <= maxNumDims);
30 
31  std::vector<unsigned int> paddedInput(4);
32  std::vector<unsigned int> paddedBegin(4);
33  std::vector<unsigned int> paddedSize (4);
34 
35  const unsigned int numPaddingDims = maxNumDims - numDims;
36  for (unsigned int i = 0u; i < maxNumDims; ++i)
37  {
38  if (i < numPaddingDims)
39  {
40  paddedInput[i] = 1u;
41  paddedBegin[i] = 0u;
42  paddedSize[i] = 1u;
43  }
44  else
45  {
46  const unsigned int j = i - numPaddingDims;
47  paddedInput[i] = inputShape[j];
48  paddedBegin[i] = descriptor.m_Begin[j];
49  paddedSize[i] = descriptor.m_Size[j];
50  }
51  }
52 
53  unsigned int dim0 = paddedInput[0];
54  unsigned int dim1 = paddedInput[1];
55  unsigned int dim2 = paddedInput[2];
56  unsigned int dim3 = paddedInput[3];
57 
58  unsigned int begin0 = paddedBegin[0];
59  unsigned int begin1 = paddedBegin[1];
60  unsigned int begin2 = paddedBegin[2];
61  unsigned int begin3 = paddedBegin[3];
62 
63  unsigned int size0 = paddedSize[0];
64  unsigned int size1 = paddedSize[1];
65  unsigned int size2 = paddedSize[2];
66  unsigned int size3 = paddedSize[3];
67 
68  BOOST_ASSERT(begin0 + size0 <= dim0);
69  BOOST_ASSERT(begin1 + size1 <= dim1);
70  BOOST_ASSERT(begin2 + size2 <= dim2);
71  BOOST_ASSERT(begin3 + size3 <= dim3);
72 
73  const unsigned char* input = reinterpret_cast<const unsigned char*>(inputData);
74  unsigned char* output = reinterpret_cast<unsigned char*>(outputData);
75 
76  IgnoreUnused(dim0);
77  for (unsigned int idx0 = begin0; idx0 < begin0 + size0; ++idx0)
78  {
79  for (unsigned int idx1 = begin1; idx1 < begin1 + size1; ++idx1)
80  {
81  for (unsigned int idx2 = begin2; idx2 < begin2 + size2; ++idx2)
82  {
83  for (unsigned int idx3 = begin3; idx3 < begin3 + size3; ++idx3)
84  {
85  const unsigned int inputOffset =
86  (((idx0 * dim1 + idx1) * dim2 + idx2) * dim3 + idx3) * dataTypeSize;
87 
88  ::memcpy(output, input + inputOffset, dataTypeSize);
89  output += dataTypeSize;
90  }
91  }
92  }
93  }
94 }
95 
96 } // namespace armnn
+
void Slice(const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
Definition: Slice.cpp:16
+
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
+ +
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
+
Copyright (c) 2020 ARM Limited.
+
void IgnoreUnused(Ts &&...)
+ +
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
+
A SliceDescriptor for the SliceLayer.
+
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:43
+ +
+
+ + + + -- cgit v1.2.1