[CK] Add command option instance_index and param_mask to run partial ck test (#2889)

* [CK] Add command option instance_index and param_mask to run partial ck test

Many CK test are instance test. it will loop all instance in the instance library. It causes test often out-of-time if we run test on simulator/emulator.
This PR add option instance_index and param_mask to reduce the workload of instance test

instance_index: only run test 1 available instance with specified index.
param_mask: filter the embedded parameter with specified mask

* fix CI error

* fix clang format

---------

Co-authored-by: illsilin_amdeng <Illia.Silin@amd.com>
This commit is contained in:
linqunAMD
2025-09-30 23:24:40 +08:00
committed by GitHub
parent 28ad8ae5d8
commit e78a897ec0
113 changed files with 2804 additions and 704 deletions

View File

@@ -8,6 +8,9 @@ using F16 = ck::half_t;
using F32 = float;
using ck::index_t;
static ck::index_t length_mask = 0xffff;
static ck::index_t instance_index = -1;
template <typename Tuple>
class TestGroupnorm : public ::testing::Test
{
@@ -31,16 +34,21 @@ class TestGroupnorm : public ::testing::Test
{2, 32, 32, 32, 40},
{1, 16, 16, 32, 40}};
for(auto length : lengths)
for(size_t i = 0; i < lengths.size(); i++)
{
bool success =
ck::profiler::profile_groupnorm_impl<XDataType,
GammaDataType,
BetaDataType,
ComputeDataType,
YDataType,
SaveMeanInvStdDataType,
true>(true, 2, false, false, length);
if((length_mask & (1 << i)) == 0)
{
continue;
}
auto length = lengths[i];
bool success = ck::profiler::profile_groupnorm_impl<XDataType,
GammaDataType,
BetaDataType,
ComputeDataType,
YDataType,
SaveMeanInvStdDataType,
true>(
true, 2, false, false, length, instance_index);
EXPECT_TRUE(success);
}
}
@@ -52,3 +60,20 @@ using KernelTypes = ::testing::Types<
TYPED_TEST_SUITE(TestGroupnorm, KernelTypes);
TYPED_TEST(TestGroupnorm, Test_FP16) { this->Run(); }
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
{
length_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: length_mask instance_index(-1 means all)" << std::endl;
}
return RUN_ALL_TESTS();
}

View File

@@ -8,6 +8,9 @@ using F16 = ck::half_t;
using F32 = float;
using ck::index_t;
static ck::index_t length_mask = 0xffff;
static ck::index_t instance_index = -1;
template <typename Tuple>
class TestGroupnorm : public ::testing::Test
{
@@ -29,16 +32,21 @@ class TestGroupnorm : public ::testing::Test
{1, 32, 32, 32, 20},
{1, 16, 16, 32, 40}};
for(auto length : lengths)
for(size_t i = 0; i < lengths.size(); i++)
{
bool success =
ck::profiler::profile_groupnorm_impl<XDataType,
GammaDataType,
BetaDataType,
ComputeDataType,
YDataType,
SaveMeanInvStdDataType,
true>(true, 2, false, false, length);
if((length_mask & (1 << i)) == 0)
{
continue;
}
auto length = lengths[i];
bool success = ck::profiler::profile_groupnorm_impl<XDataType,
GammaDataType,
BetaDataType,
ComputeDataType,
YDataType,
SaveMeanInvStdDataType,
true>(
true, 2, false, false, length, instance_index);
EXPECT_TRUE(success);
}
}
@@ -50,3 +58,20 @@ using KernelTypes = ::testing::Types<
TYPED_TEST_SUITE(TestGroupnorm, KernelTypes);
TYPED_TEST(TestGroupnorm, Test_FP32) { this->Run(); }
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
{
length_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: length_mask instance_index(-1 means all)" << std::endl;
}
return RUN_ALL_TESTS();
}

View File

