21 unsigned int carry = 1;
23 for (
unsigned int idx = numDims; idx-- > 0; )
25 unsigned int current_val = current[idx] + carry;
26 if (dims[idx] == current_val)
32 current[idx] = current_val;
42 std::vector<unsigned int>& index,
43 const unsigned int numAxis,
44 const std::vector<unsigned int>& axis)
46 unsigned int offset = 0;
47 for (
unsigned int idx = 0; idx < numDims; ++idx)
52 for (
unsigned int axisIdx = 0; axisIdx < numAxis; ++axisIdx)
54 if (idx == axis[axisIdx])
63 offset = offset * dims[idx] + index[idx];
74 const std::vector<uint32_t> axis,
82 std::vector<float> tempOut(numOutputs);
83 switch(reduceOperation)
87 std::fill(tempOut.begin(), tempOut.end(), 0.0f);
90 std::fill(tempOut.begin(), tempOut.end(), 1.0f);
93 std::fill(tempOut.begin(), tempOut.end(), -1 * std::numeric_limits<float>::max());
96 std::fill(tempOut.begin(), tempOut.end(), std::numeric_limits<float>::max());
100 std::to_string(
static_cast<int>(reduceOperation)));
104 std::vector<unsigned int> tempIndex(inputNumDims, 0);
106 std::vector<unsigned int> resolvedAxis = axis;
107 if (resolvedAxis.empty())
109 for (
unsigned int idx = 0; idx < inputNumDims; ++idx)
111 resolvedAxis.push_back(idx);
114 auto numResolvedAxis = armnn::numeric_cast<unsigned int>(resolvedAxis.size());
117 for (
bool hasNext =
true; hasNext; hasNext =
NextIndex(inputNumDims, inputDims, tempIndex))
121 numResolvedAxis, resolvedAxis);
123 auto inputValue = input.
Get();
124 switch(reduceOperation)
128 tempOut[outputOffset] += inputValue;
131 tempOut[outputOffset] *= inputValue;
134 if (inputValue > tempOut[outputOffset])
136 tempOut[outputOffset] = inputValue;
140 if (inputValue < tempOut[outputOffset])
142 tempOut[outputOffset] = inputValue;
147 std::to_string(
static_cast<int>(reduceOperation)));
152 size_t numElementsInAxis = 1;
153 for (
unsigned int idx = 0; idx < numResolvedAxis; ++idx)
155 unsigned int current = inputDims[resolvedAxis[idx]];
156 numElementsInAxis *= current;
159 for (
unsigned int idx = 0; idx < numOutputs; ++idx)
164 if (numElementsInAxis > 0)
166 output.
Set(tempOut[idx] / armnn::numeric_cast<float>(numElementsInAxis));
171 output.
Set(tempOut[idx]);