15 #include <fmt/format.h>
27 fmt::format(
"The number of mappings ({0}) cannot be greater "
28 "than the maximum number of dimensions supported ({1})",
33 if ((dimMappings ==
nullptr) && (numDimMappings != 0))
38 for (
SizeType i = 0; i < numDimMappings; ++i)
40 const ValueType dstIndex = dimMappings[i];
41 if (dstIndex >= numDimMappings)
44 fmt::format(
"Dimension mapping at index {0} is invalid: "
45 "{1} is outside of the valid range [0,{2}]",
48 (numDimMappings - 1)));
54 std::array<bool, MaxNumOfTensorDimensions> observedDims;
55 observedDims.fill(
false);
57 for (
SizeType i = 0; i < numDimMappings; ++i)
59 const ValueType dstIndex = dimMappings[i];
60 if (observedDims[dstIndex])
63 "to the same output dimension");
65 observedDims[dstIndex] =
true;
70 for (
SizeType i = 0; i < numDimMappings; ++i)
72 m_DimMappings[i] = dimMappings[i];
74 m_NumDimMappings = numDimMappings;
86 , m_ViewOrigins(nullptr)
91 , m_NumViews(numViews)
92 , m_NumDimensions(numDimensions)
93 , m_ViewOrigins(numViews && numDimensions > 0 ? new uint32_t *[numViews]() : nullptr)
95 for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
97 m_ViewOrigins[i] =
new uint32_t[m_NumDimensions]();
102 : m_ConcatAxis(other.m_ConcatAxis)
103 , m_NumViews(other.m_NumViews)
104 , m_NumDimensions(other.m_NumDimensions)
105 , m_ViewOrigins(other.m_NumViews && other.m_NumDimensions > 0 ? new uint32_t *[other.m_NumViews]() : nullptr)
107 for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
109 m_ViewOrigins[i] =
new uint32_t[m_NumDimensions]();
110 memcpy(m_ViewOrigins[i], other.m_ViewOrigins[i], m_NumDimensions *
sizeof(uint32_t));
122 for (uint32_t i = 0; m_NumDimensions > 0 && i < m_NumViews; ++i)
124 delete[] m_ViewOrigins[i];
126 delete[] m_ViewOrigins;
160 m_ConcatAxis = concatAxis;
169 if (view >= m_NumViews)
171 ARMNN_LOG(
error) <<
"OriginsDescriptor::SetViewOriginCoord: view argument:" << view <<
175 if (coord >= m_NumDimensions)
177 ARMNN_LOG(
error) <<
"OriginsDescriptor::SetViewOriginCoord: coord argument:" << coord <<
182 m_ViewOrigins[view][coord] = value;
194 return m_NumDimensions;
199 return m_ViewOrigins ? m_ViewOrigins[idx] :
nullptr;
207 "number of views must match number of elements in the new ordering array");
209 std::vector<uint32_t*> viewOrigins(&m_ViewOrigins[0], &m_ViewOrigins[m_NumViews]);
211 for (
unsigned int i = 0; i < numNewOrdering; ++i)
213 m_ViewOrigins[i] = viewOrigins[newOrdering[i]];
219 , m_ViewSizes(nullptr)
225 : m_Origins(numViews, numDimensions)
226 , m_ViewSizes(numViews > 0 && numDimensions > 0 ?
227 new uint32_t *[numViews]() : nullptr)
241 : m_Origins(other.m_Origins)
242 , m_ViewSizes(other.GetNumViews() > 0 && other.GetNumDimensions() > 0 ?
243 new uint32_t *[other.GetNumViews()]() : nullptr)
244 , m_IsAxisSet(other.m_IsAxisSet)
245 , m_Axis(other.m_Axis)
252 memcpy(m_ViewSizes[i], other.m_ViewSizes[i],
GetNumDimensions() *
sizeof(uint32_t));
269 delete[] m_ViewSizes[i];
271 delete[] m_ViewSizes;
326 ARMNN_LOG(
error) <<
"ViewsDescriptor::SetViewSize: invalid view sizes";
332 ARMNN_LOG(
error) <<
"ViewsDescriptor::SetViewSize: view argument:" << view <<
338 ARMNN_LOG(
error) <<
"ViewsDescriptor::SetViewSize: coord argument:" << coord <<
343 m_ViewSizes[view][coord] = value;
349 return m_ViewSizes ? m_ViewSizes[idx] :
nullptr;
360 swap(first.m_NumViews, second.m_NumViews);
361 swap(first.m_NumDimensions, second.m_NumDimensions);
362 swap(first.m_ViewOrigins, second.m_ViewOrigins);
363 swap(first.m_ConcatAxis, second.m_ConcatAxis);
369 swap(first.m_Origins, second.m_Origins);
370 swap(first.m_ViewSizes, second.m_ViewSizes);
371 swap(first.m_IsAxisSet, second.m_IsAxisSet);
372 swap(first.m_Axis, second.m_Axis);
394 unsigned int axis)
const
402 start = std::numeric_limits<int>::min();
406 start = std::numeric_limits<int>::max();
410 const int axisSize = armnn::numeric_cast<int>(inputShape[axis]);
416 return std::max(0, std::min(start, axisSize - 1));
422 int startForAxis)
const
427 return startForAxis + 1;
430 int stop =
m_End[axis];
436 stop = std::numeric_limits<int>::max();
440 stop = std::numeric_limits<int>::min();
444 const int axisSize = armnn::numeric_cast<int>(inputShape[axis]);
450 return m_Stride[axis] > 0 ? std::max(0, std::min(stop, axisSize)) :
451 std::max(-1, std::min(stop, axisSize - 1));
457 unsigned int numInputs = 2;
490 std::pair<unsigned int, unsigned int> axes = { numDims-2, numDims-1 };
511 std::vector<unsigned int> axesNotMul;
514 if(i == axesToMul.first || i == axesToMul.second)
518 axesNotMul.push_back(i);
527 std::vector<unsigned int> vec;
531 if(i == axesToMul.first)
535 else if(i == axesToMul.second)
545 static_cast<unsigned int>(vec.size()));