@@ -8,6 +8,9 @@ using F16 = ck::half_t;
using F32 = float;
using ck::index_t;
static ck::index_t length_mask = 0xffff;
static ck::index_t instance_index = -1;
template <typename Tuple>
class TestLayernorm2d : public ::testing::Test
{
@@ -25,8 +28,13 @@ class TestLayernorm2d : public ::testing::Test
std::vector<std::vector<ck::index_t>> lengths = {
{4, 256}, {8, 511}, {9, 1032}, {4, 2048}, {1, 8192}, {4000, 2000}};
for(auto length : lengths)
for(size_t i = 0; i < lengths.size(); i++)
{
if((length_mask & (1 << i)) == 0)
{
continue;
}
auto length = lengths[i];
bool success = ck::profiler::profile_layernorm_impl<XDataType,
GammaDataType,
BetaDataType,
@@ -34,7 +42,8 @@ class TestLayernorm2d : public ::testing::Test
YDataType,
SaveMeanInvStdDataType,
true,
2>(true, 2, false, false, length);
2>(
true, 2, false, false, length, instance_index);
EXPECT_TRUE(success);
}
}
@@ -46,3 +55,19 @@ using KernelTypes = ::testing::Types<
TYPED_TEST_SUITE(TestLayernorm2d, KernelTypes);
TYPED_TEST(TestLayernorm2d, Test_FP16) { this->Run(); }
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
{
length_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: length_mask instance_index(-1 means all)" << std::endl;
}
return RUN_ALL_TESTS();
}

View File

@@ -8,6 +8,9 @@ using F16 = ck::half_t;
using F32 = float;
using ck::index_t;
static ck::index_t length_mask = 0xffff;
static ck::index_t instance_index = -1;
template <typename Tuple>
class TestLayernorm2d : public ::testing::Test
{
@@ -25,8 +28,13 @@ class TestLayernorm2d : public ::testing::Test
std::vector<std::vector<ck::index_t>> lengths = {
{4, 256}, {8, 511}, {9, 1032}, {4, 2048}, {1, 8192}, {4000, 2000}};
for(auto length : lengths)
for(size_t i = 0; i < lengths.size(); i++)
{
if((length_mask & (1 << i)) == 0)
{
continue;
}
auto length = lengths[i];
bool success = ck::profiler::profile_layernorm_impl<XDataType,
GammaDataType,
BetaDataType,
@@ -34,7 +42,8 @@ class TestLayernorm2d : public ::testing::Test
YDataType,
SaveMeanInvStdDataType,
true,
2>(true, 2, false, false, length);
2>(
true, 2, false, false, length, instance_index);
EXPECT_TRUE(success);
}
}
@@ -46,3 +55,19 @@ using KernelTypes = ::testing::Types<
TYPED_TEST_SUITE(TestLayernorm2d, KernelTypes);
TYPED_TEST(TestLayernorm2d, Test_FP32) { this->Run(); }
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
{
length_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: length_mask instance_index(-1 means all)" << std::endl;
}
return RUN_ALL_TESTS();
}

View File

@@ -8,6 +8,9 @@ using F16 = ck::half_t;
using F32 = float;
using ck::index_t;
static ck::index_t length_mask = 0xffff;
static ck::index_t instance_index = -1;
template <typename Tuple>
class TestLayernorm4d : public ::testing::Test
{
@@ -25,8 +28,13 @@ class TestLayernorm4d : public ::testing::Test
std::vector<std::vector<ck::index_t>> lengths = {
{1, 1, 1, 1}, {7, 7, 7, 7}, {256, 16, 16, 8}};
for(auto length : lengths)
for(size_t i = 0; i < lengths.size(); i++)
{
if((length_mask & (1 << i)) == 0)
{
continue;
}
auto length = lengths[i];
bool success = ck::profiler::profile_layernorm_impl<XDataType,
GammaDataType,
BetaDataType,
@@ -34,7 +42,8 @@ class TestLayernorm4d : public ::testing::Test
YDataType,
SaveMeanInvStdDataType,
true,
4>(true, 2, false, false, length);
4>(
true, 2, false, false, length, instance_index);
EXPECT_TRUE(success);
}
}
@@ -46,3 +55,19 @@ using KernelTypes = ::testing::Types<
TYPED_TEST_SUITE(TestLayernorm4d, KernelTypes);
TYPED_TEST(TestLayernorm4d, Test_FP16) { this->Run(); }
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
{
length_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: length_mask instance_index(-1 means all)" << std::endl;
}
return RUN_ALL_TESTS();
}