Files
composable_kernel/experimental/builder/include/ck_tile/builder/factory
Ville Pietilä 419aa4e420 [CK_BUILDER] Refactor convolution signature to provide data type/layout/elementwise op per tensor (#3331)
* Separate layouts into separate entities for input, weight, and output tensors.

* Add test for handling bias tensor layouts.

* Use instance string in builder tests.

* Add handling of output bias data types and layouts.

* Generalize handling of the elementwise ops.

* Test fix.

* Create builder for layouts.

* Layout builder improvements.

* Improve layout builder.

* Simplify bias layout handling.

* Code clean-up.

* Move layout utils into separate file.

* Remove hard-coded layout combinations.

* Small code clean-up.

* Move data type utils into a separate file.

* Add data types, layouts, and elementwise ops per conv tensor.

* Builder bug fixes after refactoring.

* Working baseline.

* Make signature definition look nice in the test code.

* Move TensorConfig into test implementations.

* Fix all fwd conv builder tests.

* Fix conv traits and descriptors tests.

* More factory assets under a separate directory.

* Fix building conv traits.

* Fix clang-format.

* Add Readme doc to describe the design.

* Add link to main Readme. Fix links in the builder design doc.

* Clean-up data type/layout/elementwise op conversions.

* Switch from dimension and tensor type specific layouts to a flat list of tensor layouts.

* Fix clang-formatting.

* Fix clang-format for test code.

* Simplify fwd conv signature definitions in the test code.

* Remove accidental edits.

* Fix comment string.

* Fix instance factory after rebase.

* Fix tests after rebase.

* Unify layout handling.

* Add more conv layout unit tests.

* Clang-format.

* Fix merge conflicts.

* Improve elementwise op handling.

---------

Co-authored-by: Ville Pietilä <>

[ROCm/composable_kernel commit: 9cb1f421bc]
2025-12-04 12:58:31 +02:00
..

Convolution Builder Factory Directory

This directory implements compile-time dispatch from high-level signature algorithm descriptors to our exisitng specialized convolution kernel implementations.

See the main builder documentation for an overview.

Design Overview

The factory system operates in two phases:

  1. Algorithm Classification: The function make_conv_instance in conv_dispatcher.hpp inspects the signature and algorithm descriptors to determine which kernel variant they satisfy (XDL V3, XDL, WMMA, DL, or Large Tensor)

  2. Factory Instantiation: Each factory (conv_fwd_*_factory.hpp) transforms builder descriptors into CK device operation template parameters and instantiates the corresponding kernel device operation.

Key Files

  • conv_dispatcher.hpp: Entry point with make_conv_instance() function. Contains dispatch logic and algorithm classification predicates. Start here to understand the overall flow.

  • conv_fwd_*_factory.hpp: Individual factories for each kernel variant. Each extracts configuration from descriptors, validates parameters, and instantiates the underlying CK device operation.

  • helpers/: Transformation utilities that map builder types to CK device operation parameters (layouts, data types, elementwise ops, block configurations, etc.)

Usage

#include "ck_tile/builder/factory/conv_dispatcher.hpp"

using Factory = decltype(make_conv_instance<signature, algorithm, "v1">());

The dispatcher automatically selects the appropriate factory following explicit logic.