mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-12 09:16:52 +00:00
* [What] Separate fixpoint gemm from gemm example [Why] let example of gemm_int8 be pure gemm. [What] 1. Add gemm_requant_relu_requant, 2. Let CDataType be int32 in pure gemm, because no one use int8 CDataType. It is also part of gemm_requant_relu_requant * Fix path * Revise cmakelist due to merge develop * Add gemm fp16 test * Extract PrepareGemmTensor * Extract TestGemm * Add test for different layout * Add 4 layouts of shuffle version of fp32 * Add 4 layouts of shuffle version of int8 * Add 4 layouts of shuffle version of bf16 * replace all DeviceGemmPtr_ with DeviceGemmNoOpPtr to fit naming convension * Add test for non-shuffle verstion of gemm * Fix typo * Print kernel information * Add rest of the fp32 kernel to the test * 1. Add rest of the fp16 device iop. 2. Mark the invalid device operation Co-authored-by: rocking <chunylai@amd.com>
113 lines
4.3 KiB
C++
113 lines
4.3 KiB
C++
#include <algorithm>
|
|
#include <cstdlib>
|
|
#include <half.hpp>
|
|
#include <iostream>
|
|
#include <numeric>
|
|
#include <tuple>
|
|
#include <vector>
|
|
|
|
#include "gemm_util.hpp"
|
|
#include "config.hpp"
|
|
#include "print.hpp"
|
|
#include "device.hpp"
|
|
#include "host_tensor.hpp"
|
|
#include "host_tensor_generator.hpp"
|
|
#include "host_gemm.hpp"
|
|
#include "device_tensor.hpp"
|
|
#include "device_gemm_xdl.hpp"
|
|
#include "device_gemm_xdl_c_shuffle.hpp"
|
|
#include "element_wise_operation.hpp"
|
|
#include "reference_gemm.hpp"
|
|
#include "gemm_specialization.hpp"
|
|
#include "test_util.hpp"
|
|
|
|
using PassThrough = ck::tensor_operation::element_wise::PassThrough;
|
|
|
|
using DeviceGemmNoOpPtr =
|
|
ck::tensor_operation::device::DeviceGemmPtr<ck::tensor_operation::element_wise::PassThrough,
|
|
ck::tensor_operation::element_wise::PassThrough,
|
|
ck::tensor_operation::element_wise::PassThrough>;
|
|
|
|
namespace ck {
|
|
namespace tensor_operation {
|
|
namespace device {
|
|
namespace device_gemm_instance {
|
|
void add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_km_kn_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
|
|
void add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_km_nk_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
|
|
void add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_mk_nk_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
|
|
void add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_mk_kn_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
|
|
} // namespace device_gemm_instance
|
|
} // namespace device
|
|
} // namespace tensor_operation
|
|
} // namespace ck
|
|
|
|
int main()
|
|
{
|
|
using RowMajor = ck::tensor_layout::gemm::RowMajor;
|
|
using ColumnMajor = ck::tensor_layout::gemm::ColumnMajor;
|
|
|
|
bool res = true;
|
|
std::vector<DeviceGemmNoOpPtr> gemmPtrs;
|
|
|
|
ck::tensor_operation::device::device_gemm_instance::
|
|
add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_km_kn_mn_instances(gemmPtrs);
|
|
|
|
for(auto& gemmPtr : gemmPtrs)
|
|
{
|
|
res &= ck::gemm_util::TestGemmBF16<DeviceGemmNoOpPtr,
|
|
ColumnMajor,
|
|
RowMajor,
|
|
RowMajor,
|
|
PassThrough,
|
|
PassThrough,
|
|
PassThrough>{}(gemmPtr);
|
|
}
|
|
|
|
gemmPtrs.clear();
|
|
ck::tensor_operation::device::device_gemm_instance::
|
|
add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_km_nk_mn_instances(gemmPtrs);
|
|
|
|
for(auto& gemmPtr : gemmPtrs)
|
|
{
|
|
res &= ck::gemm_util::TestGemmBF16<DeviceGemmNoOpPtr,
|
|
ColumnMajor,
|
|
ColumnMajor,
|
|
RowMajor,
|
|
PassThrough,
|
|
PassThrough,
|
|
PassThrough>{}(gemmPtr);
|
|
}
|
|
|
|
gemmPtrs.clear();
|
|
ck::tensor_operation::device::device_gemm_instance::
|
|
add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_mk_kn_mn_instances(gemmPtrs);
|
|
|
|
for(auto& gemmPtr : gemmPtrs)
|
|
{
|
|
res &= ck::gemm_util::TestGemmBF16<DeviceGemmNoOpPtr,
|
|
RowMajor,
|
|
RowMajor,
|
|
RowMajor,
|
|
PassThrough,
|
|
PassThrough,
|
|
PassThrough>{}(gemmPtr);
|
|
}
|
|
|
|
gemmPtrs.clear();
|
|
ck::tensor_operation::device::device_gemm_instance::
|
|
add_device_gemm_xdl_c_shuffle_bf16_bf16_bf16_mk_nk_mn_instances(gemmPtrs);
|
|
|
|
for(auto& gemmPtr : gemmPtrs)
|
|
{
|
|
res &= ck::gemm_util::TestGemmBF16<DeviceGemmNoOpPtr,
|
|
RowMajor,
|
|
ColumnMajor,
|
|
RowMajor,
|
|
PassThrough,
|
|
PassThrough,
|
|
PassThrough>{}(gemmPtr);
|
|
}
|
|
|
|
std::cout << "TestGemm ..... " << (res ? "SUCCESS" : "FAILURE") << std::endl;
|
|
}
|