| 63 | |
| 64 | template <typename T> |
| 65 | SimpleTensor<T> get_slice(const SimpleTensor<T> &input_tensor, size_t axis, size_t slice) |
| 66 | { |
| 67 | TensorShape out_shape = input_tensor.shape(); |
| 68 | out_shape.remove_dimension(axis); |
| 69 | |
| 70 | const size_t unpacked_num_dimensions(input_tensor.shape().num_dimensions()); |
| 71 | |
| 72 | SimpleTensor<T> output{out_shape, input_tensor.data_type()}; |
| 73 | |
| 74 | Window win; |
| 75 | win.use_tensor_dimensions(out_shape); |
| 76 | execute_window_loop(win, |
| 77 | [&](const Coordinates &id) |
| 78 | { |
| 79 | const Coordinates input_coords = |
| 80 | expand_coordinates(id, axis, slice, unpacked_num_dimensions); |
| 81 | *reinterpret_cast<T *>(output(id)) = |
| 82 | *reinterpret_cast<const T *>(input_tensor(input_coords)); |
| 83 | }); |
| 84 | |
| 85 | return output; |
| 86 | } |
| 87 | } // namespace |
| 88 | |
| 89 | template <typename T> |
no test coverage detected