MCPcopy Create free account
hub / github.com/alibaba/MNN / encode

Method encode

transformers/diffusion/engine/src/tokenizer.cpp:75–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75std::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

Callers 5

runMethod · 0.45
encodePromptMethod · 0.45
encode_promptMethod · 0.45
encodeSingleMethod · 0.45
convert_modelsFunction · 0.45

Calls 3

copyFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected