17 inline std::vector<unsigned int> IndexToCoord(
const armnn::TensorShape& shape,
unsigned int index)
27 numOfElements /= shape[i];
28 coord[i] = index / numOfElements;
29 index %= numOfElements;
37 inline unsigned int CoordToIndex(
const armnn::TensorShape& shape,
const std::vector<unsigned int>& coord)
42 unsigned int index = 0;
43 unsigned int dimSize = 1;
47 index += coord[i - 1] * dimSize;
48 dimSize *= shape[i - 1];
78 for(
unsigned int i = 0; i < padList.size(); ++i)
80 if(padList.at(i).first > (inputShape[i] - isReflect) ||
81 padList.at(i).second > (inputShape[i] - isReflect))
84 "equal (Symmetric) to the dimension size.");
88 auto inputData = MakeDecoder<float>(inputInfo, inputHandle->
Map());
89 auto outData = MakeEncoder<float>(outputInfo, outputHandle->
Map());
94 for(
unsigned int idx = 0; idx < numOutputElements; ++idx)
97 const std::vector<unsigned int> coord = IndexToCoord(outputShape, idx);
99 std::vector<unsigned int> dimensions;
100 std::vector<unsigned int> coords;
102 for(
unsigned int i = 0; i < numInputDimensions; ++i)
104 dimensions.emplace_back(i);
105 coords.emplace_back(coord[i]);
108 auto isInPadding = [&](
unsigned int i)
110 return (coords[i] < padList[i].first || coords[i] > inputShape[i] + padList[i].first - 1);
113 auto getReflectIndex = [&](
unsigned int i) ->
unsigned int
117 if(coords[i] < padList[i].first)
119 return padList[i].first - coords[i];
123 return 2 * inputShape[i] + padList[i].first - 2 - coords[i];
126 return coords[i] - padList[i].first;
129 auto getSymmetricIndex = [&](
unsigned int i) ->
unsigned int
133 if(coords[i] < padList[i].first)
135 return padList[i].first - coords[i] - 1;
139 return 2 * inputShape[i] + padList[i].first - 1 - coords[i];
142 return coords[i] - padList[i].first;
146 std::vector<unsigned int> coordOfInput;
155 if(std::any_of(dimensions.begin(), dimensions.end(), isInPadding))
161 for(
unsigned int i = 0; i < numInputDimensions; ++i)
163 coordOfInput.emplace_back(getReflectIndex(i));
169 for(
unsigned int i = 0; i < numInputDimensions; ++i)
171 coordOfInput.emplace_back(getSymmetricIndex(i));
182 for(
unsigned int i = 0; i < numInputDimensions; ++i)
184 coordOfInput.emplace_back(coord[i] - padList[i].first);
189 const unsigned int indexOfInput = CoordToIndex(inputShape, coordOfInput);
192 auto inputValue = input.
Get();
195 output.
Set(inputValue);