mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-07-14 02:57:45 +00:00
Add unit tests for template optimization helpers
Add Google Tests for optimized template utilities: - sequence_gen: Tests with custom functors (4 tests) - generate_identity_sequences: Tuple of identity sequences (4 tests) - find_in_tuple_of_sequences: O(1) sequence search (6 tests) - sequence_find_value: Value lookup in sequences (5 tests) - container_concat: Tuple/array concatenation (5 tests) - make_uniform_tuple: Repeated value tuples (4 tests) - compute_element_space_size: Fold expression (8 tests) - unpack_and_merge_sequences: Sequence merging (2 tests) Total: 43 new tests across 4 test files.
This commit is contained in:
@@ -185,6 +185,54 @@ TEST(Sequence, ReorderGivenOld2New)
|
||||
EXPECT_TRUE((is_same<Result, Expected>::value));
|
||||
}
|
||||
|
||||
// Test sequence_gen with custom functor
|
||||
TEST(SequenceGen, SequenceGenWithDoubleFunctor)
|
||||
{
|
||||
struct DoubleFunctor
|
||||
{
|
||||
__host__ __device__ constexpr index_t operator()(index_t i) const { return i * 2; }
|
||||
};
|
||||
using Result = typename sequence_gen<5, DoubleFunctor>::type;
|
||||
using Expected = Sequence<0, 2, 4, 6, 8>;
|
||||
EXPECT_TRUE((is_same<Result, Expected>::value));
|
||||
}
|
||||
|
||||
TEST(SequenceGen, SequenceGenWithSquareFunctor)
|
||||
{
|
||||
struct SquareFunctor
|
||||
{
|
||||
__host__ __device__ constexpr index_t operator()(index_t i) const { return i * i; }
|
||||
};
|
||||
using Result = typename sequence_gen<5, SquareFunctor>::type;
|
||||
using Expected = Sequence<0, 1, 4, 9, 16>;
|
||||
EXPECT_TRUE((is_same<Result, Expected>::value));
|
||||
}
|
||||
|
||||
TEST(SequenceGen, SequenceGenZeroSize)
|
||||
{
|
||||
struct IdentityFunctor
|
||||
{
|
||||
__host__ __device__ constexpr index_t operator()(index_t i) const { return i; }
|
||||
};
|
||||
using Result = typename sequence_gen<0, IdentityFunctor>::type;
|
||||
using Expected = Sequence<>;
|
||||
EXPECT_TRUE((is_same<Result, Expected>::value));
|
||||
// Also verify non-zero size works with identity
|
||||
using Result5 = typename sequence_gen<5, IdentityFunctor>::type;
|
||||
EXPECT_TRUE((is_same<Result5, Sequence<0, 1, 2, 3, 4>>::value));
|
||||
}
|
||||
|
||||
TEST(SequenceGen, SequenceGenSingleElement)
|
||||
{
|
||||
struct ConstantFunctor
|
||||
{
|
||||
__host__ __device__ constexpr index_t operator()(index_t) const { return 42; }
|
||||
};
|
||||
using Result = typename sequence_gen<1, ConstantFunctor>::type;
|
||||
using Expected = Sequence<42>;
|
||||
EXPECT_TRUE((is_same<Result, Expected>::value));
|
||||
}
|
||||
|
||||
// Test arithmetic_sequence_gen
|
||||
TEST(SequenceGen, ArithmeticSequence)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user