mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-24 14:54:47 +00:00
Group norm (#417)
* Add groupnorm example by layernorm
1. Reference is not ready
2. shape of gamma and beta need to be fix
* Let shape of gamma and beta can be same as x
* Modify test, instance and client example
* [What] Fix bug of layernorm for greater than 2 dimension.
[Why] We need to get upper length from merge transform instead of embed transform.
* Add reference for groupnorm
* Fuse sigmoid after groupnorm
* [What] Rename original layernorm into layernorm2d
[Why] Prepare to add groupnorm using layernorm5d
* clang-format
* Add groupnorm test
* Refine error message
* Add groupnorm ckProfiler
* Test groupnorm kernel from device_instance
* update example
* upadte profiler
* Fix test naming
* Fix argc number
* Move descriptor and sweeponce to argument for quick debugging
Co-authored-by: Chao Liu <chao.liu2@amd.com>
[ROCm/composable_kernel commit: 4eba345f6e]
This commit is contained in:
56
test/layernorm/test_groupnorm_fp32.cpp
Normal file
56
test/layernorm/test_groupnorm_fp32.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "profiler/include/profile_groupnorm_impl.hpp"
|
||||
|
||||
using F16 = ck::half_t;
|
||||
using F32 = float;
|
||||
using ck::index_t;
|
||||
|
||||
template <typename Tuple>
|
||||
class TestGroupnorm : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
using XDataType = std::tuple_element_t<0, Tuple>;
|
||||
using GammaDataType = std::tuple_element_t<1, Tuple>;
|
||||
using BetaDataType = std::tuple_element_t<2, Tuple>;
|
||||
using AccDataType = std::tuple_element_t<3, Tuple>;
|
||||
using YDataType = std::tuple_element_t<4, Tuple>;
|
||||
|
||||
void Run()
|
||||
{
|
||||
// N, H, W, G, C
|
||||
std::vector<std::vector<ck::index_t>> lengths = {{1, 1, 1, 1, 1},
|
||||
{1, 2, 3, 4, 5},
|
||||
{256, 9, 9, 9, 9},
|
||||
{1, 64, 64, 32, 10},
|
||||
{1, 32, 32, 32, 20},
|
||||
{1, 16, 16, 32, 40}};
|
||||
|
||||
for(auto length : lengths)
|
||||
{
|
||||
bool success =
|
||||
ck::profiler::profile_groupnorm_impl<XDataType,
|
||||
GammaDataType,
|
||||
BetaDataType,
|
||||
AccDataType,
|
||||
YDataType>(true, 2, false, false, length);
|
||||
EXPECT_TRUE(success);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using KernelTypes = ::testing::Types<
|
||||
// XDataType, GammaDataType, BetaDataType, AccDataType, YDataType>
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>,
|
||||
std::tuple<F32, F32, F32, F32, F32>>;
|
||||
|
||||
TYPED_TEST_SUITE(TestGroupnorm, KernelTypes);
|
||||
TYPED_TEST(TestGroupnorm, Test_FP32) { this->Run(); }
|
||||
Reference in New Issue
Block a user