17 unsigned int inputRank,
18 std::vector<unsigned int>& elementNumInner)
20 std::vector<unsigned int> indexList(inputRank);
22 unsigned int mIdx = idx;
24 for (
unsigned int iDim = 0; iDim < inputRank; ++iDim)
26 indexList[iDim] =
static_cast<unsigned int>(mIdx / elementNumInner[iDim]);
27 mIdx %= elementNumInner[iDim];
35 unsigned int inputRank,
36 std::vector<unsigned int>& elementNumInner)
40 for (
unsigned int iDim = 0; iDim < inputRank; ++iDim)
42 idx += idxList[iDim] * elementNumInner[iDim];
50 unsigned int inputRank,
51 std::vector<bool>& axisFlag,
52 std::vector<unsigned int>& dimSize,
53 std::vector<unsigned int>& elementNumInner)
58 std::vector<unsigned int> outputIdxList(inputRank);
61 for (
unsigned int iDim = 0; iDim < inputRank; ++iDim)
65 outputIdxList[iDim] = dimSize[iDim] - inputIdxList[iDim] - 1;
69 outputIdxList[iDim] = inputIdxList[iDim];
74 unsigned int outputIdx =
ReverseGetFlatIdx(outputIdxList, inputRank, elementNumInner);
84 unsigned int axesRank =
static_cast<unsigned int>(axisInfo.
GetNumElements());
91 float inputValue = inputDecoder.
Get();
93 outputEncoder.
Set(inputValue);
99 unsigned int inputRank =
static_cast<unsigned int>(inputInfo.
GetNumDimensions());
101 std::vector<bool> axisFlag(inputRank,
false);
102 std::vector<unsigned int> dimSize(inputRank, 0);
103 std::vector<int32_t> axis(axesRank, 0);
106 for (
unsigned int i=0; i < axesRank; i++)
108 axis[i] = axisDecoder.
Get();
113 for (int32_t axisElement: axis)
115 axisElement = axisElement < 0 ? axisElement + static_cast<int32_t>(inputRank) : axisElement;
116 axisFlag[
static_cast<uint32_t
>(axisElement)] =
true;
122 unsigned int baseDimSize = 1;
124 std::vector<unsigned int> elementNumInner;
127 for (
unsigned int iDim = 0; iDim < inputRank; ++iDim) {
128 dimSize[iDim] = inputShape[iDim];
129 baseDimSize *= dimSize[iDim];
130 elementNumInner.push_back(
static_cast<unsigned int>(elementNum / baseDimSize));
134 for (
unsigned int idx = 0; idx < elementNum; ++idx)
136 float inputValue = inputDecoder.
Get();
138 auto outputIdx =
ReverseRelocateIdx(idx, inputRank, axisFlag, dimSize, elementNumInner);
139 outputEncoder[outputIdx];
140 outputEncoder.
Set(inputValue);