| 254 | } |
| 255 | |
| 256 | std::vector<int64> ReorderDims(const std::vector<int64>& input, |
| 257 | const DataLayout& from, const DataLayout& to) { |
| 258 | if (from == to) return input; |
| 259 | |
| 260 | int d_idx_from, b_idx_from, spatial_idx_from; |
| 261 | int d_idx_to, b_idx_to, spatial_idx_to; |
| 262 | |
| 263 | std::tie(d_idx_from, b_idx_from, spatial_idx_from) = |
| 264 | GetDimIndices(from, input.size()); |
| 265 | std::tie(d_idx_to, b_idx_to, spatial_idx_to) = |
| 266 | GetDimIndices(to, input.size()); |
| 267 | |
| 268 | std::vector<int64> reordered(input.size()); |
| 269 | reordered[b_idx_to] = input[b_idx_from]; |
| 270 | reordered[d_idx_to] = input[d_idx_from]; |
| 271 | |
| 272 | for (size_t i = 0; i < input.size() - 2; |
| 273 | i++, spatial_idx_from++, spatial_idx_to++) { |
| 274 | reordered[spatial_idx_to] = input[spatial_idx_from]; |
| 275 | } |
| 276 | |
| 277 | return reordered; |
| 278 | } |
| 279 | |
| 280 | // -- AlgorithmConfig |
| 281 |
no test coverage detected