added test for gemm_add_multiply

This commit is contained in:
Zoltan Lakatos
2025-06-03 11:16:44 +00:00
parent 07f75d9c1d
commit 75550ff770
3 changed files with 88 additions and 5 deletions

View File

@@ -604,7 +604,7 @@ ENDFOREACH()
add_custom_target(instances DEPENDS utility;${CK_DEVICE_INSTANCES} SOURCES ${INSTANCE_FILES})
add_subdirectory(library)
# if(NOT GPU_ARCHS AND USER_GPU_TARGETS)
if(NOT GPU_ARCHS AND USER_GPU_TARGETS)
# rocm_package_setup_component(tests
# LIBRARY_NAME composablekernel
# PACKAGE_NAME tests # Prevent -static suffix on package name
@@ -616,10 +616,10 @@ add_subdirectory(library)
# )
# add_subdirectory(example)
# add_subdirectory(tile_engine)
# if(BUILD_TESTING)
# add_subdirectory(test)
# endif()
# endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
endif()
rocm_package_setup_component(profiler
LIBRARY_NAME composablekernel

View File

@@ -22,3 +22,8 @@ add_gtest_executable(test_gemm_add_fastgelu_wmma test_gemm_add_fastgelu_wmma.cpp
if(result EQUAL 0)
target_link_libraries(test_gemm_add_fastgelu_wmma PRIVATE utility device_gemm_add_fastgelu_instance)
endif()
add_gtest_executable(test_gemm_add_multiply_wmma test_gemm_add_multiply_wmma.cpp)
if(result EQUAL 0)
target_link_libraries(test_gemm_add_multiply_wmma PRIVATE utility device_gemm_add_multiply_instance)
endif()

View File

@@ -0,0 +1,78 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
#include "gtest/gtest.h"
#include "ck/ck.hpp"
#include "profiler/profile_gemm_add_multiply_impl.hpp"
using Row = ck::tensor_layout::gemm::RowMajor;
using Col = ck::tensor_layout::gemm::ColumnMajor;
using F16 = ck::half_t;
using F32 = float;
// TODO: inerit TestGemmAddMultiply from TestGemmD0Common after changes are rebased on top of multipleD feature branch.
// After that clean test...
template <typename Tuple>
class TestGemmAddMultiply : public ::testing::Test
{
private:
using ADataType = std::tuple_element_t<0, Tuple>;
using BDataType = std::tuple_element_t<1, Tuple>;
using AccDataType = std::tuple_element_t<2, Tuple>;
using D0DataType = std::tuple_element_t<3, Tuple>;
using D1DataType = std::tuple_element_t<4, Tuple>;
using EDataType = std::tuple_element_t<5, Tuple>;
using ALayout = std::tuple_element_t<6, Tuple>;
using BLayout = std::tuple_element_t<7, Tuple>;
using D0Layout = std::tuple_element_t<8, Tuple>;
using D1Layout = std::tuple_element_t<9, Tuple>;
using ELayout = std::tuple_element_t<10, Tuple>;
constexpr static auto ProfileGemmAddMultiplyImpl =
ck::profiler::profile_gemm_add_multiply_impl<ADataType,
BDataType,
AccDataType,
D0DataType,
D1DataType,
EDataType,
ALayout,
BLayout,
D0Layout,
D1Layout,
ELayout>;
decltype(ProfileGemmAddMultiplyImpl) GetImpl() { return ProfileGemmAddMultiplyImpl; }
protected:
void Run()
{
std::vector<std::vector<ck::index_t>> lengths = {
{16, 32, 64}, {2048, 1024, 16}, {2048, 4096, 1024}};
bool all_success = true;
for(auto length : lengths)
{
int M = length[0];
int N = length[1];
int K = length[2];
int StrideA = ck::is_same_v<ALayout, Row> ? K : M;
int StrideB = ck::is_same_v<BLayout, Row> ? N : K;
int StrideD0 = ck::is_same_v<D0Layout, Row> ? N : M;
int StrideD1 = ck::is_same_v<D1Layout, Row> ? N : M;
int StrideE = ck::is_same_v<ELayout, Row> ? N : M;
all_success =
all_success &
GetImpl()(true, 1, false, false, M, N, K, StrideA, StrideB, StrideD0, StrideD1, StrideE);
}
EXPECT_TRUE(all_success);
}
};
using KernelTypes = ::testing::Types<std::tuple<F16, F16, F32, F16, F16, F16, Row, Col, Row, Row, Row>>;
TYPED_TEST_SUITE(TestGemmAddMultiply, KernelTypes);
TYPED_TEST(TestGemmAddMultiply, Test_BF16FP16) { this->Run(); }