Skip to content

Commit

Permalink
snrt_dma_load_2d_tile_transpose
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerbarton committed Feb 6, 2024
1 parent 17ede54 commit 7c2bba9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions sw/snRuntime/src/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c2bba9

Please sign in to comment.