- Parameters
-
dimMappings | - Indicates how to translate tensor elements from a given source into the target destination, when source and target potentially have different memory layouts. |
E.g. For a 4-d tensor laid out in a memory with the format (Batch Element, Height, Width, Channels), which is to be passed as an input to ArmNN, each source dimension is mapped to the corresponding ArmNN dimension. The Batch dimension remains the same (0 -> 0). The source Height dimension is mapped to the location of the ArmNN Height dimension (1 -> 2). Similar arguments are made for the Width and Channels (2 -> 3 and 3 -> 1). This will lead to m_DimMappings pointing to the following array: [ 0, 2, 3, 1 ].
Note that the mapping should be reversed if considering the case of ArmNN 4-d outputs (Batch Element, Channels, Height, Width) being written to a destination with the format mentioned above. We now have 0 -> 0, 2 -> 1, 3 -> 2, 1 -> 3, which, when reordered, lead to the following m_DimMappings contents: [ 0, 3, 1, 2 ].
Definition at line 18 of file Descriptors.cpp.
References armnn::MaxNumOfTensorDimensions.
24 boost::format fmt(
"The number of mappings (%1%) cannot be greater " 25 "than the maximum number of dimensions supported (%2%)");
29 if ((dimMappings ==
nullptr) && (numDimMappings != 0))
31 throw InvalidArgumentException(
"Dimension mappings must not be NULL if the number of mappings is positive");
34 for (
SizeType i = 0; i < numDimMappings; ++i)
36 const ValueType dstIndex = dimMappings[i];
37 if (dstIndex >= numDimMappings)
39 boost::format fmt(
"Dimension mapping at index %1% is invalid: %2% is outside of the valid range [0,%3%]");
40 throw InvalidArgumentException(boost::str(fmt % i % dstIndex % (numDimMappings - 1)));
46 std::array<bool, MaxNumOfTensorDimensions> observedDims;
47 observedDims.fill(
false);
49 for (
SizeType i = 0; i < numDimMappings; ++i)
51 const ValueType dstIndex = dimMappings[i];
52 if (observedDims[dstIndex])
54 throw InvalidArgumentException(
"Invalid dimension mappings: Two or more source dimensions are mapped " 55 "to the same output dimension");
57 observedDims[dstIndex] =
true;
62 for (
SizeType i = 0; i < numDimMappings; ++i)
64 m_DimMappings[i] = dimMappings[i];
66 m_NumDimMappings = numDimMappings;
constexpr unsigned int MaxNumOfTensorDimensions