| 106 | } |
| 107 | |
| 108 | TensorShape ReduceDims(const TensorShape& tensorShape, unsigned int dimensions) |
| 109 | { |
| 110 | if (tensorShape.GetNumDimensions() <= dimensions) |
| 111 | { |
| 112 | return tensorShape; |
| 113 | } |
| 114 | std::vector<unsigned int> newShape; |
| 115 | |
| 116 | unsigned int dimsToSkip = tensorShape.GetNumDimensions() - dimensions; |
| 117 | unsigned int dimsSkipped = 0; |
| 118 | bool insertRemainder = false; |
| 119 | |
| 120 | for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i) |
| 121 | { |
| 122 | if (tensorShape[i] == 1 && dimsSkipped < dimsToSkip && !insertRemainder) |
| 123 | { |
| 124 | ++dimsSkipped; |
| 125 | continue; |
| 126 | } |
| 127 | newShape.push_back(tensorShape[i]); |
| 128 | // Once we insert the first dimension we can't skip any more |
| 129 | insertRemainder = true; |
| 130 | } |
| 131 | return TensorShape(static_cast<unsigned int>(newShape.size()), newShape.data()); |
| 132 | } |
| 133 | |
| 134 | TensorInfo ReduceDims(const TensorInfo& tensorInfo, unsigned int dimensions) |
| 135 | { |
no test coverage detected