Skip to content

Commit 3136a84

Browse files
authored
common : remove unused token util functions (ggml-org#19506)
This commit removes two unused functions `common_lcp` and `common_lcs`. The last usage of these functions was removed in Commit 33eff40 ("server : vision support via libmtmd") and are no longer used anywhere in the codebase.
1 parent e463bbd commit 3136a84

File tree

2 files changed

+0
-70
lines changed

2 files changed

+0
-70
lines changed

common/common.cpp

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,66 +1469,6 @@ void common_batch_add(
14691469
batch.n_tokens++;
14701470
}
14711471

1472-
//
1473-
// Token utils
1474-
//
1475-
1476-
size_t common_lcp(const llama_tokens & a, const llama_tokens & b) {
1477-
size_t i;
1478-
for (i = 0; i < a.size() && i < b.size() && a[i] == b[i]; i++) {}
1479-
1480-
return i;
1481-
}
1482-
1483-
size_t common_lcs(const llama_tokens & a, const llama_tokens & b) {
1484-
// check for empty sequences
1485-
if (a.empty() || b.empty()) {
1486-
return 0;
1487-
}
1488-
1489-
// get the lengths of the input sequences
1490-
size_t a_len = a.size();
1491-
size_t b_len = b.size();
1492-
1493-
// initialize the maximum length of the longest common subsequence (LCS)
1494-
size_t max_length = 0;
1495-
1496-
// use two rows instead of a 2D matrix to optimize space
1497-
std::vector<size_t> prev_row(b_len + 1, 0);
1498-
std::vector<size_t> curr_row(b_len + 1, 0);
1499-
1500-
// iterate through the elements of a
1501-
for (size_t i = 1; i <= a_len; i++) {
1502-
// iterate through the elements of b
1503-
for (size_t j = 1; j <= b_len; j++) {
1504-
// if elements at the current positions match
1505-
if (a[i - 1] == b[j - 1]) {
1506-
// if it's the first element of either sequences, set LCS length to 1
1507-
if (i == 1 || j == 1) {
1508-
curr_row[j] = 1;
1509-
} else {
1510-
// increment LCS length by 1 compared to the previous element
1511-
curr_row[j] = prev_row[j - 1] + 1;
1512-
}
1513-
1514-
// update max_length if necessary
1515-
if (curr_row[j] > max_length) {
1516-
max_length = curr_row[j];
1517-
}
1518-
} else {
1519-
// reset LCS length if elements don't match
1520-
curr_row[j] = 0;
1521-
}
1522-
}
1523-
1524-
// update the previous row for the next iteration
1525-
prev_row = curr_row;
1526-
}
1527-
1528-
// return the maximum length of the LCS
1529-
return max_length;
1530-
}
1531-
15321472
//
15331473
// Vocab utils
15341474
//

common/common.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -779,16 +779,6 @@ void common_batch_add(
779779
const std::vector<llama_seq_id> & seq_ids,
780780
bool logits);
781781

782-
//
783-
// Token utils
784-
//
785-
786-
// longest common prefix
787-
size_t common_lcp(const llama_tokens & a, const llama_tokens & b);
788-
789-
// longet common subsequence
790-
size_t common_lcs(const llama_tokens & a, const llama_tokens & b);
791-
792782
//
793783
// Vocab utils
794784
//

0 commit comments

Comments
 (0)