[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ä <>
This commit is contained in:
Ville Pietilä
2025-12-04 12:58:31 +02:00
committed by GitHub
parent 583fafc803
commit 9cb1f421bc
37 changed files with 1731 additions and 617 deletions

View File

@@ -8,30 +8,38 @@
namespace {
using ::ck_tile::builder::factory::internal::ElementwiseOps;
using enum ::ck_tile::builder::ElementwiseOperation;
using ::ck_tile::builder::ElementwiseOperation;
using ::ck_tile::builder::factory::internal::ElementwiseOpToCK;
TEST(ConvElementwiseOp, AssignsOpsForPassThrough)
{
using Ops = ElementwiseOps<PASS_THROUGH>;
EXPECT_TRUE(
(std::is_same_v<Ops::AElementwiseOp, ck::tensor_operation::element_wise::PassThrough>));
EXPECT_TRUE(
(std::is_same_v<Ops::BElementwiseOp, ck::tensor_operation::element_wise::PassThrough>));
EXPECT_TRUE(
(std::is_same_v<Ops::CDEElementwiseOp, ck::tensor_operation::element_wise::PassThrough>));
using Op = ElementwiseOpToCK<ElementwiseOperation::PASS_THROUGH>::Op;
EXPECT_TRUE((std::is_same_v<Op, ck::tensor_operation::element_wise::PassThrough>));
}
TEST(ConvElementwiseOp, AssignsOpsForScale)
{
using Ops = ElementwiseOps<SCALE>;
using Op = ElementwiseOpToCK<ElementwiseOperation::SCALE>::Op;
EXPECT_TRUE((std::is_same_v<Op, ck::tensor_operation::element_wise::Scale>));
}
TEST(ConvElementwiseOp, AssignsOpsForClamp)
{
using Op = ElementwiseOpToCK<ElementwiseOperation::CLAMP>::Op;
EXPECT_TRUE((std::is_same_v<Op, ck::tensor_operation::element_wise::Clamp>));
}
TEST(ConvElementwiseOp, AssignsOpsForScaleAddScaleAddRelu)
{
using Op = ElementwiseOpToCK<ElementwiseOperation::SCALEADD_SCALEADD_RELU>::Op;
EXPECT_TRUE((std::is_same_v<Op, ck::tensor_operation::element_wise::ScaleAddScaleAddRelu>));
}
TEST(ConvElementwiseOp, AssignsOpsForBiasNormClamp)
{
using Op = ElementwiseOpToCK<ElementwiseOperation::BIAS_BNORM_CLAMP>::Op;
EXPECT_TRUE(
(std::is_same_v<Ops::AElementwiseOp, ck::tensor_operation::element_wise::PassThrough>));
EXPECT_TRUE(
(std::is_same_v<Ops::BElementwiseOp, ck::tensor_operation::element_wise::PassThrough>));
EXPECT_TRUE((std::is_same_v<Ops::CDEElementwiseOp, ck::tensor_operation::element_wise::Scale>));
(std::is_same_v<Op, ck::tensor_operation::element_wise::BiasNormalizeInInferClamp>));
}
} // namespace