[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

@@ -58,3 +58,20 @@ TYPED_TEST(TestSoftmax, ReduceOddLengths)
this->Run({this->Rank - 1});
this->Run({this->Rank - 2});
}
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();
}

View File

@@ -15,6 +15,9 @@
#include "include/ck/utility/data_type.hpp"
#include "profiler/profile_softmax_impl.hpp"
static ck::index_t param_mask = 0xffff;
static ck::index_t instance_index = -1;
namespace ck {
template <typename Range>
@@ -56,7 +59,8 @@ class TestSoftmax : public ::testing::Test
void RunSingle(std::vector<index_t> in_length,
std::vector<index_t> reduce_dims,
AccDataType alpha,
AccDataType beta)
AccDataType beta,
index_t instance_index)
{
int init_method = 1; // integer value initialization
bool log = false;
@@ -67,84 +71,98 @@ class TestSoftmax : public ::testing::Test
{
if(reduce_dims.size() == 1)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 1>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 1>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
else if(reduce_dims.size() == 2)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 2>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 2>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
else if(reduce_dims.size() == 3)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 3>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 3>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
}
else if constexpr(Rank == 4)
{
if(reduce_dims.size() == 1)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 1>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 1>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
else if(reduce_dims.size() == 2)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 2>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 2>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
else if(reduce_dims.size() == 3)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 3>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 3>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
else if(reduce_dims.size() == 4)
pass = ck::profiler::
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 4>(verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta);
profile_softmax_impl<InDataType, AccDataType, OutDataType, Rank, 4>(
verify_,
init_method,
log,
bench_,
in_length,
strides,
reduce_dims,
alpha,
beta,
instance_index);
};
EXPECT_TRUE(pass);
@@ -161,7 +179,7 @@ class TestSoftmax : public ::testing::Test
{
for(auto scale : this->scales_)
{
this->RunSingle(in_length, reduce_dims, scale[0], scale[1]);
this->RunSingle(in_length, reduce_dims, scale[0], scale[1], instance_index);
}
}
}