| 168 | } |
| 169 | |
| 170 | TensorShape ExpandDimsToRank(const TensorShape& tensorShape, unsigned int rank) |
| 171 | { |
| 172 | // Can't expand if rank is smaller than current shape |
| 173 | if (tensorShape.GetNumDimensions() >= rank) |
| 174 | { |
| 175 | return tensorShape; |
| 176 | } |
| 177 | |
| 178 | std::vector<unsigned int> newShape; |
| 179 | |
| 180 | // First add 1s to the beginning of the tensorInfo to fill in the space |
| 181 | for (unsigned int i = 0; i < rank - tensorShape.GetNumDimensions(); ++i) |
| 182 | { |
| 183 | newShape.push_back(1); |
| 184 | } |
| 185 | |
| 186 | // Then iterate through the original shape and append it to the new shape with the added 1s |
| 187 | for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i) |
| 188 | { |
| 189 | newShape.push_back(tensorShape[i]); |
| 190 | } |
| 191 | |
| 192 | return TensorShape(static_cast<unsigned int>(newShape.size()), newShape.data()); |
| 193 | } |
| 194 | |
| 195 | std::vector<unsigned int> SqueezeDims(const TensorShape& tensorShape) |
| 196 | { |
no test coverage detected