TensorRT-LLMs/cpp/tests/batch_manager/blockKeyTest.cpp
pansicheng 143edc8153
fix partialMatch (#3413)
Signed-off-by: pansicheng <sicheng.pan.chn@gmail.com>
2025-04-11 16:42:52 +08:00

24 lines
618 B
C++

#include "tensorrt_llm/batch_manager/kvCacheManager.h"
#include <gtest/gtest.h>
using namespace tensorrt_llm::batch_manager::kv_cache_manager;
class BlockKeyTest : public ::testing::Test
{
};
TEST_F(BlockKeyTest, PartialMatch)
{
VecUniqueTokens tokens0 = {{0, 0}, {0, 0}};
VecUniqueTokens tokens1 = {{0, 0}};
BlockKey bk0(false, 0, tokens0);
BlockKey bk1(false, 0, tokens1);
bk1.uniqueTokens.reserve(2);
auto ptr = reinterpret_cast<char*>(bk1.uniqueTokens.data());
std::fill(ptr, ptr + bk1.uniqueTokens.capacity() * sizeof(UniqueToken), 0);
EXPECT_EQ(bk0.partialMatch(bk1), 1);
}