CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
202 lines
7.0 KiB
C++
202 lines
7.0 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "ck/ck.hpp"
|
|
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
|
|
#include "ck/utility/data_type.hpp"
|
|
|
|
using Row = ck::tensor_layout::gemm::RowMajor;
|
|
using Col = ck::tensor_layout::gemm::ColumnMajor;
|
|
|
|
using I8 = int8_t;
|
|
using I32 = int32_t;
|
|
using BF16 = ck::bhalf_t;
|
|
using F16 = ck::half_t;
|
|
using F32 = float;
|
|
using F8 = ck::f8_t;
|
|
|
|
// M, N, K
|
|
using TestMatrixSizes = std::vector<std::vector<ck::index_t>>;
|
|
|
|
static const TestMatrixSizes DefaultTestMatrixSizes = {
|
|
{16, 32, 64}, {512, 2048, 4096}, {2048, 1024, 16}};
|
|
|
|
static ck::index_t param_mask = 0xffff;
|
|
static ck::index_t instance_index = -1;
|
|
|
|
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, int);
|
|
|
|
virtual ProfileCall GetImpl() = 0;
|
|
|
|
void Run(const TestMatrixSizes& lengths = DefaultTestMatrixSizes)
|
|
{
|
|
bool all_success = true;
|
|
|
|
for(size_t i = 0; i < lengths.size(); i++)
|
|
{
|
|
if((param_mask & (1 << i)) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
auto& length = lengths[i];
|
|
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, instance_index);
|
|
}
|
|
|
|
EXPECT_TRUE(all_success);
|
|
}
|
|
};
|
|
|
|
template <typename Tuple>
|
|
class TestGemmD0Common : 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 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 = bool (*const)(int, int, bool, bool, int, int, int, int, int, int, int, int);
|
|
|
|
virtual ProfileCall GetImpl() = 0;
|
|
|
|
void Run(const TestMatrixSizes& lengths = DefaultTestMatrixSizes)
|
|
{
|
|
bool all_success = true;
|
|
|
|
for(size_t i = 0; i < lengths.size(); i++)
|
|
{
|
|
if((param_mask & (1 << i)) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
auto& length = lengths[i];
|
|
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 StrideE = ck::is_same_v<ELayout, Row> ? N : M;
|
|
|
|
all_success = all_success & GetImpl()(1,
|
|
1,
|
|
false,
|
|
false,
|
|
M,
|
|
N,
|
|
K,
|
|
StrideA,
|
|
StrideB,
|
|
StrideD0,
|
|
StrideE,
|
|
instance_index);
|
|
}
|
|
|
|
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, int);
|
|
|
|
virtual ProfileCall GetImpl() = 0;
|
|
|
|
void Run(const TestMatrixSizes& lengths = DefaultTestMatrixSizes)
|
|
{
|
|
bool all_success = true;
|
|
|
|
for(size_t i = 0; i < lengths.size(); i++)
|
|
{
|
|
if((param_mask & (1 << i)) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
auto& length = lengths[i];
|
|
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,
|
|
instance_index);
|
|
}
|
|
|
|
EXPECT_TRUE(all_success);
|
|
}
|
|
};
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
testing::InitGoogleTest(&argc, argv);
|
|
if(argc == 1) {}
|
|
else if(argc == 3)
|
|
{
|
|
param_mask = strtol(argv[1], nullptr, 0);
|
|
instance_index = atoi(argv[2]);
|
|
}
|
|
else
|
|
{
|
|
std::cout << "Usage of " << argv[0] << std::endl;
|
|
std::cout << "Arg1,2: param_mask instance_index(-1 means all)" << std::endl;
|
|
}
|
|
return RUN_ALL_TESTS();
|
|
}
|