mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-06-06 15:54:31 +00:00
added tests for all splitk fastgelus
This commit is contained in:
@@ -24,10 +24,10 @@ static constexpr auto Intrawave = BlockGemmPipelineScheduler::Intrawave;
|
||||
static constexpr auto V1 = BlockGemmPipelineVersion::v1;
|
||||
static constexpr auto V3 = BlockGemmPipelineVersion::v3;
|
||||
|
||||
// e = elementwise((a * b), d0)
|
||||
// elementwise(c, d0) = fastgelu(c + d0)
|
||||
// e = elementwise((a * b), d0, d1)
|
||||
// elementwise(c, d0, d1) = fastgelu(c + d0 + d1)
|
||||
// output: e[m, n]
|
||||
// input: a[m, k], b[n, k], d0[m, n]
|
||||
// input: a[m, k], b[n, k], d0[m, n], d1[m, n]
|
||||
|
||||
template <GemmSpecialization GemmSpec>
|
||||
using device_gemm_add_add_fastgelu_wmma_c_shuffle_f16_f16_f16_f16_f16_km_nk_mn_mn_mn_instances =
|
||||
|
||||
@@ -20,7 +20,17 @@ if(result EQUAL 0)
|
||||
target_link_libraries(test_gemm_add_fastgelu_xdl PRIVATE utility device_gemm_add_instance device_gemm_add_fastgelu_instance)
|
||||
endif()
|
||||
|
||||
add_gtest_executable(test_gemm_fastgelu_wmma test_gemm_fastgelu_wmma.cpp)
|
||||
if(result EQUAL 0)
|
||||
target_link_libraries(test_gemm_fastgelu_wmma PRIVATE utility device_gemm_fastgelu_instance)
|
||||
endif()
|
||||
|
||||
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_add_fastgelu_wmma test_gemm_add_add_fastgelu_wmma.cpp)
|
||||
if(result EQUAL 0)
|
||||
target_link_libraries(test_gemm_add_add_fastgelu_wmma PRIVATE utility device_gemm_add_add_fastgelu_instance)
|
||||
endif()
|
||||
|
||||
38
test/gemm_add/test_gemm_add_add_fastgelu_wmma.cpp
Normal file
38
test/gemm_add/test_gemm_add_add_fastgelu_wmma.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2024-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ck/ck.hpp"
|
||||
#include "profiler/profile_gemm_add_add_fastgelu_impl.hpp"
|
||||
#include "test_gemm_common.hpp"
|
||||
|
||||
template <typename Tuple>
|
||||
class TestGemmAddAddFastgelu : public TestGemmD0D1Common<Tuple>
|
||||
{
|
||||
using ProfileCall = typename TestGemmD0D1Common<Tuple>::ProfileCall;
|
||||
|
||||
public:
|
||||
ProfileCall GetImpl() override
|
||||
{
|
||||
return ck::profiler::profile_gemm_add_add_fastgelu_impl<
|
||||
typename TestGemmD0D1Common<Tuple>::ADataType,
|
||||
typename TestGemmD0D1Common<Tuple>::BDataType,
|
||||
typename TestGemmD0D1Common<Tuple>::AccDataType,
|
||||
typename TestGemmD0D1Common<Tuple>::D0DataType,
|
||||
typename TestGemmD0D1Common<Tuple>::D1DataType,
|
||||
typename TestGemmD0D1Common<Tuple>::EDataType,
|
||||
typename TestGemmD0D1Common<Tuple>::ALayout,
|
||||
typename TestGemmD0D1Common<Tuple>::BLayout,
|
||||
typename TestGemmD0D1Common<Tuple>::D0Layout,
|
||||
typename TestGemmD0D1Common<Tuple>::D1Layout,
|
||||
typename TestGemmD0D1Common<Tuple>::ELayout>;
|
||||
}
|
||||
};
|
||||
|
||||
using KernelTypes = ::testing::Types<std::tuple<F16, F16, F32, F16, F16, F16, Row, Row, Row, Row, Row>,
|
||||
std::tuple<F16, F16, F32, F16, F16, F16, Row, Col, Row, Row, Row>,
|
||||
std::tuple<F16, F16, F32, F16, F16, F16, Col, Row, Row, Row, Row>,
|
||||
std::tuple<F16, F16, F32, F16, F16, F16, Col, Col, Row, Row, Row>>;
|
||||
|
||||
TYPED_TEST_SUITE(TestGemmAddAddFastgelu, KernelTypes);
|
||||
TYPED_TEST(TestGemmAddAddFastgelu, Test_BF16FP16) { this->Run(); }
|
||||
@@ -9,29 +9,21 @@
|
||||
template <typename Tuple>
|
||||
class TestGemmAddFastgelu : public TestGemmD0Common<Tuple>
|
||||
{
|
||||
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 EDataType = std::tuple_element_t<4, Tuple>;
|
||||
using ALayout = std::tuple_element_t<5, Tuple>;
|
||||
using BLayout = std::tuple_element_t<6, Tuple>;
|
||||
using D0Layout = std::tuple_element_t<7, Tuple>;
|
||||
using ELayout = std::tuple_element_t<8, Tuple>;
|
||||
using ProfileCall = typename TestGemmD0Common<Tuple>::ProfileCall;
|
||||
|
||||
constexpr static auto ProfileGemmAddFastgeluImpl =
|
||||
ck::profiler::profile_gemm_add_fastgelu_impl<ADataType,
|
||||
BDataType,
|
||||
AccDataType,
|
||||
D0DataType,
|
||||
EDataType,
|
||||
ALayout,
|
||||
BLayout,
|
||||
D0Layout,
|
||||
ELayout>;
|
||||
|
||||
decltype(ProfileGemmAddFastgeluImpl) GetImpl() override { return ProfileGemmAddFastgeluImpl; }
|
||||
ProfileCall GetImpl() override
|
||||
{
|
||||
return ck::profiler::profile_gemm_add_fastgelu_impl<
|
||||
typename TestGemmD0Common<Tuple>::ADataType,
|
||||
typename TestGemmD0Common<Tuple>::BDataType,
|
||||
typename TestGemmD0Common<Tuple>::AccDataType,
|
||||
typename TestGemmD0Common<Tuple>::D0DataType,
|
||||
typename TestGemmD0Common<Tuple>::EDataType,
|
||||
typename TestGemmD0Common<Tuple>::ALayout,
|
||||
typename TestGemmD0Common<Tuple>::BLayout,
|
||||
typename TestGemmD0Common<Tuple>::D0Layout,
|
||||
typename TestGemmD0Common<Tuple>::ELayout>;
|
||||
}
|
||||
};
|
||||
|
||||
using KernelTypes = ::testing::Types<std::tuple<F16, F16, F32, F16, F16, Row, Row, Row, Row>,
|
||||
|
||||
@@ -9,6 +9,22 @@
|
||||
template <typename Tuple>
|
||||
class TestGemmAddFastgelu : public TestGemmD0Common<Tuple>
|
||||
{
|
||||
using ProfileCall = typename TestGemmD0Common<Tuple>::ProfileCall;
|
||||
|
||||
ProfileCall GetImpl() override
|
||||
{
|
||||
return ck::profiler::profile_gemm_add_fastgelu_impl<
|
||||
typename TestGemmD0Common<Tuple>::ADataType,
|
||||
typename TestGemmD0Common<Tuple>::BDataType,
|
||||
typename TestGemmD0Common<Tuple>::AccDataType,
|
||||
typename TestGemmD0Common<Tuple>::D0DataType,
|
||||
typename TestGemmD0Common<Tuple>::EDataType,
|
||||
typename TestGemmD0Common<Tuple>::ALayout,
|
||||
typename TestGemmD0Common<Tuple>::BLayout,
|
||||
typename TestGemmD0Common<Tuple>::D0Layout,
|
||||
typename TestGemmD0Common<Tuple>::ELayout>;
|
||||
}
|
||||
|
||||
private:
|
||||
using ADataType = std::tuple_element_t<0, Tuple>;
|
||||
using BDataType = std::tuple_element_t<1, Tuple>;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ck/ck.hpp"
|
||||
#include "profiler/profile_gemm_add_impl.hpp"
|
||||
|
||||
using Row = ck::tensor_layout::gemm::RowMajor;
|
||||
using Col = ck::tensor_layout::gemm::ColumnMajor;
|
||||
@@ -13,6 +12,47 @@ using BF16 = ck::bhalf_t;
|
||||
using F16 = ck::half_t;
|
||||
using F32 = float;
|
||||
|
||||
template <typename Tuple>
|
||||
class TestGemmCommon : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
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 EDataType = std::tuple_element_t<3, Tuple>;
|
||||
using ALayout = std::tuple_element_t<4, Tuple>;
|
||||
using BLayout = std::tuple_element_t<5, Tuple>;
|
||||
using ELayout = std::tuple_element_t<6, Tuple>;
|
||||
|
||||
using ProfileCall = bool(*const)(int, int, bool, bool, int, int, int, int, int, int);
|
||||
|
||||
virtual ProfileCall GetImpl() = 0;
|
||||
|
||||
void Run()
|
||||
{
|
||||
std::vector<std::vector<ck::index_t>> lengths = {
|
||||
{16, 32, 64}, {2048, 4096, 8192}, {2048, 1024, 16}};
|
||||
|
||||
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 StrideE = ck::is_same_v<ELayout, Row> ? N : M;
|
||||
|
||||
all_success =
|
||||
all_success &
|
||||
GetImpl()(1, 1, false, false, M, N, K, StrideA, StrideB, StrideE);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(all_success);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tuple>
|
||||
class TestGemmD0Common : public ::testing::Test
|
||||
{
|
||||
@@ -27,17 +67,9 @@ class TestGemmD0Common : public ::testing::Test
|
||||
using D0Layout = std::tuple_element_t<7, Tuple>;
|
||||
using ELayout = std::tuple_element_t<8, Tuple>;
|
||||
|
||||
constexpr static auto ProfileGemmAddImpl = ck::profiler::profile_gemm_add_impl<ADataType,
|
||||
BDataType,
|
||||
AccDataType,
|
||||
D0DataType,
|
||||
EDataType,
|
||||
ALayout,
|
||||
BLayout,
|
||||
D0Layout,
|
||||
ELayout>;
|
||||
using ProfileCall = bool(*const)(int, int, bool, bool, int, int, int, int, int, int, int);
|
||||
|
||||
virtual decltype(ProfileGemmAddImpl) GetImpl() = 0;
|
||||
virtual ProfileCall GetImpl() = 0;
|
||||
|
||||
void Run()
|
||||
{
|
||||
@@ -58,7 +90,54 @@ class TestGemmD0Common : public ::testing::Test
|
||||
|
||||
all_success =
|
||||
all_success &
|
||||
GetImpl()(true, 1, false, false, M, N, K, StrideA, StrideB, StrideD0, StrideE);
|
||||
GetImpl()(1, 1, false, false, M, N, K, StrideA, StrideB, StrideD0, StrideE);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(all_success);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tuple>
|
||||
class TestGemmD0D1Common : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
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>;
|
||||
|
||||
using ProfileCall = bool(*const)(int, int, bool, bool, int, int, int, int, int, int, int, int);
|
||||
|
||||
virtual ProfileCall GetImpl() = 0;
|
||||
|
||||
void Run()
|
||||
{
|
||||
std::vector<std::vector<ck::index_t>> lengths = {
|
||||
{16, 32, 64}, {2048, 4096, 8192}, {2048, 1024, 16}};
|
||||
|
||||
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()(1, 1, false, false, M, N, K, StrideA, StrideB, StrideD0, StrideD1, StrideE);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(all_success);
|
||||
|
||||
32
test/gemm_add/test_gemm_fastgelu_wmma.cpp
Normal file
32
test/gemm_add/test_gemm_fastgelu_wmma.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2024-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ck/ck.hpp"
|
||||
#include "profiler/profile_gemm_fastgelu_impl.hpp"
|
||||
#include "test_gemm_common.hpp"
|
||||
|
||||
template <typename Tuple>
|
||||
class TestGemmFastgelu : public TestGemmCommon<Tuple>
|
||||
{
|
||||
using ProfileCall = typename TestGemmCommon<Tuple>::ProfileCall;
|
||||
|
||||
ProfileCall GetImpl() override
|
||||
{
|
||||
return ck::profiler::profile_gemm_fastgelu_impl<typename TestGemmCommon<Tuple>::ADataType,
|
||||
typename TestGemmCommon<Tuple>::BDataType,
|
||||
typename TestGemmCommon<Tuple>::AccDataType,
|
||||
typename TestGemmCommon<Tuple>::EDataType,
|
||||
typename TestGemmCommon<Tuple>::ALayout,
|
||||
typename TestGemmCommon<Tuple>::BLayout,
|
||||
typename TestGemmCommon<Tuple>::ELayout>;
|
||||
}
|
||||
};
|
||||
|
||||
using KernelTypes = ::testing::Types<std::tuple<F16, F16, F32, F16, Row, Row, Row>,
|
||||
std::tuple<F16, F16, F32, F16, Row, Col, Row>,
|
||||
std::tuple<F16, F16, F32, F16, Col, Row, Row>,
|
||||
std::tuple<F16, F16, F32, F16, Col, Col, Row>>;
|
||||
|
||||
TYPED_TEST_SUITE(TestGemmFastgelu, KernelTypes);
|
||||
TYPED_TEST(TestGemmFastgelu, Test_BF16FP16) { this->Run(); }
|
||||
Reference in New Issue
Block a user