| 37 | { |
| 38 | template <typename T> |
| 39 | SimpleTensor<T> transpose(const SimpleTensor<T> &src) |
| 40 | { |
| 41 | // Make rows the columns of the original shape |
| 42 | TensorShape dst_shape{src.shape().y(), src.shape().x()}; |
| 43 | |
| 44 | // Create reference |
| 45 | SimpleTensor<T> dst{dst_shape, src.data_type()}; |
| 46 | |
| 47 | // Compute reference |
| 48 | const uint32_t num_elements = src.num_elements(); |
| 49 | for (uint32_t i = 0; i < num_elements; ++i) |
| 50 | { |
| 51 | const Coordinates coord = index2coord(src.shape(), i); |
| 52 | const Coordinates dst_coord{coord.y(), coord.x()}; |
| 53 | const size_t dst_index = coord2index(dst.shape(), dst_coord); |
| 54 | |
| 55 | dst[dst_index] = src[i]; |
| 56 | } |
| 57 | |
| 58 | return dst; |
| 59 | } |
| 60 | |
| 61 | template SimpleTensor<uint8_t> transpose(const SimpleTensor<uint8_t> &src); |
| 62 | template SimpleTensor<uint16_t> transpose(const SimpleTensor<uint16_t> &src); |
nothing calls this directly
no test coverage detected