Files
composable_kernel/example/ck_tile/04_img2col
Max Podkorytov 79aae7c7f7 [CK Tile] enable building examples by default (#3259)
* remove EXCLUDE_FROM_ALL from ck-tile examples
-> +15 min build time w/ 64 threads for a single arch

* fix cpp17 compile error in the ck-tile examples

---------

Co-authored-by: khuagarw <khuagarw@amd.com>
Co-authored-by: Ding, Yi <yi.ding@amd.com>
2025-11-26 16:24:44 -08:00
..

Image to Column (im2col) with CK Tile

This example demonstrates the im2col transformation using the CK Tile programming model, a key step for converting convolution into GEMM for efficient GPU execution.


Algorithm and Math

Given an input image tensor X and convolution kernel size, im2col rearranges sliding windows of X into columns:

  • For each patch, flatten and stack as a column in the output matrix.
  • Enables convolution as matrix multiplication: \text{im2col}(X) \times W.

Tile Programming Model

  • Tiles: Each thread block processes a tile (block of patches).
  • Pipeline: Modular, can be extended for fused operations (e.g., quantization, activation).

Build & Run

mkdir build && cd build
# you can replace <arch> with the appropriate architecture (for example gfx90a or gfx942) or leave it blank
../script/cmake-ck-dev.sh  ../ <arch>
make tile_example_img2col -j
./bin/tile_example_img2col -?

Source Structure

  • Kernel: image_to_column.hpp (tile-programming kernel template)
  • Executable: image_to_column.cpp (argument parsing, kernel launch)
  • Build: CMakeLists.txt

For distribution, see include/ck_tile/tile_program/tile_distribution/.


Back to CK Tile Examples