| 73 | } |
| 74 | |
| 75 | std::vector<int> MtokTokenizer::encode(const std::string& sentence, int maxlen) { |
| 76 | #if defined(MNN_DIFFUSION_WITH_LLM_TOKENIZER) |
| 77 | if (mStyle == Style::kPair) { |
| 78 | std::vector<int> ids(maxlen * 2, 0); |
| 79 | auto uncond = encodeSingle("", maxlen); |
| 80 | auto cond = encodeSingle(sentence, maxlen); |
| 81 | std::copy(uncond.begin(), uncond.end(), ids.begin()); |
| 82 | std::copy(cond.begin(), cond.end(), ids.begin() + maxlen); |
| 83 | return ids; |
| 84 | } |
| 85 | return encodeSingle(sentence, maxlen); |
| 86 | #else |
| 87 | (void)sentence; |
| 88 | (void)maxlen; |
| 89 | return {}; |
| 90 | #endif |
| 91 | } |
| 92 | |
| 93 | } // namespace DIFFUSION |
| 94 | } // namespace MNN |
no test coverage detected