| 36 | namespace |
| 37 | { |
| 38 | inline Coordinates expand_coordinates(Coordinates in_coord, size_t axis, size_t slice, size_t num_dimensions) |
| 39 | { |
| 40 | /* |
| 41 | Reconstruct input_coord to read the corresponding value from the correct slice. This is done by adding an extra dimension |
| 42 | to the coordinates and shuffling around the values based on the info below. |
| 43 | |
| 44 | For example, if input tensor shape is (X, Y, Z, W); |
| 45 | |
| 46 | If axis == 0, each slice will have the shape (Y, Z, W) and there will be X slices |
| 47 | |
| 48 | If axis == 1, each slice will have the shape (X, Z, W) and there will be Y slices. |
| 49 | */ |
| 50 | Coordinates expanded_coord; |
| 51 | expanded_coord.set_num_dimensions(num_dimensions); |
| 52 | expanded_coord.set(axis, slice); |
| 53 | for (size_t k = 0; k < axis; ++k) |
| 54 | { |
| 55 | expanded_coord.set(k, in_coord[k]); |
| 56 | } |
| 57 | for (size_t k = axis + 1; k < num_dimensions; ++k) |
| 58 | { |
| 59 | expanded_coord.set(k, in_coord[k - 1]); |
| 60 | } |
| 61 | return expanded_coord; |
| 62 | } |
| 63 | |
| 64 | template <typename T> |
| 65 | SimpleTensor<T> get_slice(const SimpleTensor<T> &input_tensor, size_t axis, size_t slice) |
no test coverage detected