diff --git a/sw/snRuntime/src/dma.h b/sw/snRuntime/src/dma.h index fb39f1942..578cba15d 100644 --- a/sw/snRuntime/src/dma.h +++ b/sw/snRuntime/src/dma.h @@ -233,6 +233,30 @@ inline snrt_dma_txid_t snrt_dma_load_2d_tile( ); } +/// Transfer a tile and transpose it +inline void snrt_dma_load_2d_tile_transpose( + void *dst, void *src, size_t tile_x1_idx, size_t tile_x0_idx, + size_t tile_x1_size, size_t tile_x0_size, size_t full_x0_size, + uint32_t prec) { + size_t src_offset = 0; + // Advance src array in x0 and x1 dimensions, and convert to byte offset + src_offset += tile_x0_idx * tile_x0_size; + src_offset += tile_x1_idx * tile_x1_size * full_x0_size; + src_offset *= prec; + // Initiate transfer + for (uint32_t i = 0; i < tile_x0_size; i++) + { + snrt_dma_start_2d(dst + i * tile_x1_size * prec, // dst + src + src_offset + i * prec, // src + prec, // size + prec, // dst_stride + full_x0_size * prec, // src_stride + tile_x1_size // repeat + ); + + } +} + /// Store a 2D-tile of shape (tile_x1_size, tile_x0_size) to the 2D array /// of shape (full_x1_size, full_x0_size). The specific tile is selected /// by the (tile_x1_idx, tile_x0_idx) tuple. Every element in the src and