mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-19 12:30:16 +00:00
Fix bug of layernorm ckProfiler and refine code (#448)
* Fix bug of profiler for layernorm
* 1. Rename layernorm into normalization
2. Decouple softmax from normalization
* clang-format
[ROCm/composable_kernel commit: 1b62bfaa2a]
This commit is contained in:
@@ -12,8 +12,7 @@ using ck::index_t;
|
||||
|
||||
struct LayernormArgParser
|
||||
{
|
||||
std::unordered_map<std::string, std::vector<int>> long_opts = {
|
||||
{"length", {}}, {"strideXY", {}}, {"strideGamma", {}}, {"strideBeta", {}}};
|
||||
std::unordered_map<std::string, std::vector<int>> long_opts = {{"length", {}}};
|
||||
|
||||
bool parse_opt(int argc, char* argv[], const std::string& key, int i)
|
||||
{
|
||||
@@ -52,9 +51,6 @@ void print_help_layernorm()
|
||||
<< "arg4: print tensor value (0: no; 1: yes)\n"
|
||||
<< "arg5: time kernel (0=no, 1=yes)\n"
|
||||
<< "--length: tensor extents (e.g, --length 1024 1024) \n"
|
||||
<< "--strideXY: tensor strides (e.g, --strideXY 1024 1)\n"
|
||||
<< "--strideGamma: tensor strides (e.g, --strideGamma 1)\n"
|
||||
<< "--strideBeta: tensor strides (e.g, --strideBeta 1)\n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
@@ -77,10 +73,7 @@ int profile_layernorm(int argc, char* argv[])
|
||||
|
||||
// parse the long options
|
||||
arg_parser(argc, argv);
|
||||
const std::vector<index_t> length = arg_parser.long_opts["length"];
|
||||
const std::vector<index_t> strideXY = arg_parser.long_opts["strideXY"];
|
||||
const std::vector<index_t> strideGamma = arg_parser.long_opts["strideGamma"];
|
||||
const std::vector<index_t> strideBeta = arg_parser.long_opts["strideBeta"];
|
||||
const std::vector<index_t> length = arg_parser.long_opts["length"];
|
||||
|
||||
using F16 = ck::half_t;
|
||||
using F32 = float;
|
||||
@@ -88,25 +81,13 @@ int profile_layernorm(int argc, char* argv[])
|
||||
|
||||
if(data_type == ck::DataTypeEnum::Half)
|
||||
{
|
||||
ck::profiler::profile_layernorm_impl<F16, F16, F16, F32, F16, rank>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
strideXY,
|
||||
strideGamma,
|
||||
strideBeta);
|
||||
ck::profiler::profile_layernorm_impl<F16, F16, F16, F32, F16, rank>(
|
||||
do_verification, init_method, do_log, time_kernel, length);
|
||||
}
|
||||
else if(data_type == ck::DataTypeEnum::Float)
|
||||
{
|
||||
ck::profiler::profile_layernorm_impl<F32, F32, F32, F32, F32, rank>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
strideXY,
|
||||
strideGamma,
|
||||
strideBeta);
|
||||
ck::profiler::profile_layernorm_impl<F32, F32, F32, F32, F32, rank>(
|
||||
do_verification, init_method, do_log, time_kernel, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "profiler/include/profile_normalization_impl.hpp"
|
||||
#include "profiler/include/profile_softmax_impl.hpp"
|
||||
|
||||
using ck::index_t;
|
||||
using ck::profiler::NormDataType;
|
||||
@@ -95,30 +95,29 @@ int profile_normalization(int argc, char* argv[])
|
||||
{
|
||||
if(data_type == NormDataType::F16_F16)
|
||||
{
|
||||
ck::profiler::profile_normalization_impl<ck::half_t, float, ck::half_t, 3>(
|
||||
do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
ck::profiler::profile_softmax_impl<ck::half_t, float, ck::half_t, 3>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
}
|
||||
else if(data_type == NormDataType::F32_F32)
|
||||
{
|
||||
ck::profiler::profile_normalization_impl<float, float, float, 3>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
ck::profiler::profile_softmax_impl<float, float, float, 3>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -129,30 +128,29 @@ int profile_normalization(int argc, char* argv[])
|
||||
{
|
||||
if(data_type == NormDataType::F16_F16)
|
||||
{
|
||||
ck::profiler::profile_normalization_impl<ck::half_t, float, ck::half_t, 4>(
|
||||
do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
ck::profiler::profile_softmax_impl<ck::half_t, float, ck::half_t, 4>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
}
|
||||
else if(data_type == NormDataType::F32_F32)
|
||||
{
|
||||
ck::profiler::profile_normalization_impl<float, float, float, 4>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
ck::profiler::profile_softmax_impl<float, float, float, 4>(do_verification,
|
||||
init_method,
|
||||
do_log,
|
||||
time_kernel,
|
||||
length,
|
||||
stride,
|
||||
reduce,
|
||||
float(alpha),
|
||||
float(beta),
|
||||
norm_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
Reference in New Issue
Block a user