enhance set_stop_value_multi_ends and standardize the registration of some operators (#4525)

* fix custom_ops

* paddleformers>=0.3.1
This commit is contained in:
Yuanle Liu
2025-10-21 22:06:06 +08:00
committed by GitHub
parent dc7facaa7f
commit 3b58310c26
18 changed files with 68 additions and 17 deletions

View File

@@ -18,6 +18,10 @@
#include <stdio.h>
#include "paddle/extension.h"
#ifndef PD_BUILD_STATIC_OP
#define PD_BUILD_STATIC_OP(name) PD_BUILD_OP(static_op_##name)
#endif
bool is_in_end(const int64_t id, const int64_t *end_ids, int length) {
bool flag = false;
for (int i = 0; i < length; i++) {
@@ -49,6 +53,8 @@ void set_value_by_flags(bool *stop_flags,
}
if (!beam_search && is_in_end(topk_ids[bi], end_ids, end_length)) {
stop_flags[bi] = true;
topk_ids[bi] = end_ids[0];
next_tokens[bi] = end_ids[0];
}
}
}