| 37 | { |
| 38 | template <typename T> |
| 39 | SimpleTensor<T> permute(const SimpleTensor<T> &src, PermutationVector perm) |
| 40 | { |
| 41 | // Permute shapes |
| 42 | TensorShape dst_shape = src.shape(); |
| 43 | permute(dst_shape, perm); |
| 44 | |
| 45 | // Create reference |
| 46 | SimpleTensor<T> dst{dst_shape, src.data_type(), src.num_channels(), src.quantization_info()}; |
| 47 | |
| 48 | // Compute reference |
| 49 | const uint32_t num_elements = src.num_elements(); |
| 50 | for (uint32_t i = 0; i < num_elements; ++i) |
| 51 | { |
| 52 | const Coordinates src_coords = index2coord(src.shape(), i); |
| 53 | Coordinates dst_coords = src_coords; |
| 54 | permute(dst_coords, perm); |
| 55 | |
| 56 | std::copy_n(static_cast<const T *>(src(src_coords)), src.num_channels(), static_cast<T *>(dst(dst_coords))); |
| 57 | } |
| 58 | |
| 59 | return dst; |
| 60 | } |
| 61 | |
| 62 | template SimpleTensor<int8_t> permute(const SimpleTensor<int8_t> &src, PermutationVector perm); |
| 63 | template SimpleTensor<uint8_t> permute(const SimpleTensor<uint8_t> &src, PermutationVector perm); |
no test coverage detected